From 7e1183d2431759313aff5ed228943d8a52bb9811 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Mon, 22 Apr 2024 10:46:38 +0000 Subject: [PATCH] Updating based on 3bd4fc1c --- .../availableworkloadprofiles/README.md | 37 + .../availableworkloadprofiles/client.go | 26 + .../availableworkloadprofiles/constants.go | 51 + .../availableworkloadprofiles/id_location.go | 121 + .../id_location_test.go | 237 + .../availableworkloadprofiles/method_get.go | 91 + .../model_availableworkloadprofile.go | 17 + ...odel_availableworkloadprofileproperties.go | 13 + .../availableworkloadprofiles/predicates.go | 32 + .../availableworkloadprofiles/version.go | 12 + .../2024-03-01/billingmeters/README.md | 36 + .../2024-03-01/billingmeters/client.go | 26 + .../2024-03-01/billingmeters/id_location.go | 121 + .../billingmeters/id_location_test.go | 237 + .../2024-03-01/billingmeters/method_get.go | 55 + .../billingmeters/model_billingmeter.go | 17 + .../model_billingmetercollection.go | 8 + .../model_billingmeterproperties.go | 10 + .../2024-03-01/billingmeters}/version.go | 6 +- .../2024-03-01/certificates/README.md | 202 + .../2024-03-01/certificates/client.go | 26 + .../2024-03-01/certificates/constants.go | 60 + .../2024-03-01/certificates/id_certificate.go | 139 + .../certificates/id_certificate_test.go | 327 + .../certificates/id_connectedenvironment.go | 130 + .../id_connectedenvironment_test.go | 282 + .../id_connectedenvironmentcertificate.go | 139 + ...id_connectedenvironmentcertificate_test.go | 327 + .../certificates/id_managedenvironment.go | 130 + .../id_managedenvironment_test.go | 282 + ...denvironmentscertificatescreateorupdate.go | 58 + ...connectedenvironmentscertificatesdelete.go | 47 + ...od_connectedenvironmentscertificatesget.go | 54 + ...d_connectedenvironmentscertificateslist.go | 91 + ...connectedenvironmentscertificatesupdate.go | 58 + .../certificates/method_createorupdate.go | 58 + .../2024-03-01/certificates/method_delete.go | 47 + .../2024-03-01/certificates/method_get.go | 54 + .../2024-03-01/certificates/method_list.go | 91 + .../2024-03-01/certificates/method_update.go | 58 + .../certificates/model_certificate.go | 18 + .../certificates/model_certificatepatch.go | 8 + .../model_certificateproperties.go | 48 + .../2024-03-01/certificates/predicates.go | 32 + .../2024-03-01/certificates/version.go | 12 + .../containerapps/2024-03-01/client.go | 181 + .../connectedenvironments/README.md | 228 + .../connectedenvironments/client.go | 26 + .../connectedenvironments/constants.go | 198 + .../id_connectedenvironment.go | 130 + .../id_connectedenvironment_test.go | 282 + .../id_connectedenvironmentcertificate.go | 139 + ...id_connectedenvironmentcertificate_test.go | 327 + .../method_certificatescreateorupdate.go | 58 + .../method_certificatesdelete.go | 47 + .../method_certificatesget.go | 54 + .../method_certificateslist.go | 91 + .../method_certificatesupdate.go | 58 + .../method_checknameavailability.go | 59 + .../method_createorupdate.go | 75 + .../connectedenvironments/method_delete.go | 71 + .../connectedenvironments/method_get.go | 54 + .../method_listbyresourcegroup.go | 92 + .../method_listbysubscription.go | 92 + .../connectedenvironments/method_update.go | 54 + .../model_certificate.go | 18 + .../model_certificatepatch.go | 8 + .../model_certificateproperties.go | 48 + .../model_checknameavailabilityrequest.go | 9 + .../model_checknameavailabilityresponse.go | 10 + .../model_connectedenvironment.go | 19 + .../model_connectedenvironmentproperties.go | 13 + .../model_customdomainconfiguration.go | 32 + .../model_extendedlocation.go | 9 + .../connectedenvironments/predicates.go | 60 + .../connectedenvironments/version.go | 12 + .../connectedenvironmentsstorages/README.md | 89 + .../connectedenvironmentsstorages/client.go | 26 + .../constants.go | 51 + .../id_connectedenvironment.go | 130 + .../id_connectedenvironment_test.go | 282 + .../id_connectedenvironmentstorage.go | 139 + .../id_connectedenvironmentstorage_test.go | 327 + .../method_createorupdate.go | 58 + .../method_delete.go | 47 + .../method_get.go | 54 + .../method_list.go | 55 + .../model_azurefileproperties.go | 11 + .../model_connectedenvironmentstorage.go | 16 + ...l_connectedenvironmentstorageproperties.go | 8 + ..._connectedenvironmentstoragescollection.go | 8 + .../connectedenvironmentsstorages/version.go | 12 + .../2024-03-01/containerapps/README.md | 271 + .../2024-03-01/containerapps/client.go | 26 + .../2024-03-01/containerapps/constants.go | 761 ++ .../containerapps/id_containerapp.go | 130 + .../containerapps/id_containerapp_test.go | 282 + .../containerapps/id_containerappdetector.go | 139 + .../id_containerappdetector_test.go | 327 + .../containerapps/id_revisionsapirevision.go | 141 + .../id_revisionsapirevision_test.go | 357 + .../containerapps/method_createorupdate.go | 75 + .../2024-03-01/containerapps/method_delete.go | 71 + .../method_diagnosticsgetdetector.go | 54 + .../method_diagnosticsgetrevision.go | 54 + .../method_diagnosticsgetroot.go | 55 + .../method_diagnosticslistdetectors.go | 91 + .../method_diagnosticslistrevisions.go | 119 + .../2024-03-01/containerapps/method_get.go | 54 + .../containerapps/method_getauthtoken.go | 55 + .../method_listbyresourcegroup.go | 92 + .../method_listbysubscription.go | 92 + .../method_listcustomhostnameanalysis.go | 83 + .../containerapps/method_listsecrets.go | 55 + .../2024-03-01/containerapps/method_start.go | 71 + .../2024-03-01/containerapps/method_stop.go | 71 + .../2024-03-01/containerapps/method_update.go | 75 + .../containerapps/model_basecontainer.go | 14 + .../containerapps/model_configuration.go | 14 + .../containerapps/model_container.go | 15 + .../containerapps/model_containerapp.go | 22 + .../model_containerappauthtoken.go | 18 + .../model_containerappauthtokenproperties.go | 27 + .../containerapps/model_containerappprobe.go | 16 + .../model_containerappprobehttpget.go | 12 + ...tainerappprobehttpgethttpheadersinlined.go | 9 + .../model_containerappprobetcpsocket.go | 9 + .../model_containerappproperties.go | 19 + .../containerapps/model_containerappsecret.go | 11 + .../containerapps/model_containerresources.go | 10 + .../containerapps/model_corspolicy.go | 13 + .../containerapps/model_customdomain.go | 10 + .../model_customhostnameanalysisresult.go | 19 + ...sultcustomdomainverificationfailureinfo.go | 11 + ...inverificationfailureinfodetailsinlined.go | 10 + .../containerapps/model_customscalerule.go | 10 + .../2024-03-01/containerapps/model_dapr.go | 15 + .../model_diagnosticdataprovidermetadata.go | 9 + ...cdataprovidermetadatapropertybaginlined.go | 9 + ...model_diagnosticdatatableresponsecolumn.go | 10 + ...model_diagnosticdatatableresponseobject.go | 10 + .../model_diagnosticrendering.go | 11 + .../containerapps/model_diagnostics.go | 16 + .../model_diagnosticsdataapiresponse.go | 9 + .../model_diagnosticsdefinition.go | 16 + .../model_diagnosticsproperties.go | 11 + .../containerapps/model_diagnosticsstatus.go | 9 + .../model_diagnosticsupporttopic.go | 9 + .../containerapps/model_environmentvar.go | 10 + .../containerapps/model_extendedlocation.go | 9 + .../containerapps/model_httpscalerule.go | 9 + .../2024-03-01/containerapps/model_ingress.go | 20 + .../containerapps/model_ingressportmapping.go | 10 + .../model_ingressstickysessions.go | 8 + .../model_ipsecurityrestrictionrule.go | 11 + .../containerapps/model_queuescalerule.go | 10 + .../model_registrycredentials.go | 11 + .../containerapps/model_revision.go | 16 + .../containerapps/model_revisionproperties.go | 48 + .../2024-03-01/containerapps/model_scale.go | 10 + .../containerapps/model_scalerule.go | 12 + .../containerapps/model_scaleruleauth.go | 9 + .../2024-03-01/containerapps/model_secret.go | 11 + .../containerapps/model_secretscollection.go | 8 + .../containerapps/model_secretvolumeitem.go | 9 + .../2024-03-01/containerapps/model_service.go | 8 + .../containerapps/model_servicebind.go | 9 + .../containerapps/model_tcpscalerule.go | 9 + .../containerapps/model_template.go | 14 + .../containerapps/model_trafficweight.go | 11 + .../2024-03-01/containerapps/model_volume.go | 12 + .../containerapps/model_volumemount.go | 10 + .../2024-03-01/containerapps/predicates.go | 83 + .../2024-03-01/containerapps/version.go | 12 + .../containerappsauthconfigs/README.md | 90 + .../containerappsauthconfigs}/client.go | 12 +- .../containerappsauthconfigs/constants.go | 180 + .../containerappsauthconfigs/id_authconfig.go | 139 + .../id_authconfig_test.go | 327 + .../id_containerapp.go | 130 + .../id_containerapp_test.go | 282 + .../method_createorupdate.go | 58 + .../containerappsauthconfigs/method_delete.go | 47 + .../containerappsauthconfigs/method_get.go | 54 + .../method_listbycontainerapp.go | 91 + .../model_allowedaudiencesvalidation.go | 8 + .../model_allowedprincipals.go | 9 + .../containerappsauthconfigs/model_apple.go | 10 + .../model_appleregistration.go | 9 + .../model_appregistration.go | 9 + .../model_authconfig.go | 16 + .../model_authconfigproperties.go | 13 + .../model_authplatform.go | 9 + .../model_azureactivedirectory.go | 12 + .../model_azureactivedirectorylogin.go | 9 + .../model_azureactivedirectoryregistration.go | 13 + .../model_azureactivedirectoryvalidation.go | 10 + .../model_azurestaticwebapps.go | 9 + .../model_azurestaticwebappsregistration.go | 8 + .../model_blobstoragetokenstore.go | 8 + .../model_clientregistration.go | 9 + .../model_cookieexpiration.go | 9 + .../model_customopenidconnectprovider.go | 10 + .../model_defaultauthorizationpolicy.go | 9 + .../model_encryptionsettings.go | 9 + .../model_facebook.go | 11 + .../model_forwardproxy.go | 10 + .../containerappsauthconfigs/model_github.go | 10 + .../model_globalvalidation.go | 10 + .../containerappsauthconfigs/model_google.go | 11 + .../model_httpsettings.go | 10 + .../model_httpsettingsroutes.go | 8 + .../model_identityproviders.go | 15 + .../model_jwtclaimchecks.go | 9 + .../containerappsauthconfigs/model_login.go | 13 + .../model_loginroutes.go | 8 + .../model_loginscopes.go | 8 + .../containerappsauthconfigs/model_nonce.go | 9 + .../model_openidconnectclientcredential.go | 9 + .../model_openidconnectconfig.go | 12 + .../model_openidconnectlogin.go | 9 + .../model_openidconnectregistration.go | 10 + .../model_tokenstore.go | 10 + .../containerappsauthconfigs/model_twitter.go | 9 + .../model_twitterregistration.go | 9 + .../containerappsauthconfigs/predicates.go | 27 + .../containerappsauthconfigs/version.go | 12 + .../containerappsrevisionreplicas/README.md | 52 + .../containerappsrevisionreplicas/client.go | 26 + .../constants.go | 98 + .../id_replica.go | 148 + .../id_replica_test.go | 372 + .../id_revision.go | 139 + .../id_revision_test.go | 327 + .../method_getreplica.go | 54 + .../method_listreplicas.go | 55 + .../model_replica.go | 16 + .../model_replicacollection.go | 8 + .../model_replicacontainer.go | 16 + .../model_replicaproperties.go | 30 + .../containerappsrevisionreplicas/version.go | 12 + .../containerappsrevisions/README.md | 101 + .../containerappsrevisions/client.go | 26 + .../containerappsrevisions/constants.go | 286 + .../containerappsrevisions/id_containerapp.go | 130 + .../id_containerapp_test.go | 282 + .../containerappsrevisions/id_revision.go | 139 + .../id_revision_test.go | 327 + .../method_activaterevision.go | 47 + .../method_deactivaterevision.go | 47 + .../method_getrevision.go | 54 + .../method_listrevisions.go | 119 + .../method_restartrevision.go | 47 + .../model_basecontainer.go | 14 + .../containerappsrevisions/model_container.go | 15 + .../model_containerappprobe.go | 16 + .../model_containerappprobehttpget.go | 12 + ...tainerappprobehttpgethttpheadersinlined.go | 9 + .../model_containerappprobetcpsocket.go | 9 + .../model_containerresources.go | 10 + .../model_customscalerule.go | 10 + .../model_environmentvar.go | 10 + .../model_httpscalerule.go | 9 + .../model_queuescalerule.go | 10 + .../containerappsrevisions/model_revision.go | 16 + .../model_revisionproperties.go | 48 + .../containerappsrevisions/model_scale.go | 10 + .../containerappsrevisions/model_scalerule.go | 12 + .../model_scaleruleauth.go | 9 + .../model_secretvolumeitem.go | 9 + .../model_servicebind.go | 9 + .../model_tcpscalerule.go | 9 + .../containerappsrevisions/model_template.go | 14 + .../containerappsrevisions/model_volume.go | 12 + .../model_volumemount.go | 10 + .../containerappsrevisions/predicates.go | 27 + .../containerappsrevisions/version.go | 12 + .../containerappssourcecontrols/README.md | 82 + .../containerappssourcecontrols/client.go | 26 + .../containerappssourcecontrols/constants.go | 57 + .../id_containerapp.go | 130 + .../id_containerapp_test.go | 282 + .../id_sourcecontrol.go | 139 + .../id_sourcecontrol_test.go | 327 + .../method_createorupdate.go | 75 + .../method_delete.go | 71 + .../containerappssourcecontrols/method_get.go | 54 + .../method_listbycontainerapp.go | 91 + .../model_azurecredentials.go | 12 + .../model_githubactionconfiguration.go | 16 + .../model_registryinfo.go | 10 + .../model_sourcecontrol.go | 16 + .../model_sourcecontrolproperties.go | 11 + .../containerappssourcecontrols/predicates.go | 27 + .../containerappssourcecontrols/version.go | 12 + .../2024-03-01/daprcomponents/README.md | 192 + .../2024-03-01/daprcomponents/client.go | 26 + .../daprcomponents/id_connectedenvironment.go | 130 + .../id_connectedenvironment_test.go | 282 + .../id_connectedenvironmentdaprcomponent.go | 139 + ..._connectedenvironmentdaprcomponent_test.go | 327 + .../daprcomponents/id_daprcomponent.go | 139 + .../daprcomponents/id_daprcomponent_test.go | 327 + .../daprcomponents/id_managedenvironment.go | 130 + .../id_managedenvironment_test.go | 282 + ...nvironmentsdaprcomponentscreateorupdate.go | 58 + ...nnectedenvironmentsdaprcomponentsdelete.go | 47 + ..._connectedenvironmentsdaprcomponentsget.go | 54 + ...connectedenvironmentsdaprcomponentslist.go | 91 + ...edenvironmentsdaprcomponentslistsecrets.go | 55 + .../daprcomponents/method_createorupdate.go | 58 + .../daprcomponents/method_delete.go | 47 + .../2024-03-01/daprcomponents/method_get.go | 54 + .../2024-03-01/daprcomponents/method_list.go | 91 + .../daprcomponents/method_listsecrets.go | 55 + .../daprcomponents/model_daprcomponent.go | 16 + .../model_daprcomponentproperties.go | 15 + .../daprcomponents/model_daprmetadata.go | 10 + .../daprcomponents/model_daprsecret.go | 9 + .../model_daprsecretscollection.go | 8 + .../2024-03-01/daprcomponents/model_secret.go | 11 + .../2024-03-01/daprcomponents/predicates.go | 27 + .../2024-03-01/daprcomponents/version.go | 12 + .../2024-03-01/diagnostics/README.md | 200 + .../2024-03-01/diagnostics/client.go | 26 + .../2024-03-01/diagnostics/constants.go | 876 ++ .../2024-03-01/diagnostics/id_containerapp.go | 130 + .../diagnostics/id_containerapp_test.go | 282 + .../diagnostics/id_containerappdetector.go | 139 + .../id_containerappdetector_test.go | 327 + .../2024-03-01/diagnostics/id_detector.go | 139 + .../diagnostics/id_detector_test.go | 327 + .../diagnostics/id_detectorproperty.go | 139 + .../diagnostics/id_detectorproperty_test.go | 327 + .../2024-03-01/diagnostics/id_job.go | 130 + .../2024-03-01/diagnostics/id_job_test.go} | 80 +- .../diagnostics/id_managedenvironment.go | 130 + .../diagnostics/id_managedenvironment_test.go | 282 + .../id_managedenvironmentdetector.go | 139 + .../id_managedenvironmentdetector_test.go | 327 + .../diagnostics/id_revisionsapirevision.go | 141 + .../id_revisionsapirevision_test.go | 357 + ...hod_containerappsdiagnosticsgetdetector.go | 54 + ...hod_containerappsdiagnosticsgetrevision.go | 54 + .../method_containerappsdiagnosticsgetroot.go | 55 + ...d_containerappsdiagnosticslistdetectors.go | 91 + ...d_containerappsdiagnosticslistrevisions.go | 119 + .../diagnostics/method_jobsgetdetector.go | 54 + .../diagnostics/method_jobslistdetectors.go | 91 + .../diagnostics/method_jobsproxyget.go | 54 + ...anagedenvironmentdiagnosticsgetdetector.go | 54 + ...agedenvironmentdiagnosticslistdetectors.go | 91 + ...d_managedenvironmentsdiagnosticsgetroot.go | 55 + .../diagnostics/model_applogsconfiguration.go | 9 + .../diagnostics/model_basecontainer.go | 14 + .../diagnostics/model_configuration.go | 14 + .../2024-03-01/diagnostics/model_container.go | 15 + .../diagnostics/model_containerapp.go | 22 + .../diagnostics/model_containerappprobe.go | 16 + .../model_containerappprobehttpget.go | 12 + ...tainerappprobehttpgethttpheadersinlined.go | 9 + .../model_containerappprobetcpsocket.go | 9 + .../model_containerappproperties.go | 19 + .../diagnostics/model_containerresources.go | 10 + .../diagnostics/model_corspolicy.go | 13 + .../diagnostics/model_customdomain.go | 10 + .../model_customdomainconfiguration.go | 32 + .../diagnostics/model_customscalerule.go | 10 + .../2024-03-01/diagnostics/model_dapr.go | 15 + .../diagnostics/model_daprconfiguration.go | 8 + .../model_diagnosticdataprovidermetadata.go | 9 + ...cdataprovidermetadatapropertybaginlined.go | 9 + ...model_diagnosticdatatableresponsecolumn.go | 10 + ...model_diagnosticdatatableresponseobject.go | 10 + .../diagnostics/model_diagnosticrendering.go | 11 + .../diagnostics/model_diagnostics.go | 16 + .../model_diagnosticsdataapiresponse.go | 9 + .../model_diagnosticsdefinition.go | 16 + .../model_diagnosticsproperties.go | 11 + .../diagnostics/model_diagnosticsstatus.go | 9 + .../model_diagnosticsupporttopic.go | 9 + .../diagnostics/model_environmentvar.go | 10 + .../diagnostics/model_extendedlocation.go | 9 + .../diagnostics/model_httpscalerule.go | 9 + .../2024-03-01/diagnostics/model_ingress.go | 20 + .../diagnostics/model_ingressportmapping.go | 10 + .../model_ingressstickysessions.go | 8 + .../model_ipsecurityrestrictionrule.go | 11 + .../2024-03-01/diagnostics/model_job.go | 20 + .../diagnostics/model_jobconfiguration.go | 15 + ...odel_jobconfigurationeventtriggerconfig.go | 10 + ...del_jobconfigurationmanualtriggerconfig.go | 9 + ...l_jobconfigurationscheduletriggerconfig.go | 10 + .../diagnostics/model_jobproperties.go | 14 + .../2024-03-01/diagnostics/model_jobscale.go | 11 + .../diagnostics/model_jobscalerule.go | 11 + .../diagnostics/model_jobtemplate.go | 10 + .../diagnostics/model_kedaconfiguration.go | 8 + .../model_loganalyticsconfiguration.go | 9 + .../diagnostics/model_managedenvironment.go | 19 + .../model_managedenvironmentproperties.go | 24 + ...environmentpropertiespeerauthentication.go | 8 + ...nmentpropertiespeertrafficconfiguration.go | 8 + ...rtiespeertrafficconfigurationencryption.go | 8 + .../2024-03-01/diagnostics/model_mtls.go | 8 + .../diagnostics/model_queuescalerule.go | 10 + .../diagnostics/model_registrycredentials.go | 11 + .../2024-03-01/diagnostics/model_revision.go | 16 + .../diagnostics/model_revisionproperties.go | 48 + .../2024-03-01/diagnostics/model_scale.go | 10 + .../2024-03-01/diagnostics/model_scalerule.go | 12 + .../diagnostics/model_scaleruleauth.go | 9 + .../2024-03-01/diagnostics/model_secret.go | 11 + .../diagnostics/model_secretvolumeitem.go | 9 + .../2024-03-01/diagnostics/model_service.go | 8 + .../diagnostics/model_servicebind.go | 9 + .../diagnostics/model_tcpscalerule.go | 9 + .../2024-03-01/diagnostics/model_template.go | 14 + .../diagnostics/model_trafficweight.go | 11 + .../diagnostics/model_vnetconfiguration.go | 12 + .../2024-03-01/diagnostics/model_volume.go | 12 + .../diagnostics/model_volumemount.go | 10 + .../diagnostics/model_workloadprofile.go | 11 + .../2024-03-01/diagnostics/predicates.go | 50 + .../2024-03-01/diagnostics/version.go | 12 + .../containerapps/2024-03-01/jobs/README.md | 261 + .../containerapps/2024-03-01/jobs/client.go | 26 + .../2024-03-01/jobs/constants.go | 289 + .../2024-03-01/jobs/id_detector.go | 139 + .../2024-03-01/jobs/id_detector_test.go | 327 + .../2024-03-01/jobs/id_detectorproperty.go | 139 + .../jobs/id_detectorproperty_test.go | 327 + .../2024-03-01/jobs/id_execution.go | 139 + .../2024-03-01/jobs/id_execution_test.go | 327 + .../containerapps/2024-03-01/jobs/id_job.go | 130 + .../2024-03-01/jobs/id_job_test.go | 282 + .../2024-03-01/jobs/method_createorupdate.go | 75 + .../2024-03-01/jobs/method_delete.go | 71 + .../2024-03-01/jobs/method_executionslist.go | 119 + .../2024-03-01/jobs/method_get.go | 54 + .../2024-03-01/jobs/method_getdetector.go | 54 + .../2024-03-01/jobs/method_jobexecution.go | 54 + .../jobs/method_listbyresourcegroup.go | 92 + .../jobs/method_listbysubscription.go | 92 + .../2024-03-01/jobs/method_listdetectors.go | 91 + .../2024-03-01/jobs/method_listsecrets.go | 55 + .../2024-03-01/jobs/method_proxyget.go | 54 + .../2024-03-01/jobs/method_start.go | 75 + .../2024-03-01/jobs/method_stopexecution.go | 70 + .../jobs/method_stopmultipleexecutions.go | 76 + .../2024-03-01/jobs/method_update.go | 75 + .../2024-03-01/jobs/model_basecontainer.go | 14 + .../2024-03-01/jobs/model_container.go | 15 + .../jobs/model_containerappprobe.go | 16 + .../jobs/model_containerappprobehttpget.go | 12 + ...tainerappprobehttpgethttpheadersinlined.go | 9 + .../jobs/model_containerappprobetcpsocket.go | 9 + .../jobs/model_containerresources.go | 10 + .../model_diagnosticdataprovidermetadata.go | 9 + ...cdataprovidermetadatapropertybaginlined.go | 9 + ...model_diagnosticdatatableresponsecolumn.go | 10 + ...model_diagnosticdatatableresponseobject.go | 10 + .../jobs/model_diagnosticrendering.go | 11 + .../2024-03-01/jobs/model_diagnostics.go | 16 + .../jobs/model_diagnosticsdataapiresponse.go | 9 + .../jobs/model_diagnosticsdefinition.go | 16 + .../jobs/model_diagnosticsproperties.go | 11 + .../jobs/model_diagnosticsstatus.go | 9 + .../jobs/model_diagnosticsupporttopic.go | 9 + .../2024-03-01/jobs/model_environmentvar.go | 10 + .../2024-03-01/jobs/model_job.go | 20 + .../2024-03-01/jobs/model_jobconfiguration.go | 15 + ...odel_jobconfigurationeventtriggerconfig.go | 10 + ...del_jobconfigurationmanualtriggerconfig.go | 9 + ...l_jobconfigurationscheduletriggerconfig.go | 10 + .../2024-03-01/jobs/model_jobexecution.go | 11 + .../2024-03-01/jobs/model_jobexecutionbase.go | 9 + .../jobs/model_jobexecutioncontainer.go | 13 + .../jobs/model_jobexecutionproperties.go | 41 + .../jobs/model_jobexecutiontemplate.go | 9 + .../jobs/model_jobpatchproperties.go | 14 + .../model_jobpatchpropertiesproperties.go | 12 + .../2024-03-01/jobs/model_jobproperties.go | 14 + .../2024-03-01/jobs/model_jobscale.go | 11 + .../2024-03-01/jobs/model_jobscalerule.go | 11 + .../jobs/model_jobsecretscollection.go | 8 + .../2024-03-01/jobs/model_jobtemplate.go | 10 + .../jobs/model_registrycredentials.go | 11 + .../2024-03-01/jobs/model_scaleruleauth.go | 9 + .../2024-03-01/jobs/model_secret.go | 11 + .../2024-03-01/jobs/model_secretvolumeitem.go | 9 + .../2024-03-01/jobs/model_volume.go | 12 + .../2024-03-01/jobs/model_volumemount.go | 10 + .../2024-03-01/jobs/predicates.go | 78 + .../containerapps/2024-03-01/jobs/version.go | 12 + .../2024-03-01/managedcertificates/README.md | 107 + .../2024-03-01/managedcertificates/client.go | 26 + .../managedcertificates/constants.go | 104 + .../id_managedcertificate.go | 139 + .../id_managedcertificate_test.go | 327 + .../id_managedenvironment.go | 130 + .../id_managedenvironment_test.go | 282 + .../method_createorupdate.go | 75 + .../managedcertificates/method_delete.go | 47 + .../managedcertificates/method_get.go | 54 + .../managedcertificates/method_list.go | 91 + .../managedcertificates/method_update.go | 58 + .../model_managedcertificate.go | 18 + .../model_managedcertificatepatch.go | 8 + .../model_managedcertificateproperties.go | 12 + .../managedcertificates/predicates.go | 32 + .../2024-03-01/managedcertificates/version.go | 12 + .../2024-03-01/managedenvironments/README.md | 398 + .../2024-03-01/managedenvironments/client.go | 26 + .../managedenvironments/constants.go | 210 + .../managedenvironments/id_certificate.go | 139 + .../id_certificate_test.go | 327 + .../id_managedcertificate.go | 139 + .../id_managedcertificate_test.go | 327 + .../id_managedenvironment.go | 130 + .../id_managedenvironment_test.go | 282 + .../id_managedenvironmentdetector.go | 139 + .../id_managedenvironmentdetector_test.go | 327 + .../method_certificatescreateorupdate.go | 58 + .../method_certificatesdelete.go | 47 + .../method_certificatesget.go | 54 + .../method_certificateslist.go | 91 + .../method_certificatesupdate.go | 58 + .../method_createorupdate.go | 75 + .../managedenvironments/method_delete.go | 71 + .../method_diagnosticsgetroot.go | 55 + .../managedenvironments/method_get.go | 54 + .../method_getauthtoken.go | 55 + .../method_listbyresourcegroup.go | 92 + .../method_listbysubscription.go | 92 + .../method_listworkloadprofilestates.go | 91 + ...ethod_managedcertificatescreateorupdate.go | 75 + .../method_managedcertificatesdelete.go | 47 + .../method_managedcertificatesget.go | 54 + .../method_managedcertificateslist.go | 91 + .../method_managedcertificatesupdate.go | 58 + ...anagedenvironmentdiagnosticsgetdetector.go | 54 + ...agedenvironmentdiagnosticslistdetectors.go | 91 + .../method_namespaceschecknameavailability.go | 59 + .../managedenvironments/method_update.go | 75 + .../model_applogsconfiguration.go | 9 + .../managedenvironments/model_certificate.go | 18 + .../model_certificatepatch.go | 8 + .../model_certificateproperties.go | 48 + .../model_checknameavailabilityrequest.go | 9 + .../model_checknameavailabilityresponse.go | 10 + .../model_customdomainconfiguration.go | 32 + .../model_daprconfiguration.go | 8 + .../model_diagnosticdataprovidermetadata.go | 9 + ...cdataprovidermetadatapropertybaginlined.go | 9 + ...model_diagnosticdatatableresponsecolumn.go | 10 + ...model_diagnosticdatatableresponseobject.go | 10 + .../model_diagnosticrendering.go | 11 + .../managedenvironments/model_diagnostics.go | 16 + .../model_diagnosticsdataapiresponse.go | 9 + .../model_diagnosticsdefinition.go | 16 + .../model_diagnosticsproperties.go | 11 + .../model_diagnosticsstatus.go | 9 + .../model_diagnosticsupporttopic.go | 9 + .../model_environmentauthtoken.go | 18 + .../model_environmentauthtokenproperties.go | 27 + .../model_kedaconfiguration.go | 8 + .../model_loganalyticsconfiguration.go | 9 + .../model_managedcertificate.go | 18 + .../model_managedcertificatepatch.go | 8 + .../model_managedcertificateproperties.go | 12 + .../model_managedenvironment.go | 19 + .../model_managedenvironmentproperties.go | 24 + ...environmentpropertiespeerauthentication.go | 8 + ...nmentpropertiespeertrafficconfiguration.go | 8 + ...rtiespeertrafficconfigurationencryption.go | 8 + .../managedenvironments/model_mtls.go | 8 + .../model_vnetconfiguration.go | 12 + .../model_workloadprofile.go | 11 + .../model_workloadprofilestates.go | 16 + .../model_workloadprofilestatesproperties.go | 10 + .../managedenvironments/predicates.go | 139 + .../2024-03-01/managedenvironments/version.go | 12 + .../managedenvironmentsstorages/README.md | 89 + .../managedenvironmentsstorages/client.go | 26 + .../managedenvironmentsstorages/constants.go | 51 + .../id_managedenvironment.go | 130 + .../id_managedenvironment_test.go | 282 + .../managedenvironmentsstorages/id_storage.go | 139 + .../id_storage_test.go | 327 + .../method_createorupdate.go | 58 + .../method_delete.go | 47 + .../managedenvironmentsstorages/method_get.go | 54 + .../method_list.go | 55 + .../model_azurefileproperties.go | 11 + .../model_managedenvironmentstorage.go | 16 + ...del_managedenvironmentstorageproperties.go | 8 + ...el_managedenvironmentstoragescollection.go | 8 + .../managedenvironmentsstorages/version.go | 12 + .../2024-03-01/subscriptions/client.go | 26 + .../method_getcustomdomainverificationid.go | 56 + .../2024-03-01/subscriptions/version.go | 12 + .../containerapps/2024-03-01/usages/README.md | 54 + .../containerapps/2024-03-01/usages/client.go | 26 + .../2024-03-01/usages/constants.go | 48 + .../2024-03-01/usages/id_location.go | 121 + .../2024-03-01/usages/id_location_test.go | 237 + .../usages/id_managedenvironment.go | 130 + .../usages/id_managedenvironment_test.go | 282 + .../2024-03-01/usages/method_list.go | 91 + .../method_managedenvironmentusageslist.go | 91 + .../2024-03-01/usages/model_usage.go | 11 + .../2024-03-01/usages/model_usagename.go | 9 + .../2024-03-01/usages/predicates.go | 22 + .../2024-03-01/usages/version.go | 12 + .../model_managedidentitycredential.go | 2 +- .../2018-06-01/pipelines/constants.go | 41 - .../model_scriptactivityscriptblock.go | 2 +- .../2024-04-01/azurebackupjob/README.md | 64 + .../2024-04-01/azurebackupjob/client.go | 26 + .../2024-04-01/azurebackupjob/id_backupjob.go | 139 + .../azurebackupjob/id_backupjob_test.go | 327 + .../azurebackupjob/id_backupvault.go | 130 + .../azurebackupjob/id_backupvault_test.go | 282 + .../azurebackupjob/id_operationid.go | 140 + .../azurebackupjob/id_operationid_test.go | 342 + .../method_exportjobsoperationresultget.go | 55 + .../method_exportjobstrigger.go | 70 + .../azurebackupjob/method_jobsget.go | 54 + .../azurebackupjob/model_azurebackupjob.go | 65 + .../model_azurebackupjobresource.go | 16 + .../azurebackupjob/model_exportjobsresult.go | 11 + .../azurebackupjob/model_innererror.go | 10 + .../azurebackupjob/model_jobextendedinfo.go | 15 + .../azurebackupjob/model_jobsubtask.go | 12 + .../model_restorejobrecoverypointdetails.go | 27 + .../azurebackupjob/model_userfacingerror.go | 16 + .../model_userfacingwarningdetail.go | 9 + .../2024-04-01/azurebackupjob/version.go | 12 + .../2024-04-01/azurebackupjobs/README.md | 37 + .../2024-04-01/azurebackupjobs/client.go | 26 + .../azurebackupjobs/id_backupvault.go | 130 + .../azurebackupjobs/id_backupvault_test.go | 282 + .../azurebackupjobs/method_jobslist.go | 91 + .../azurebackupjobs/model_azurebackupjob.go | 65 + .../model_azurebackupjobresource.go | 16 + .../azurebackupjobs/model_innererror.go | 10 + .../azurebackupjobs/model_jobextendedinfo.go | 15 + .../azurebackupjobs/model_jobsubtask.go | 12 + .../model_restorejobrecoverypointdetails.go | 27 + .../azurebackupjobs/model_userfacingerror.go | 16 + .../model_userfacingwarningdetail.go | 9 + .../2024-04-01/azurebackupjobs/predicates.go | 27 + .../2024-04-01/azurebackupjobs/version.go | 12 + .../2024-04-01/backupinstances/README.md | 276 + .../2024-04-01/backupinstances/client.go | 26 + .../2024-04-01/backupinstances/constants.go | 594 ++ .../backupinstances/id_backupinstance.go | 139 + .../backupinstances/id_backupinstance_test.go | 327 + .../backupinstances/id_backupvault.go | 130 + .../backupinstances/id_backupvault_test.go | 282 + .../backupinstances/id_providerlocation.go | 130 + .../id_providerlocation_test.go | 282 + .../backupinstances/method_adhocbackup.go | 75 + .../backupinstances/method_createorupdate.go | 104 + .../backupinstances/method_delete.go | 99 + .../2024-04-01/backupinstances/method_get.go | 54 + .../2024-04-01/backupinstances/method_list.go | 91 + .../backupinstances/method_resumebackups.go | 70 + .../method_resumeprotection.go | 70 + .../backupinstances/method_stopprotection.go | 102 + .../backupinstances/method_suspendbackups.go | 102 + .../method_syncbackupinstance.go | 74 + .../method_triggercrossregionrestore.go | 75 + .../method_triggerrehydrate.go | 74 + .../backupinstances/method_triggerrestore.go | 103 + .../method_validatecrossregionrestore.go | 75 + .../method_validateforbackup.go | 75 + .../method_validateforrestore.go | 75 + .../model_adhocbackupruleoptions.go | 9 + .../model_adhocbackuptriggeroption.go | 8 + .../backupinstances/model_authcredentials.go | 53 + ...ebackuprecoverypointbasedrestorerequest.go | 76 + ...rebackuprecoverytimebasedrestorerequest.go | 76 + .../model_azurebackuprehydrationrequest.go | 10 + .../model_azurebackuprestorerequest.go | 69 + ...zurebackuprestorewithrehydrationrequest.go | 80 + .../model_azureoperationalstoreparameters.go | 42 + .../model_backupdatasourceparameters.go | 61 + .../backupinstances/model_backupinstance.go | 62 + .../model_backupinstanceresource.go | 17 + .../model_baseresourceproperties.go | 53 + .../model_blobbackupdatasourceparameters.go | 41 + .../model_crossregionrestoredetails.go | 9 + .../model_crossregionrestorerequestobject.go | 40 + .../backupinstances/model_datasource.go | 52 + .../backupinstances/model_datasourceset.go | 52 + .../model_datastoreparameters.go | 53 + .../model_defaultresourceproperties.go | 40 + .../backupinstances/model_identitydetails.go | 9 + .../backupinstances/model_innererror.go | 10 + .../model_itemlevelrestorecriteria.go | 93 + .../model_itemlevelrestoretargetinfo.go | 92 + .../model_itempathbasedrestorecriteria.go | 43 + ...rnetesclusterbackupdatasourceparameters.go | 48 + .../model_kubernetesclusterrestorecriteria.go | 51 + ...bernetesclustervaulttierrestorecriteria.go | 53 + .../model_kubernetespvrestorecriteria.go | 42 + ...l_kubernetesstorageclassrestorecriteria.go | 42 + .../model_namespacednameresource.go | 9 + .../model_operationextendedinfo.go | 53 + .../model_operationjobextendedinfo.go | 41 + .../backupinstances/model_policyinfo.go | 10 + .../backupinstances/model_policyparameters.go | 59 + .../model_protectionstatusdetails.go | 9 + ...odel_rangebaseditemlevelrestorecriteria.go | 42 + .../model_restorefilestargetinfo.go | 43 + .../model_restoretargetinfo.go | 74 + .../model_restoretargetinfobase.go | 69 + .../model_secretstorebasedauthcredentials.go | 41 + .../model_secretstoreresource.go | 10 + .../model_stopprotectionrequest.go | 8 + .../model_suspendbackuprequest.go | 8 + .../model_syncbackupinstancerequest.go | 8 + .../backupinstances/model_targetdetails.go | 11 + .../model_triggerbackuprequest.go | 8 + .../backupinstances/model_userfacingerror.go | 16 + ...validatecrossregionrestorerequestobject.go | 40 + .../model_validateforbackuprequest.go | 8 + .../model_validaterestorerequestobject.go | 32 + .../2024-04-01/backupinstances/predicates.go | 27 + .../2024-04-01/backupinstances/version.go | 12 + .../backupinstancesextensionrouting/README.md | 38 + .../backupinstancesextensionrouting/client.go | 26 + .../constants.go | 298 + .../method_list.go | 92 + .../model_authcredentials.go | 53 + .../model_azureoperationalstoreparameters.go | 42 + .../model_backupdatasourceparameters.go | 61 + .../model_backupinstance.go | 62 + .../model_backupinstanceresource.go | 17 + .../model_baseresourceproperties.go | 53 + .../model_blobbackupdatasourceparameters.go | 41 + .../model_datasource.go | 52 + .../model_datasourceset.go | 52 + .../model_datastoreparameters.go | 53 + .../model_defaultresourceproperties.go | 40 + .../model_identitydetails.go | 9 + .../model_innererror.go | 10 + ...rnetesclusterbackupdatasourceparameters.go | 48 + .../model_namespacednameresource.go | 9 + .../model_policyinfo.go | 10 + .../model_policyparameters.go | 59 + .../model_protectionstatusdetails.go | 9 + .../model_secretstorebasedauthcredentials.go | 41 + .../model_secretstoreresource.go | 10 + .../model_userfacingerror.go | 16 + .../predicates.go | 27 + .../version.go | 12 + .../2024-04-01/backuppolicies/README.md | 90 + .../2024-04-01/backuppolicies/client.go | 26 + .../2024-04-01/backuppolicies/constants.go | 281 + .../backuppolicies/id_backuppolicy.go | 139 + .../backuppolicies/id_backuppolicy_test.go | 327 + .../backuppolicies/id_backupvault.go | 130 + .../backuppolicies/id_backupvault_test.go | 282 + .../backuppolicies/method_createorupdate.go | 58 + .../backuppolicies/method_delete.go | 47 + .../2024-04-01/backuppolicies/method_get.go | 54 + .../2024-04-01/backuppolicies/method_list.go | 91 + .../model_absolutedeleteoption.go | 41 + .../model_adhocbasedtaggingcriteria.go | 8 + .../model_adhocbasedtriggercontext.go | 41 + .../backuppolicies/model_azurebackupparams.go | 41 + .../backuppolicies/model_azurebackuprule.go | 79 + .../model_azureretentionrule.go | 43 + .../backuppolicies/model_backupcriteria.go | 53 + .../backuppolicies/model_backupparameters.go | 53 + .../backuppolicies/model_backuppolicy.go | 77 + .../backuppolicies/model_backupschedule.go | 9 + .../backuppolicies/model_basebackuppolicy.go | 53 + .../model_basebackuppolicyresource.go | 48 + .../backuppolicies/model_basepolicyrule.go | 61 + .../model_copyonexpiryoption.go | 40 + .../backuppolicies/model_copyoption.go | 69 + .../backuppolicies/model_customcopyoption.go | 41 + .../backuppolicies/model_datastoreinfobase.go | 9 + .../2024-04-01/backuppolicies/model_day.go | 9 + .../backuppolicies/model_deleteoption.go | 53 + .../model_immediatecopyoption.go | 40 + .../backuppolicies/model_retentiontag.go | 10 + .../model_schedulebasedbackupcriteria.go | 46 + .../model_schedulebasedtriggercontext.go | 42 + .../backuppolicies/model_sourcelifecycle.go | 42 + .../backuppolicies/model_taggingcriteria.go | 53 + .../backuppolicies/model_targetcopysetting.go | 40 + .../backuppolicies/model_triggercontext.go | 61 + .../2024-04-01/backuppolicies/predicates.go | 27 + .../2024-04-01/backuppolicies/version.go | 12 + .../2024-04-01/backupvaults/README.md | 138 + .../2024-04-01/backupvaults/client.go | 26 + .../2024-04-01/backupvaults/constants.go | 653 ++ .../2024-04-01/backupvaults/id_backupvault.go | 130 + .../backupvaults/id_backupvault_test.go | 282 + .../backupvaults/id_providerlocation.go | 130 + .../backupvaults/id_providerlocation_test.go | 282 + .../method_checknameavailability.go | 59 + .../backupvaults/method_createorupdate.go | 103 + .../2024-04-01/backupvaults/method_delete.go | 71 + .../2024-04-01/backupvaults/method_get.go | 54 + .../backupvaults/method_getinresourcegroup.go | 92 + .../backupvaults/method_getinsubscription.go | 92 + .../2024-04-01/backupvaults/method_update.go | 103 + .../model_azuremonitoralertsettings.go | 8 + .../backupvaults/model_backupvault.go | 19 + .../backupvaults/model_backupvaultresource.go | 20 + .../model_checknameavailabilityrequest.go | 9 + .../model_checknameavailabilityresult.go | 10 + .../backupvaults/model_cmkkekidentity.go | 9 + .../model_cmkkeyvaultproperties.go | 8 + .../model_crossregionrestoresettings.go | 8 + .../model_crosssubscriptionrestoresettings.go | 8 + .../backupvaults/model_dppidentitydetails.go | 11 + .../backupvaults/model_encryptionsettings.go | 11 + .../backupvaults/model_featuresettings.go | 9 + .../model_immutabilitysettings.go | 8 + .../backupvaults/model_monitoringsettings.go | 8 + .../model_patchbackupvaultinput.go | 11 + .../model_patchresourcerequestinput.go | 10 + .../backupvaults/model_resourcemovedetails.go | 12 + .../backupvaults/model_securitysettings.go | 10 + .../backupvaults/model_softdeletesettings.go | 9 + .../backupvaults/model_storagesetting.go | 9 + .../model_userassignedidentity.go | 9 + .../2024-04-01/backupvaults/predicates.go | 37 + .../2024-04-01/backupvaults/version.go | 12 + .../dataprotection/2024-04-01/client.go | 145 + .../deletedbackupinstances/README.md | 65 + .../deletedbackupinstances/client.go | 26 + .../deletedbackupinstances/constants.go | 298 + .../deletedbackupinstances/id_backupvault.go | 130 + .../id_backupvault_test.go | 282 + .../id_deletedbackupinstance.go | 139 + .../id_deletedbackupinstance_test.go | 327 + .../deletedbackupinstances/method_get.go | 54 + .../deletedbackupinstances/method_list.go | 91 + .../deletedbackupinstances/method_undelete.go | 70 + .../model_authcredentials.go | 53 + .../model_azureoperationalstoreparameters.go | 42 + .../model_backupdatasourceparameters.go | 61 + .../model_baseresourceproperties.go | 53 + .../model_blobbackupdatasourceparameters.go | 41 + .../model_datasource.go | 52 + .../model_datasourceset.go | 52 + .../model_datastoreparameters.go | 53 + .../model_defaultresourceproperties.go | 40 + .../model_deletedbackupinstance.go | 64 + .../model_deletedbackupinstanceresource.go | 16 + .../model_deletioninfo.go | 11 + .../model_identitydetails.go | 9 + .../model_innererror.go | 10 + ...rnetesclusterbackupdatasourceparameters.go | 48 + .../model_namespacednameresource.go | 9 + .../model_policyinfo.go | 10 + .../model_policyparameters.go | 59 + .../model_protectionstatusdetails.go | 9 + .../model_secretstorebasedauthcredentials.go | 41 + .../model_secretstoreresource.go | 10 + .../model_userfacingerror.go | 16 + .../deletedbackupinstances/predicates.go | 27 + .../deletedbackupinstances/version.go | 12 + .../2024-04-01/dppfeaturesupport/README.md | 41 + .../2024-04-01/dppfeaturesupport/client.go | 26 + .../2024-04-01/dppfeaturesupport/constants.go | 104 + .../dppfeaturesupport/id_location.go | 121 + .../dppfeaturesupport/id_location_test.go | 237 + ...ethod_dataprotectioncheckfeaturesupport.go | 63 + .../model_featurevalidationrequest.go | 42 + .../model_featurevalidationrequestbase.go | 53 + .../model_featurevalidationresponse.go | 42 + .../model_featurevalidationresponsebase.go | 53 + .../model_supportedfeature.go | 10 + .../2024-04-01/dppfeaturesupport/version.go | 12 + .../2024-04-01/dppjob/README.md | 63 + .../2024-04-01/dppjob/client.go | 26 + .../2024-04-01/dppjob/id_providerlocation.go | 130 + .../dppjob/id_providerlocation_test.go | 282 + .../method_fetchcrossregionrestorejobget.go | 59 + .../method_fetchcrossregionrestorejobslist.go | 119 + .../2024-04-01/dppjob/model_azurebackupjob.go | 65 + .../dppjob/model_azurebackupjobresource.go | 16 + .../model_crossregionrestorejobrequest.go | 10 + .../model_crossregionrestorejobsrequest.go | 9 + .../2024-04-01/dppjob/model_innererror.go | 10 + .../dppjob/model_jobextendedinfo.go | 15 + .../2024-04-01/dppjob/model_jobsubtask.go | 12 + .../model_restorejobrecoverypointdetails.go | 27 + .../dppjob/model_userfacingerror.go | 16 + .../dppjob/model_userfacingwarningdetail.go | 9 + .../2024-04-01/dppjob/predicates.go | 27 + .../2024-04-01/dppjob/version.go | 12 + .../dppresourceguardproxies/README.md | 111 + .../dppresourceguardproxies/client.go | 26 + .../id_backupresourceguardproxy.go | 139 + .../id_backupresourceguardproxy_test.go | 327 + .../dppresourceguardproxies/id_backupvault.go | 130 + .../id_backupvault_test.go | 282 + ...hod_dppresourceguardproxycreateorupdate.go | 58 + .../method_dppresourceguardproxydelete.go | 47 + .../method_dppresourceguardproxyget.go | 54 + .../method_dppresourceguardproxylist.go | 91 + ...ethod_dppresourceguardproxyunlockdelete.go | 87 + .../model_resourceguardoperationdetail.go | 9 + .../model_resourceguardproxybase.go | 11 + .../model_resourceguardproxybaseresource.go | 16 + .../model_unlockdeleterequest.go | 9 + .../model_unlockdeleteresponse.go | 8 + .../dppresourceguardproxies/predicates.go | 27 + .../dppresourceguardproxies/version.go | 12 + .../fetchsecondaryrecoverypoints/README.md | 42 + .../fetchsecondaryrecoverypoints/client.go | 26 + .../fetchsecondaryrecoverypoints/constants.go | 101 + .../id_providerlocation.go | 130 + .../id_providerlocation_test.go | 282 + .../method_list.go | 119 + .../model_azurebackupdiscreterecoverypoint.go | 51 + .../model_azurebackuprecoverypoint.go | 53 + .../model_azurebackuprecoverypointresource.go | 48 + ...odel_fetchsecondaryrpsrequestparameters.go | 9 + .../model_recoverypointdatastoredetails.go | 58 + .../predicates.go | 27 + .../fetchsecondaryrecoverypoints/version.go | 12 + .../findrestorabletimeranges/README.md | 41 + .../findrestorabletimeranges/client.go | 26 + .../findrestorabletimeranges/constants.go | 54 + .../id_backupinstance.go | 139 + .../id_backupinstance_test.go | 327 + .../method_restorabletimerangesfind.go | 59 + ...rebackupfindrestorabletimerangesrequest.go | 10 + ...ebackupfindrestorabletimerangesresponse.go | 9 + ...indrestorabletimerangesresponseresource.go | 16 + .../model_restorabletimerange.go | 10 + .../findrestorabletimeranges/version.go | 12 + .../2024-04-01/recoverypoint/README.md | 53 + .../2024-04-01/recoverypoint/client.go | 26 + .../2024-04-01/recoverypoint/constants.go | 101 + .../recoverypoint/id_backupinstance.go | 139 + .../recoverypoint/id_backupinstance_test.go | 327 + .../recoverypoint/id_recoverypoint.go | 148 + .../recoverypoint/id_recoverypoint_test.go | 372 + .../2024-04-01/recoverypoint/method_get.go | 54 + .../2024-04-01/recoverypoint/method_list.go | 119 + .../model_azurebackupdiscreterecoverypoint.go | 51 + .../model_azurebackuprecoverypoint.go | 53 + .../model_azurebackuprecoverypointresource.go | 48 + .../model_recoverypointdatastoredetails.go | 58 + .../2024-04-01/recoverypoint/predicates.go | 27 + .../2024-04-01/recoverypoint/version.go | 12 + .../2024-04-01/resourceguards/README.md | 327 + .../2024-04-01/resourceguards/client.go | 26 + .../2024-04-01/resourceguards/constants.go | 60 + .../id_deleteprotecteditemrequest.go | 139 + .../id_deleteprotecteditemrequest_test.go | 327 + .../id_deleteresourceguardproxyrequest.go | 139 + ...id_deleteresourceguardproxyrequest_test.go | 327 + .../id_disablesoftdeleterequest.go | 139 + .../id_disablesoftdeleterequest_test.go | 327 + .../id_getbackupsecuritypinrequest.go | 139 + .../id_getbackupsecuritypinrequest_test.go | 327 + .../resourceguards/id_resourceguard.go | 130 + .../resourceguards/id_resourceguard_test.go | 282 + .../id_updateprotecteditemrequest.go | 139 + .../id_updateprotecteditemrequest_test.go | 327 + .../id_updateprotectionpolicyrequest.go | 139 + .../id_updateprotectionpolicyrequest_test.go | 327 + .../resourceguards/method_delete.go | 47 + .../2024-04-01/resourceguards/method_get.go | 54 + ...hod_getbackupsecuritypinrequestsobjects.go | 91 + ...tdefaultbackupsecuritypinrequestsobject.go | 54 + ...efaultdeleteprotecteditemrequestsobject.go | 54 + ...tdeleteresourceguardproxyrequestsobject.go | 54 + ...tdefaultdisablesoftdeleterequestsobject.go | 54 + ...efaultupdateprotecteditemrequestsobject.go | 54 + ...ultupdateprotectionpolicyrequestsobject.go | 54 + ...d_getdeleteprotecteditemrequestsobjects.go | 91 + ...deleteresourceguardproxyrequestsobjects.go | 91 + ...hod_getdisablesoftdeleterequestsobjects.go | 91 + .../method_getresourcesinresourcegroup.go | 92 + .../method_getresourcesinsubscription.go | 92 + ...d_getupdateprotecteditemrequestsobjects.go | 91 + ...etupdateprotectionpolicyrequestsobjects.go | 91 + .../2024-04-01/resourceguards/method_patch.go | 58 + .../2024-04-01/resourceguards/method_put.go | 59 + .../resourceguards/model_dppbaseresource.go | 10 + .../model_patchresourceguardinput.go | 8 + .../resourceguards/model_resourceguard.go | 12 + .../model_resourceguardoperation.go | 9 + .../model_resourceguardresource.go | 19 + .../2024-04-01/resourceguards/predicates.go | 60 + .../2024-04-01/resourceguards/version.go | 12 + .../eventhub/2024-01-01/client.go | 9 - .../eventhubs/model_eventhubproperties.go | 1 + .../2024-01-01/eventhubsclusters/constants.go | 59 - .../model_clusterproperties.go | 13 +- .../model_upgradepreferences.go | 9 - .../recoveryservices/2024-04-01/client.go | 100 + .../getprivatelinkresources/README.md | 36 + .../getprivatelinkresources/client.go | 26 + .../id_privatelinkresource.go | 139 + .../id_privatelinkresource_test.go | 327 + .../method_privatelinkresourcesget.go | 54 + .../model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 10 + .../getprivatelinkresources/version.go | 12 + .../listprivatelinkresources/README.md | 37 + .../listprivatelinkresources/client.go | 26 + .../listprivatelinkresources/id_vault.go} | 74 +- .../listprivatelinkresources/id_vault_test.go | 282 + .../method_privatelinkresourceslist.go | 91 + .../model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 10 + .../listprivatelinkresources/predicates.go | 27 + .../listprivatelinkresources/version.go | 12 + .../2024-04-01/recoveryservices/README.md | 62 + .../2024-04-01/recoveryservices/client.go | 26 + .../2024-04-01/recoveryservices/constants.go | 54 + .../recoveryservices/id_location.go | 121 + .../recoveryservices/id_location_test.go | 237 + .../recoveryservices/id_providerlocation.go | 130 + .../id_providerlocation_test.go | 282 + .../recoveryservices/method_capabilities.go | 59 + .../method_checknameavailability.go | 59 + .../model_capabilitiesproperties.go | 8 + .../model_capabilitiesresponse.go | 9 + .../model_capabilitiesresponseproperties.go | 8 + .../model_checknameavailabilityparameters.go | 9 + .../model_checknameavailabilityresult.go | 10 + .../recoveryservices/model_dnszone.go | 8 + .../recoveryservices/model_dnszoneresponse.go | 9 + .../model_resourcecapabilities.go | 9 + .../2024-04-01/recoveryservices/version.go | 12 + .../2024-04-01/registeredidentities/client.go | 26 + .../id_registeredidentity.go | 139 + .../id_registeredidentity_test.go | 327 + .../registeredidentities/method_delete.go | 46 + .../registeredidentities/version.go | 12 + .../2024-04-01/replicationusages/README.md | 36 + .../2024-04-01/replicationusages/client.go | 26 + .../2024-04-01/replicationusages/id_vault.go | 130 + .../replicationusages/id_vault_test.go | 282 + .../replicationusages/method_list.go | 55 + .../replicationusages/model_jobssummary.go | 10 + .../model_monitoringsummary.go | 13 + .../model_replicationusage.go | 13 + .../model_replicationusagelist.go | 8 + .../2024-04-01/replicationusages/version.go | 12 + .../2024-04-01/vaultcertificates/README.md | 41 + .../2024-04-01/vaultcertificates/client.go | 26 + .../2024-04-01/vaultcertificates/constants.go | 60 + .../vaultcertificates/id_certificate.go | 139 + .../vaultcertificates/id_certificate_test.go | 327 + .../vaultcertificates/method_create.go | 58 + .../model_certificaterequest.go | 8 + .../model_rawcertificatedata.go | 9 + .../model_resourcecertificateandaaddetails.go | 82 + .../model_resourcecertificateandacsdetails.go | 78 + .../model_resourcecertificatedetails.go | 61 + .../model_vaultcertificateresponse.go | 44 + .../2024-04-01/vaultcertificates/version.go | 12 + .../2024-04-01/vaultextendedinfo/README.md | 78 + .../2024-04-01/vaultextendedinfo/client.go | 26 + .../2024-04-01/vaultextendedinfo/id_vault.go | 130 + .../vaultextendedinfo/id_vault_test.go | 282 + .../method_createorupdate.go | 59 + .../vaultextendedinfo/method_get.go | 55 + .../vaultextendedinfo/method_update.go | 59 + .../model_vaultextendedinfo.go | 11 + .../model_vaultextendedinforesource.go | 12 + .../2024-04-01/vaultextendedinfo/version.go | 12 + .../2024-04-01/vaults/README.md | 117 + .../2024-04-01/vaults/client.go | 26 + .../2024-04-01/vaults/constants.go | 958 +++ .../2024-04-01/vaults/id_vault.go | 130 + .../2024-04-01/vaults/id_vault_test.go | 282 + .../vaults/method_createorupdate.go | 103 + .../2024-04-01/vaults/method_delete.go | 70 + .../2024-04-01/vaults/method_get.go | 54 + .../vaults/method_listbyresourcegroup.go | 92 + .../vaults/method_listbysubscriptionid.go | 92 + .../2024-04-01/vaults/method_update.go | 103 + .../vaults/model_azuremonitoralertsettings.go | 10 + .../vaults/model_classicalertsettings.go | 9 + .../2024-04-01/vaults/model_cmkkekidentity.go | 9 + .../vaults/model_cmkkeyvaultproperties.go | 8 + .../model_crosssubscriptionrestoresettings.go | 8 + .../vaults/model_immutabilitysettings.go | 8 + .../vaults/model_monitoringsettings.go | 9 + .../2024-04-01/vaults/model_patchvault.go | 20 + .../vaults/model_privateendpoint.go | 8 + .../vaults/model_privateendpointconnection.go | 11 + ...rivateendpointconnectionvaultproperties.go | 12 + ...model_privatelinkserviceconnectionstate.go | 10 + .../vaults/model_restoresettings.go | 8 + .../vaults/model_securitysettings.go | 10 + .../2024-04-01/vaults/model_sku.go | 12 + .../vaults/model_softdeletesettings.go | 10 + .../2024-04-01/vaults/model_upgradedetails.go | 58 + .../2024-04-01/vaults/model_vault.go | 22 + .../vaults/model_vaultproperties.go | 24 + .../vaults/model_vaultpropertiesencryption.go | 10 + .../model_vaultpropertiesmovedetails.go | 42 + ...model_vaultpropertiesredundancysettings.go | 9 + .../2024-04-01/vaults/predicates.go | 37 + .../2024-04-01/vaults/version.go | 12 + .../2024-04-01/vaultusages/README.md | 36 + .../2024-04-01/vaultusages/client.go | 26 + .../2024-04-01/vaultusages/constants.go | 63 + .../2024-04-01/vaultusages/id_vault.go | 130 + .../2024-04-01/vaultusages/id_vault_test.go | 282 + .../vaultusages/method_usageslistbyvaults.go | 55 + .../2024-04-01/vaultusages/model_nameinfo.go | 9 + .../vaultusages/model_vaultusage.go | 31 + .../vaultusages/model_vaultusagelist.go | 8 + .../2024-04-01/vaultusages/version.go | 12 + .../2024-04-01/backupengines/README.md | 53 + .../2024-04-01/backupengines/client.go | 18 + .../2024-04-01/backupengines/constants.go | 86 + .../backupengines/id_backupengine.go | 139 + .../backupengines/id_backupengine_test.go | 327 + .../2024-04-01/backupengines/id_vault.go | 130 + .../2024-04-01/backupengines/id_vault_test.go | 282 + .../backupengines/method_get_autorest.go | 97 + .../backupengines/method_list_autorest.go | 215 + .../model_azurebackupserverengine.go | 52 + .../backupengines/model_backupenginebase.go | 61 + .../model_backupenginebaseresource.go | 50 + .../model_backupengineextendedinfo.go | 33 + .../backupengines/model_dpmbackupengine.go | 52 + .../2024-04-01/backupengines/predicates.go | 37 + .../2024-04-01/backupengines/version.go | 12 + .../2024-04-01/backupjobs/README.md | 37 + .../2024-04-01/backupjobs/client.go | 18 + .../2024-04-01/backupjobs/constants.go | 223 + .../2024-04-01/backupjobs/id_vault.go | 130 + .../2024-04-01/backupjobs/id_vault_test.go | 282 + .../backupjobs/method_list_autorest.go | 215 + .../backupjobs/model_azureiaasvmerrorinfo.go | 11 + .../backupjobs/model_azureiaasvmjob.go | 81 + .../model_azureiaasvmjobextendedinfo.go | 13 + .../model_azureiaasvmjobtaskdetails.go | 45 + .../backupjobs/model_azureiaasvmjobv2.go | 80 + .../backupjobs/model_azurestorageerrorinfo.go | 10 + .../backupjobs/model_azurestoragejob.go | 81 + .../model_azurestoragejobextendedinfo.go | 10 + .../model_azurestoragejobtaskdetails.go | 9 + .../model_azureworkloaderrorinfo.go | 12 + .../backupjobs/model_azureworkloadjob.go | 79 + .../model_azureworkloadjobextendedinfo.go | 10 + .../model_azureworkloadjobtaskdetails.go | 9 + .../backupjobs/model_dpmerrorinfo.go | 9 + .../2024-04-01/backupjobs/model_dpmjob.go | 82 + .../backupjobs/model_dpmjobextendedinfo.go | 10 + .../backupjobs/model_dpmjobtaskdetails.go | 42 + .../2024-04-01/backupjobs/model_job.go | 101 + .../backupjobs/model_jobresource.go | 50 + .../backupjobs/model_maberrorinfo.go | 9 + .../2024-04-01/backupjobs/model_mabjob.go | 81 + .../backupjobs/model_mabjobextendedinfo.go | 10 + .../backupjobs/model_mabjobtaskdetails.go | 42 + .../2024-04-01/backupjobs/model_vaultjob.go | 78 + .../backupjobs/model_vaultjoberrorinfo.go | 10 + .../backupjobs/model_vaultjobextendedinfo.go | 8 + .../2024-04-01/backupjobs/predicates.go | 37 + .../2024-04-01/backupjobs/version.go | 12 + .../2024-04-01/backuppolicies/README.md | 37 + .../2024-04-01/backuppolicies/client.go | 18 + .../2024-04-01/backuppolicies/constants.go | 458 ++ .../2024-04-01/backuppolicies/id_vault.go | 130 + .../backuppolicies/id_vault_test.go | 282 + .../backuppolicies/method_list_autorest.go | 215 + .../model_azurefileshareprotectionpolicy.go | 85 + .../model_azureiaasvmprotectionpolicy.go | 91 + .../model_azuresqlprotectionpolicy.go | 70 + .../model_azurevmworkloadprotectionpolicy.go | 46 + .../model_dailyretentionformat.go | 8 + .../model_dailyretentionschedule.go | 9 + .../backuppolicies/model_dailyschedule.go | 8 + .../2024-04-01/backuppolicies/model_day.go | 9 + .../model_genericprotectionpolicy.go | 45 + .../backuppolicies/model_hourlyschedule.go | 28 + .../model_instantrpadditionaldetails.go | 9 + .../backuppolicies/model_logschedulepolicy.go | 41 + .../model_longtermretentionpolicy.go | 44 + .../model_longtermschedulepolicy.go | 40 + .../model_mabprotectionpolicy.go | 79 + .../model_monthlyretentionschedule.go | 12 + .../backuppolicies/model_protectionpolicy.go | 93 + .../model_protectionpolicyresource.go | 50 + .../backuppolicies/model_retentionduration.go | 9 + .../backuppolicies/model_retentionpolicy.go | 61 + .../backuppolicies/model_schedulepolicy.go | 77 + .../backuppolicies/model_settings.go | 10 + .../model_simpleretentionpolicy.go | 41 + .../model_simpleschedulepolicy.go | 45 + .../model_simpleschedulepolicyv2.go | 44 + .../model_snapshotbackupadditionaldetails.go | 10 + .../model_subprotectionpolicy.go | 53 + .../backuppolicies/model_tieringpolicy.go | 10 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../model_vaultretentionpolicy.go | 40 + .../model_weeklyretentionformat.go | 9 + .../model_weeklyretentionschedule.go | 10 + .../backuppolicies/model_weeklyschedule.go | 9 + .../model_yearlyretentionschedule.go | 13 + .../2024-04-01/backuppolicies/predicates.go | 37 + .../2024-04-01/backuppolicies/version.go | 12 + .../backupprotectableitems/README.md | 37 + .../backupprotectableitems/client.go | 18 + .../backupprotectableitems/constants.go | 105 + .../backupprotectableitems/id_vault.go | 130 + .../backupprotectableitems/id_vault_test.go | 282 + .../method_list_autorest.go | 215 + .../model_azurefileshareprotectableitem.go | 47 + ...zureiaasclassiccomputevmprotectableitem.go | 47 + ...model_azureiaascomputevmprotectableitem.go | 47 + .../model_azurevmworkloadprotectableitem.go | 53 + ...revmworkloadsapasesystemprotectableitem.go | 53 + ...mworkloadsaphanadatabaseprotectableitem.go | 53 + .../model_azurevmworkloadsaphanadbinstance.go | 53 + ...zurevmworkloadsaphanahsrprotectableitem.go | 53 + ...evmworkloadsaphanasystemprotectableitem.go | 53 + ...loadsqlavailabilitygroupprotectableitem.go | 54 + ...urevmworkloadsqldatabaseprotectableitem.go | 53 + ...urevmworkloadsqlinstanceprotectableitem.go | 53 + .../model_distributednodesinfo.go | 11 + .../model_errordetail.go | 10 + .../model_iaasvmprotectableitem.go | 47 + .../model_prebackupvalidation.go | 10 + .../model_workloadprotectableitem.go | 149 + .../model_workloadprotectableitemresource.go | 50 + .../backupprotectableitems/predicates.go | 37 + .../backupprotectableitems/version.go | 12 + .../2024-04-01/backupprotecteditems/README.md | 37 + .../2024-04-01/backupprotecteditems/client.go | 18 + .../backupprotecteditems/constants.go | 387 + .../backupprotecteditems/id_vault.go | 130 + .../backupprotecteditems/id_vault_test.go | 282 + .../method_list_autorest.go | 215 + .../model_azurefileshareprotecteditem.go | 92 + ...azurefileshareprotecteditemextendedinfo.go | 42 + ..._azureiaasclassiccomputevmprotecteditem.go | 97 + .../model_azureiaascomputevmprotecteditem.go | 97 + .../model_azureiaasvmprotecteditem.go | 97 + ...el_azureiaasvmprotecteditemextendedinfo.go | 67 + .../model_azuresqlprotecteditem.go | 88 + ...model_azuresqlprotecteditemextendedinfo.go | 28 + .../model_azurevmworkloadprotecteditem.go | 99 + ...zurevmworkloadprotecteditemextendedinfo.go | 68 + ...revmworkloadsapasedatabaseprotecteditem.go | 99 + ...evmworkloadsaphanadatabaseprotecteditem.go | 99 + ...mworkloadsaphanadbinstanceprotecteditem.go | 99 + ...azurevmworkloadsqldatabaseprotecteditem.go | 99 + .../model_diskexclusionproperties.go | 9 + .../model_distributednodesinfo.go | 11 + .../model_dpmprotecteditem.go | 89 + .../model_dpmprotecteditemextendedinfo.go | 75 + .../backupprotecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 91 + .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 92 + ..._mabfilefolderprotecteditemextendedinfo.go | 40 + .../model_protecteditem.go | 149 + .../model_protecteditemresource.go | 50 + .../model_resourcehealthdetails.go | 11 + .../backupprotecteditems/predicates.go | 37 + .../backupprotecteditems/version.go | 12 + .../backupprotectioncontainers/README.md | 37 + .../backupprotectioncontainers/client.go | 18 + .../backupprotectioncontainers/constants.go | 330 + .../backupprotectioncontainers/id_vault.go | 130 + .../id_vault_test.go | 282 + .../method_list_autorest.go | 215 + .../model_azurebackupservercontainer.go | 53 + ...odel_azureiaasclassiccomputevmcontainer.go | 48 + .../model_azureiaascomputevmcontainer.go | 48 + ...lagworkloadcontainerprotectioncontainer.go | 50 + .../model_azuresqlcontainer.go | 45 + .../model_azurestoragecontainer.go | 50 + ..._azurevmappcontainerprotectioncontainer.go | 50 + .../model_azureworkloadcontainer.go | 50 + ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 53 + .../model_dpmcontainerextendedinfo.go | 26 + .../model_errordetail.go | 10 + .../model_genericcontainer.go | 47 + .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 48 + .../model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 52 + .../model_mabcontainerextendedinfo.go | 30 + .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 141 + .../model_protectioncontainerresource.go | 50 + .../model_workloadinquirydetails.go | 10 + .../backupprotectioncontainers/predicates.go | 37 + .../backupprotectioncontainers/version.go | 12 + .../backupprotectionintent/README.md | 37 + .../backupprotectionintent/client.go | 18 + .../backupprotectionintent/constants.go | 178 + .../backupprotectionintent/id_vault.go | 130 + .../backupprotectionintent/id_vault_test.go | 282 + .../method_list_autorest.go | 215 + ...urerecoveryservicevaultprotectionintent.go | 45 + .../model_azureresourceprotectionintent.go | 46 + ...model_azureworkloadautoprotectionintent.go | 45 + ...reworkloadcontainerautoprotectionintent.go | 45 + ...el_azureworkloadsqlautoprotectionintent.go | 46 + .../model_protectionintent.go | 85 + .../model_protectionintentresource.go | 50 + .../backupprotectionintent/predicates.go | 37 + .../backupprotectionintent/version.go | 12 + .../backupresourceencryptionconfigs/README.md | 57 + .../backupresourceencryptionconfigs/client.go | 18 + .../constants.go | 114 + .../id_vault.go | 130 + .../id_vault_test.go | 282 + .../method_get_autorest.go | 69 + .../method_update_autorest.go | 68 + .../model_backupresourceencryptionconfig.go | 12 + ..._backupresourceencryptionconfigextended.go | 14 + ...esourceencryptionconfigextendedresource.go | 14 + ..._backupresourceencryptionconfigresource.go | 14 + .../version.go | 12 + .../README.md | 78 + .../client.go | 18 + .../constants.go | 136 + .../id_vault.go | 130 + .../id_vault_test.go | 282 + .../method_get_autorest.go | 69 + .../method_patch_autorest.go | 68 + .../method_update_autorest.go | 70 + .../model_backupresourceconfig.go | 13 + .../model_backupresourceconfigresource.go | 14 + .../version.go | 12 + .../backupresourcevaultconfigs/README.md | 78 + .../backupresourcevaultconfigs/client.go | 18 + .../backupresourcevaultconfigs/constants.go | 139 + .../backupresourcevaultconfigs/id_vault.go | 130 + .../id_vault_test.go | 282 + .../method_get_autorest.go | 69 + .../method_put_autorest.go | 99 + .../method_update_autorest.go | 99 + .../model_backupresourcevaultconfig.go | 15 + ...model_backupresourcevaultconfigresource.go | 14 + .../backupresourcevaultconfigs/version.go | 12 + .../2024-04-01/backups/README.md | 41 + .../2024-04-01/backups/client.go | 18 + .../2024-04-01/backups/constants.go | 52 + .../2024-04-01/backups/id_protecteditem.go | 157 + .../backups/id_protecteditem_test.go | 417 + .../backups/method_trigger_autorest.go | 68 + .../model_azurefilesharebackuprequest.go | 41 + .../model_azureworkloadbackuprequest.go | 43 + .../2024-04-01/backups/model_backuprequest.go | 69 + .../backups/model_backuprequestresource.go | 50 + .../backups/model_iaasvmbackuprequest.go | 41 + .../2024-04-01/backups/version.go | 12 + .../2024-04-01/backupstatus/README.md | 41 + .../2024-04-01/backupstatus/client.go | 18 + .../2024-04-01/backupstatus/constants.go | 169 + .../2024-04-01/backupstatus/id_location.go | 121 + .../backupstatus/id_location_test.go | 237 + .../backupstatus/method_get_autorest.go | 70 + .../backupstatus/model_backupstatusrequest.go | 10 + .../model_backupstatusresponse.go | 18 + .../2024-04-01/backupstatus/version.go | 12 + .../2024-04-01/backupusagesummaries/README.md | 36 + .../2024-04-01/backupusagesummaries/client.go | 18 + .../backupusagesummaries/constants.go | 46 + .../backupusagesummaries/id_vault.go | 130 + .../backupusagesummaries/id_vault_test.go | 282 + .../method_list_autorest.go | 98 + .../model_backupmanagementusage.go | 31 + .../model_backupmanagementusagelist.go | 8 + .../backupusagesummaries/model_nameinfo.go | 9 + .../backupusagesummaries/version.go | 12 + .../2024-04-01/backupworkloaditems/README.md | 37 + .../2024-04-01/backupworkloaditems/client.go | 18 + .../backupworkloaditems/constants.go | 74 + .../id_protectioncontainer.go | 148 + .../id_protectioncontainer_test.go | 372 + .../method_list_autorest.go | 215 + .../model_azurevmworkloaditem.go | 49 + ...urevmworkloadsapasedatabaseworkloaditem.go | 49 + ...azurevmworkloadsapasesystemworkloaditem.go | 49 + ...revmworkloadsaphanadatabaseworkloaditem.go | 49 + ...zurevmworkloadsaphanasystemworkloaditem.go | 49 + ..._azurevmworkloadsqldatabaseworkloaditem.go | 49 + ..._azurevmworkloadsqlinstanceworkloaditem.go | 50 + .../model_sqldatadirectory.go | 10 + .../backupworkloaditems/model_workloaditem.go | 101 + .../model_workloaditemresource.go | 50 + .../backupworkloaditems/predicates.go | 37 + .../2024-04-01/backupworkloaditems/version.go | 12 + .../2024-04-01/client.go | 239 + .../2024-04-01/datamove/README.md | 54 + .../2024-04-01/datamove/client.go | 18 + .../2024-04-01/datamove/constants.go | 37 + .../2024-04-01/datamove/id_vault.go | 130 + .../2024-04-01/datamove/id_vault_test.go | 282 + .../method_bmspreparedatamove_autorest.go | 79 + .../method_bmstriggerdatamove_autorest.go | 79 + .../datamove/model_preparedatamoverequest.go | 12 + .../datamove/model_triggerdatamoverequest.go | 13 + .../2024-04-01/datamove/version.go | 12 + .../2024-04-01/featuresupport/README.md | 41 + .../2024-04-01/featuresupport/client.go | 18 + .../2024-04-01/featuresupport/constants.go | 43 + .../2024-04-01/featuresupport/id_location.go | 121 + .../featuresupport/id_location_test.go | 237 + .../method_validate_autorest.go | 70 + ...el_azurebackupgoalfeaturesupportrequest.go | 40 + ...el_azurevmresourcefeaturesupportrequest.go | 42 + ...l_azurevmresourcefeaturesupportresponse.go | 8 + .../model_featuresupportrequest.go | 61 + .../2024-04-01/featuresupport/version.go | 12 + .../2024-04-01/fetchtieringcost/README.md | 37 + .../2024-04-01/fetchtieringcost/client.go | 18 + .../2024-04-01/fetchtieringcost/constants.go | 68 + .../2024-04-01/fetchtieringcost/id_vault.go | 130 + .../fetchtieringcost/id_vault_test.go | 282 + .../fetchtieringcost/method_post_autorest.go | 80 + ...tchtieringcostinfoforrehydrationrequest.go | 46 + .../model_fetchtieringcostinforequest.go | 77 + ...htieringcostsavingsinfoforpolicyrequest.go | 43 + ...gcostsavingsinfoforprotecteditemrequest.go | 44 + ...chtieringcostsavingsinfoforvaultrequest.go | 42 + .../fetchtieringcost/model_tieringcostinfo.go | 61 + .../model_tieringcostrehydrationinfo.go | 42 + .../model_tieringcostsavinginfo.go | 44 + .../2024-04-01/fetchtieringcost/version.go | 12 + .../itemlevelrecoveryconnections/README.md | 57 + .../itemlevelrecoveryconnections/client.go | 18 + .../id_recoverypoint.go | 166 + .../id_recoverypoint_test.go | 462 ++ .../method_provision_autorest.go | 68 + .../method_revoke_autorest.go | 67 + ...model_azurefileshareprovisionilrrequest.go | 42 + .../model_iaasvmilrregistrationrequest.go | 44 + .../model_ilrrequest.go | 61 + .../model_ilrrequestresource.go | 50 + .../itemlevelrecoveryconnections/version.go | 12 + .../2024-04-01/jobcancellations/client.go | 18 + .../jobcancellations/id_backupjob.go | 139 + .../jobcancellations/id_backupjob_test.go | 327 + .../method_trigger_autorest.go | 67 + .../2024-04-01/jobcancellations/version.go | 12 + .../2024-04-01/jobdetails/README.md | 36 + .../2024-04-01/jobdetails/client.go | 18 + .../2024-04-01/jobdetails/constants.go | 223 + .../2024-04-01/jobdetails/id_backupjob.go | 139 + .../jobdetails/id_backupjob_test.go | 327 + .../jobdetails/method_get_autorest.go | 68 + .../jobdetails/model_azureiaasvmerrorinfo.go | 11 + .../jobdetails/model_azureiaasvmjob.go | 81 + .../model_azureiaasvmjobextendedinfo.go | 13 + .../model_azureiaasvmjobtaskdetails.go | 45 + .../jobdetails/model_azureiaasvmjobv2.go | 80 + .../jobdetails/model_azurestorageerrorinfo.go | 10 + .../jobdetails/model_azurestoragejob.go | 81 + .../model_azurestoragejobextendedinfo.go | 10 + .../model_azurestoragejobtaskdetails.go | 9 + .../model_azureworkloaderrorinfo.go | 12 + .../jobdetails/model_azureworkloadjob.go | 79 + .../model_azureworkloadjobextendedinfo.go | 10 + .../model_azureworkloadjobtaskdetails.go | 9 + .../jobdetails/model_dpmerrorinfo.go | 9 + .../2024-04-01/jobdetails/model_dpmjob.go | 82 + .../jobdetails/model_dpmjobextendedinfo.go | 10 + .../jobdetails/model_dpmjobtaskdetails.go | 42 + .../2024-04-01/jobdetails/model_job.go | 101 + .../jobdetails/model_jobresource.go | 50 + .../jobdetails/model_maberrorinfo.go | 9 + .../2024-04-01/jobdetails/model_mabjob.go | 81 + .../jobdetails/model_mabjobextendedinfo.go | 10 + .../jobdetails/model_mabjobtaskdetails.go | 42 + .../2024-04-01/jobdetails/model_vaultjob.go | 78 + .../jobdetails/model_vaultjoberrorinfo.go | 10 + .../jobdetails/model_vaultjobextendedinfo.go | 8 + .../2024-04-01/jobdetails/version.go | 12 + .../2024-04-01/jobs/client.go | 18 + .../2024-04-01/jobs/id_vault.go | 130 + .../2024-04-01/jobs/id_vault_test.go | 282 + .../2024-04-01/jobs/method_export_autorest.go | 96 + .../2024-04-01/jobs/version.go | 12 + .../2024-04-01/operation/README.md | 41 + .../2024-04-01/operation/client.go | 18 + .../2024-04-01/operation/constants.go | 272 + .../2024-04-01/operation/id_vault.go | 130 + .../2024-04-01/operation/id_vault_test.go | 282 + .../operation/method_validate_autorest.go | 70 + .../model_azurefilesharerestorerequest.go | 47 + ..._azureworkloadpointintimerestorerequest.go | 51 + .../model_azureworkloadrestorerequest.go | 50 + ...orkloadsaphanapointintimerestorerequest.go | 51 + ...apointintimerestorewithrehydraterequest.go | 52 + ...odel_azureworkloadsaphanarestorerequest.go | 50 + ...kloadsaphanarestorewithrehydraterequest.go | 51 + ...ureworkloadsqlpointintimerestorerequest.go | 54 + ...lpointintimerestorewithrehydraterequest.go | 55 + .../model_azureworkloadsqlrestorerequest.go | 53 + ...eworkloadsqlrestorewithrehydraterequest.go | 54 + .../operation/model_encryptiondetails.go | 12 + .../2024-04-01/operation/model_errordetail.go | 10 + .../operation/model_extendedlocation.go | 9 + .../operation/model_iaasvmrestorerequest.go | 66 + ...del_iaasvmrestorewithrehydrationrequest.go | 67 + .../model_identitybasedrestoredetails.go | 9 + .../operation/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../operation/model_restorefilespecs.go | 10 + .../operation/model_restorerequest.go | 149 + .../operation/model_securedvmdetails.go | 8 + .../model_snapshotrestoreparameters.go | 9 + .../model_sqldatadirectorymapping.go | 11 + .../operation/model_targetafsrestoreinfo.go | 9 + .../model_targetdisknetworkaccesssettings.go | 9 + .../operation/model_targetrestoreinfo.go | 11 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + ...l_validateiaasvmrestoreoperationrequest.go | 60 + .../model_validateoperationrequest.go | 61 + .../model_validateoperationrequestresource.go | 40 + .../model_validateoperationresponse.go | 8 + .../model_validateoperationsresponse.go | 8 + .../model_validaterestoreoperationrequest.go | 60 + .../2024-04-01/operation/version.go | 12 + .../privateendpointconnection/README.md | 65 + .../privateendpointconnection/client.go | 18 + .../privateendpointconnection/constants.go | 105 + .../id_privateendpointconnection.go | 139 + .../id_privateendpointconnection_test.go | 327 + .../method_delete_autorest.go | 78 + .../method_get_autorest.go | 68 + .../method_put_autorest.go | 80 + .../model_privateendpoint.go | 8 + .../model_privateendpointconnection.go | 11 + ...model_privateendpointconnectionresource.go | 14 + ...model_privatelinkserviceconnectionstate.go | 10 + .../privateendpointconnection/version.go | 12 + .../protectablecontainers/README.md | 37 + .../protectablecontainers/client.go | 18 + .../protectablecontainers/constants.go | 131 + .../protectablecontainers/id_backupfabric.go | 139 + .../id_backupfabric_test.go | 327 + .../method_list_autorest.go | 215 + .../model_azurestorageprotectablecontainer.go | 44 + ...azurevmappcontainerprotectablecontainer.go | 44 + .../model_protectablecontainer.go | 61 + .../model_protectablecontainerresource.go | 50 + .../protectablecontainers/predicates.go | 37 + .../protectablecontainers/version.go | 12 + .../2024-04-01/protecteditems/README.md | 73 + .../2024-04-01/protecteditems/client.go | 18 + .../2024-04-01/protecteditems/constants.go | 387 + .../protecteditems/id_protecteditem.go | 157 + .../protecteditems/id_protecteditem_test.go | 417 + .../method_createorupdate_autorest.go | 98 + .../protecteditems/method_delete_autorest.go | 66 + .../protecteditems/method_get_autorest.go | 97 + .../model_azurefileshareprotecteditem.go | 92 + ...azurefileshareprotecteditemextendedinfo.go | 42 + ..._azureiaasclassiccomputevmprotecteditem.go | 97 + .../model_azureiaascomputevmprotecteditem.go | 97 + .../model_azureiaasvmprotecteditem.go | 97 + ...el_azureiaasvmprotecteditemextendedinfo.go | 67 + .../model_azuresqlprotecteditem.go | 88 + ...model_azuresqlprotecteditemextendedinfo.go | 28 + .../model_azurevmworkloadprotecteditem.go | 99 + ...zurevmworkloadprotecteditemextendedinfo.go | 68 + ...revmworkloadsapasedatabaseprotecteditem.go | 99 + ...evmworkloadsaphanadatabaseprotecteditem.go | 99 + ...mworkloadsaphanadbinstanceprotecteditem.go | 99 + ...azurevmworkloadsqldatabaseprotecteditem.go | 99 + .../model_diskexclusionproperties.go | 9 + .../model_distributednodesinfo.go | 11 + .../protecteditems/model_dpmprotecteditem.go | 89 + .../model_dpmprotecteditemextendedinfo.go | 75 + .../protecteditems/model_errordetail.go | 10 + .../model_extendedproperties.go | 9 + .../model_genericprotecteditem.go | 91 + .../model_kpiresourcehealthdetails.go | 9 + .../model_mabfilefolderprotecteditem.go | 92 + ..._mabfilefolderprotecteditemextendedinfo.go | 40 + .../protecteditems/model_protecteditem.go | 149 + .../model_protecteditemresource.go | 50 + .../model_resourcehealthdetails.go | 11 + .../2024-04-01/protecteditems/version.go | 12 + .../2024-04-01/protectioncontainers/README.md | 101 + .../2024-04-01/protectioncontainers/client.go | 18 + .../protectioncontainers/constants.go | 330 + .../protectioncontainers/id_backupfabric.go | 139 + .../id_backupfabric_test.go | 327 + .../id_protectioncontainer.go | 148 + .../id_protectioncontainer_test.go | 372 + .../method_get_autorest.go | 68 + .../method_inquire_autorest.go | 96 + .../method_refresh_autorest.go | 96 + .../method_register_autorest.go | 80 + .../method_unregister_autorest.go | 66 + .../model_azurebackupservercontainer.go | 53 + ...odel_azureiaasclassiccomputevmcontainer.go | 48 + .../model_azureiaascomputevmcontainer.go | 48 + ...lagworkloadcontainerprotectioncontainer.go | 50 + .../model_azuresqlcontainer.go | 45 + .../model_azurestoragecontainer.go | 50 + ..._azurevmappcontainerprotectioncontainer.go | 50 + .../model_azureworkloadcontainer.go | 50 + ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 53 + .../model_dpmcontainerextendedinfo.go | 26 + .../protectioncontainers/model_errordetail.go | 10 + .../model_genericcontainer.go | 47 + .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 48 + .../protectioncontainers/model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 52 + .../model_mabcontainerextendedinfo.go | 30 + .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 141 + .../model_protectioncontainerresource.go | 50 + .../model_workloadinquirydetails.go | 10 + .../protectioncontainers/version.go | 12 + .../2024-04-01/protectionintent/README.md | 94 + .../2024-04-01/protectionintent/client.go | 18 + .../2024-04-01/protectionintent/constants.go | 279 + .../id_backupprotectionintent.go | 148 + .../id_backupprotectionintent_test.go | 372 + .../protectionintent/id_location.go | 121 + .../protectionintent/id_location_test.go | 237 + .../method_createorupdate_autorest.go | 69 + .../method_delete_autorest.go | 66 + .../protectionintent/method_get_autorest.go | 68 + .../method_validate_autorest.go | 70 + ...urerecoveryservicevaultprotectionintent.go | 45 + .../model_azureresourceprotectionintent.go | 46 + ...model_azureworkloadautoprotectionintent.go | 45 + ...reworkloadcontainerautoprotectionintent.go | 45 + ...el_azureworkloadsqlautoprotectionintent.go | 46 + .../model_prevalidateenablebackuprequest.go | 11 + .../model_prevalidateenablebackupresponse.go | 13 + .../model_protectionintent.go | 85 + .../model_protectionintentresource.go | 50 + .../2024-04-01/protectionintent/version.go | 12 + .../2024-04-01/protectionpolicies/README.md | 69 + .../2024-04-01/protectionpolicies/client.go | 18 + .../protectionpolicies/constants.go | 458 ++ .../protectionpolicies/id_backuppolicy.go | 139 + .../id_backuppolicy_test.go | 327 + .../method_createorupdate_autorest.go | 98 + .../method_delete_autorest.go | 78 + .../protectionpolicies/method_get_autorest.go | 68 + .../model_azurefileshareprotectionpolicy.go | 85 + .../model_azureiaasvmprotectionpolicy.go | 91 + .../model_azuresqlprotectionpolicy.go | 70 + .../model_azurevmworkloadprotectionpolicy.go | 46 + .../model_dailyretentionformat.go | 8 + .../model_dailyretentionschedule.go | 9 + .../protectionpolicies/model_dailyschedule.go | 8 + .../protectionpolicies/model_day.go | 9 + .../model_genericprotectionpolicy.go | 45 + .../model_hourlyschedule.go | 28 + .../model_instantrpadditionaldetails.go | 9 + .../model_logschedulepolicy.go | 41 + .../model_longtermretentionpolicy.go | 44 + .../model_longtermschedulepolicy.go | 40 + .../model_mabprotectionpolicy.go | 79 + .../model_monthlyretentionschedule.go | 12 + .../model_protectionpolicy.go | 93 + .../model_protectionpolicyresource.go | 50 + .../model_retentionduration.go | 9 + .../model_retentionpolicy.go | 61 + .../model_schedulepolicy.go | 77 + .../protectionpolicies/model_settings.go | 10 + .../model_simpleretentionpolicy.go | 41 + .../model_simpleschedulepolicy.go | 45 + .../model_simpleschedulepolicyv2.go | 44 + .../model_snapshotbackupadditionaldetails.go | 10 + .../model_subprotectionpolicy.go | 53 + .../protectionpolicies/model_tieringpolicy.go | 10 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../model_vaultretentionpolicy.go | 40 + .../model_weeklyretentionformat.go | 9 + .../model_weeklyretentionschedule.go | 10 + .../model_weeklyschedule.go | 9 + .../model_yearlyretentionschedule.go | 13 + .../2024-04-01/protectionpolicies/version.go | 12 + .../2024-04-01/recoverypoint/README.md | 37 + .../2024-04-01/recoverypoint/client.go | 18 + .../2024-04-01/recoverypoint/constants.go | 40 + .../recoverypoint/id_recoverypoint.go | 166 + .../recoverypoint/id_recoverypoint_test.go | 462 ++ .../method_moverecoverypoint_autorest.go | 79 + .../model_moverpacrosstiersrequest.go | 10 + .../2024-04-01/recoverypoint/version.go | 12 + .../2024-04-01/recoverypoints/README.md | 53 + .../2024-04-01/recoverypoints/client.go | 18 + .../2024-04-01/recoverypoints/constants.go | 151 + .../recoverypoints/id_protecteditem.go | 157 + .../recoverypoints/id_protecteditem_test.go | 417 + .../recoverypoints/id_recoverypoint.go | 166 + .../recoverypoints/id_recoverypoint_test.go | 462 ++ .../recoverypoints/method_get_autorest.go | 68 + .../recoverypoints/method_list_autorest.go | 215 + .../model_azurefilesharerecoverypoint.go | 45 + ...l_azureworkloadpointintimerecoverypoint.go | 46 + .../model_azureworkloadrecoverypoint.go | 45 + ...workloadsaphanapointintimerecoverypoint.go | 46 + ...model_azureworkloadsaphanarecoverypoint.go | 45 + ...zureworkloadsqlpointintimerecoverypoint.go | 47 + .../model_azureworkloadsqlrecoverypoint.go | 46 + ...ureworkloadsqlrecoverypointextendedinfo.go | 27 + .../recoverypoints/model_bekdetails.go | 10 + .../recoverypoints/model_diskinformation.go | 9 + .../recoverypoints/model_extendedlocation.go | 9 + .../model_genericrecoverypoint.go | 45 + .../model_iaasvmrecoverypoint.go | 61 + .../recoverypoints/model_kekdetails.go | 10 + .../model_keyandsecretdetails.go | 10 + .../recoverypoints/model_pointintimerange.go | 39 + .../recoverypoints/model_recoverypoint.go | 117 + .../model_recoverypointdiskconfiguration.go | 11 + .../model_recoverypointmovereadinessinfo.go | 9 + .../model_recoverypointproperties.go | 10 + .../model_recoverypointresource.go | 50 + .../model_recoverypointtierinformationv2.go | 10 + .../recoverypoints/model_sqldatadirectory.go | 10 + .../2024-04-01/recoverypoints/predicates.go | 37 + .../2024-04-01/recoverypoints/version.go | 12 + .../README.md | 42 + .../client.go | 18 + .../constants.go | 151 + .../id_protecteditem.go | 157 + .../id_protecteditem_test.go | 417 + .../method_list_autorest.go | 187 + .../model_azurefilesharerecoverypoint.go | 45 + ...l_azureworkloadpointintimerecoverypoint.go | 46 + .../model_azureworkloadrecoverypoint.go | 45 + ...workloadsaphanapointintimerecoverypoint.go | 46 + ...model_azureworkloadsaphanarecoverypoint.go | 45 + ...zureworkloadsqlpointintimerecoverypoint.go | 47 + .../model_azureworkloadsqlrecoverypoint.go | 46 + ...ureworkloadsqlrecoverypointextendedinfo.go | 27 + .../model_bekdetails.go | 10 + .../model_diskinformation.go | 9 + .../model_extendedlocation.go | 9 + .../model_genericrecoverypoint.go | 45 + .../model_iaasvmrecoverypoint.go | 61 + .../model_kekdetails.go | 10 + .../model_keyandsecretdetails.go | 10 + ...recoverypointsrecommendedformoverequest.go | 9 + .../model_pointintimerange.go | 39 + .../model_recoverypoint.go | 117 + .../model_recoverypointdiskconfiguration.go | 11 + .../model_recoverypointmovereadinessinfo.go | 9 + .../model_recoverypointproperties.go | 10 + .../model_recoverypointresource.go | 50 + .../model_recoverypointtierinformationv2.go | 10 + .../model_sqldatadirectory.go | 10 + .../predicates.go | 37 + .../version.go | 12 + .../2024-04-01/resourceguardproxies/README.md | 37 + .../2024-04-01/resourceguardproxies/client.go | 18 + .../resourceguardproxies/id_vault.go | 130 + .../resourceguardproxies/id_vault_test.go | 282 + .../method_get_autorest.go | 186 + .../model_resourceguardoperationdetail.go | 9 + .../model_resourceguardproxybase.go | 11 + .../model_resourceguardproxybaseresource.go | 14 + .../resourceguardproxies/predicates.go | 37 + .../resourceguardproxies/version.go | 12 + .../2024-04-01/resourceguardproxy/README.md | 94 + .../2024-04-01/resourceguardproxy/client.go | 18 + .../id_backupresourceguardproxy.go | 139 + .../id_backupresourceguardproxy_test.go | 327 + .../method_delete_autorest.go | 66 + .../resourceguardproxy/method_get_autorest.go | 68 + .../resourceguardproxy/method_put_autorest.go | 69 + .../method_unlockdelete_autorest.go | 70 + .../model_resourceguardoperationdetail.go | 9 + .../model_resourceguardproxybase.go | 11 + .../model_resourceguardproxybaseresource.go | 14 + .../model_unlockdeleterequest.go | 9 + .../model_unlockdeleteresponse.go | 8 + .../2024-04-01/resourceguardproxy/version.go | 12 + .../2024-04-01/restores/README.md | 37 + .../2024-04-01/restores/client.go | 18 + .../2024-04-01/restores/constants.go | 272 + .../2024-04-01/restores/id_recoverypoint.go | 166 + .../restores/id_recoverypoint_test.go | 462 ++ .../restores/method_trigger_autorest.go | 108 + .../model_azurefilesharerestorerequest.go | 47 + ..._azureworkloadpointintimerestorerequest.go | 51 + .../model_azureworkloadrestorerequest.go | 50 + ...orkloadsaphanapointintimerestorerequest.go | 51 + ...apointintimerestorewithrehydraterequest.go | 52 + ...odel_azureworkloadsaphanarestorerequest.go | 50 + ...kloadsaphanarestorewithrehydraterequest.go | 51 + ...ureworkloadsqlpointintimerestorerequest.go | 54 + ...lpointintimerestorewithrehydraterequest.go | 55 + .../model_azureworkloadsqlrestorerequest.go | 53 + ...eworkloadsqlrestorewithrehydraterequest.go | 54 + .../restores/model_encryptiondetails.go | 12 + .../restores/model_extendedlocation.go | 9 + .../restores/model_iaasvmrestorerequest.go | 66 + ...del_iaasvmrestorewithrehydrationrequest.go | 67 + .../model_identitybasedrestoredetails.go | 9 + .../2024-04-01/restores/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../restores/model_restorefilespecs.go | 10 + .../restores/model_restorerequest.go | 149 + .../restores/model_restorerequestresource.go | 50 + .../restores/model_securedvmdetails.go | 8 + .../model_snapshotrestoreparameters.go | 9 + .../restores/model_sqldatadirectorymapping.go | 11 + .../restores/model_targetafsrestoreinfo.go | 9 + .../model_targetdisknetworkaccesssettings.go | 9 + .../restores/model_targetrestoreinfo.go | 11 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + .../2024-04-01/restores/version.go | 12 + .../2024-04-01/securitypins/README.md | 41 + .../2024-04-01/securitypins/client.go | 18 + .../2024-04-01/securitypins/id_vault.go | 130 + .../2024-04-01/securitypins/id_vault_test.go | 282 + .../securitypins/method_get_autorest.go | 99 + .../securitypins/model_securitypinbase.go | 8 + .../securitypins/model_tokeninformation.go | 10 + .../2024-04-01/securitypins/version.go | 12 + .../softdeletedcontainers/README.md | 37 + .../softdeletedcontainers/client.go | 18 + .../softdeletedcontainers/constants.go | 330 + .../softdeletedcontainers/id_vault.go | 130 + .../softdeletedcontainers/id_vault_test.go | 282 + ...eletedprotectioncontainerslist_autorest.go | 215 + .../model_azurebackupservercontainer.go | 53 + ...odel_azureiaasclassiccomputevmcontainer.go | 48 + .../model_azureiaascomputevmcontainer.go | 48 + ...lagworkloadcontainerprotectioncontainer.go | 50 + .../model_azuresqlcontainer.go | 45 + .../model_azurestoragecontainer.go | 50 + ..._azurevmappcontainerprotectioncontainer.go | 50 + .../model_azureworkloadcontainer.go | 50 + ...odel_azureworkloadcontainerextendedinfo.go | 10 + .../model_containeridentityinfo.go | 11 + .../model_distributednodesinfo.go | 11 + .../model_dpmcontainer.go | 53 + .../model_dpmcontainerextendedinfo.go | 26 + .../model_errordetail.go | 10 + .../model_genericcontainer.go | 47 + .../model_genericcontainerextendedinfo.go | 10 + .../model_iaasvmcontainer.go | 48 + .../model_inquiryinfo.go | 10 + .../model_inquiryvalidation.go | 11 + .../model_mabcontainer.go | 52 + .../model_mabcontainerextendedinfo.go | 30 + .../model_mabcontainerhealthdetails.go | 11 + .../model_protectioncontainer.go | 141 + .../model_protectioncontainerresource.go | 50 + .../model_workloadinquirydetails.go | 10 + .../softdeletedcontainers/predicates.go | 37 + .../softdeletedcontainers/version.go | 12 + .../2024-04-01/validateoperation/README.md | 37 + .../2024-04-01/validateoperation/client.go | 18 + .../2024-04-01/validateoperation/constants.go | 272 + .../2024-04-01/validateoperation/id_vault.go | 130 + .../validateoperation/id_vault_test.go | 282 + .../method_trigger_autorest.go | 79 + .../model_azurefilesharerestorerequest.go | 47 + ..._azureworkloadpointintimerestorerequest.go | 51 + .../model_azureworkloadrestorerequest.go | 50 + ...orkloadsaphanapointintimerestorerequest.go | 51 + ...apointintimerestorewithrehydraterequest.go | 52 + ...odel_azureworkloadsaphanarestorerequest.go | 50 + ...kloadsaphanarestorewithrehydraterequest.go | 51 + ...ureworkloadsqlpointintimerestorerequest.go | 54 + ...lpointintimerestorewithrehydraterequest.go | 55 + .../model_azureworkloadsqlrestorerequest.go | 53 + ...eworkloadsqlrestorewithrehydraterequest.go | 54 + .../model_encryptiondetails.go | 12 + .../model_extendedlocation.go | 9 + .../model_iaasvmrestorerequest.go | 66 + ...del_iaasvmrestorewithrehydrationrequest.go | 67 + .../model_identitybasedrestoredetails.go | 9 + .../validateoperation/model_identityinfo.go | 9 + .../model_recoverypointrehydrationinfo.go | 9 + .../model_restorefilespecs.go | 10 + .../validateoperation/model_restorerequest.go | 149 + .../model_securedvmdetails.go | 8 + .../model_snapshotrestoreparameters.go | 9 + .../model_sqldatadirectorymapping.go | 11 + .../model_targetafsrestoreinfo.go | 9 + .../model_targetdisknetworkaccesssettings.go | 9 + .../model_targetrestoreinfo.go | 11 + .../model_userassignedidentityproperties.go | 9 + ...odel_userassignedmanagedidentitydetails.go | 10 + ...l_validateiaasvmrestoreoperationrequest.go | 60 + .../model_validateoperationrequest.go | 61 + .../model_validateoperationrequestresource.go | 40 + .../model_validaterestoreoperationrequest.go | 60 + .../2024-04-01/validateoperation/version.go | 12 + .../2024-04-01/application/README.md | 144 + .../2024-04-01/application/client.go | 26 + .../2024-04-01/application/constants.go | 92 + .../2024-04-01/application/id_application.go | 139 + .../application/id_application_test.go | 327 + .../application/id_managedcluster.go | 130 + .../application/id_managedcluster_test.go | 282 + .../application/method_createorupdate.go | 75 + .../2024-04-01/application/method_delete.go | 71 + .../2024-04-01/application/method_get.go | 54 + .../2024-04-01/application/method_list.go | 91 + .../application/method_readupgrade.go | 69 + .../application/method_resumeupgrade.go | 73 + .../application/method_startrollback.go | 69 + .../2024-04-01/application/method_update.go | 58 + .../model_applicationhealthpolicy.go | 11 + .../application/model_applicationresource.go | 19 + .../model_applicationresourceproperties.go | 12 + .../model_applicationupdateparameters.go | 8 + .../model_applicationupgradepolicy.go | 14 + .../model_applicationuserassignedidentity.go | 9 + .../model_rollingupgrademonitoringpolicy.go | 13 + ...ntimeresumeapplicationupgradeparameters.go | 8 + .../model_servicetypehealthpolicy.go | 10 + .../application/model_systemdata.go | 43 + .../2024-04-01/application/predicates.go | 32 + .../2024-04-01/application/version.go | 12 + .../2024-04-01/applicationtype/README.md | 107 + .../2024-04-01/applicationtype/client.go | 26 + .../applicationtype/id_applicationtype.go | 139 + .../id_applicationtype_test.go | 327 + .../applicationtype/id_managedcluster.go | 130 + .../applicationtype/id_managedcluster_test.go | 282 + .../applicationtype/method_createorupdate.go | 58 + .../applicationtype/method_delete.go | 71 + .../2024-04-01/applicationtype/method_get.go | 54 + .../2024-04-01/applicationtype/method_list.go | 91 + .../applicationtype/method_update.go | 58 + .../model_applicationtyperesource.go | 14 + ...model_applicationtyperesourceproperties.go | 8 + .../model_applicationtypeupdateparameters.go | 8 + .../applicationtype/model_systemdata.go | 43 + .../2024-04-01/applicationtype/predicates.go | 32 + .../2024-04-01/applicationtype/version.go | 12 + .../applicationtypeversion/README.md | 103 + .../applicationtypeversion/client.go | 26 + .../id_applicationtype.go | 139 + .../id_applicationtype_test.go | 327 + .../applicationtypeversion/id_version.go | 148 + .../applicationtypeversion/id_version_test.go | 372 + .../method_createorupdate.go | 75 + .../applicationtypeversion/method_delete.go | 71 + .../applicationtypeversion/method_get.go | 54 + .../method_listbyapplicationtypes.go | 91 + .../applicationtypeversion/method_update.go | 58 + .../model_applicationtypeversionresource.go | 14 + ...pplicationtypeversionresourceproperties.go | 9 + ..._applicationtypeversionupdateparameters.go | 8 + .../model_systemdata.go | 43 + .../applicationtypeversion/predicates.go | 32 + .../applicationtypeversion/version.go | 12 + .../2024-04-01/client.go | 127 + .../managedapplymaintenancewindow/client.go | 26 + .../id_managedcluster.go | 130 + .../id_managedcluster_test.go | 282 + .../method_post.go | 47 + .../managedapplymaintenancewindow/version.go | 12 + .../managedazresiliencystatus/README.md | 36 + .../managedazresiliencystatus/client.go | 26 + .../id_managedcluster.go | 130 + .../id_managedcluster_test.go | 282 + .../managedazresiliencystatus/method_get.go | 55 + .../model_managedazresiliencystatus.go | 9 + .../model_resourceazstatus.go | 11 + .../managedazresiliencystatus/version.go | 12 + .../2024-04-01/managedcluster/README.md | 121 + .../2024-04-01/managedcluster/client.go | 26 + .../2024-04-01/managedcluster/constants.go | 644 ++ .../managedcluster/id_managedcluster.go | 130 + .../managedcluster/id_managedcluster_test.go | 282 + .../managedcluster/method_createorupdate.go | 75 + .../managedcluster/method_delete.go | 71 + .../2024-04-01/managedcluster/method_get.go | 54 + .../method_listbyresourcegroup.go | 92 + .../method_listbysubscription.go | 92 + .../managedcluster/method_update.go | 58 + ...el_applicationtypeversionscleanuppolicy.go | 8 + .../model_azureactivedirectory.go | 10 + .../managedcluster/model_clientcertificate.go | 11 + .../model_clusterhealthpolicy.go | 9 + .../model_clustermonitoringpolicy.go | 12 + .../model_clusterupgradedeltahealthpolicy.go | 10 + .../model_clusterupgradepolicy.go | 12 + .../2024-04-01/managedcluster/model_iptag.go | 9 + .../managedcluster/model_loadbalancingrule.go | 14 + .../managedcluster/model_managedcluster.go | 16 + .../model_managedclusterproperties.go | 46 + .../model_managedclusterupdateparameters.go | 8 + .../model_networksecurityrule.go | 21 + .../managedcluster/model_serviceendpoint.go | 9 + .../model_settingsparameterdescription.go | 9 + .../model_settingssectiondescription.go | 9 + .../2024-04-01/managedcluster/model_sku.go | 8 + .../2024-04-01/managedcluster/model_subnet.go | 12 + .../managedcluster/model_systemdata.go | 43 + .../2024-04-01/managedcluster/predicates.go | 37 + .../2024-04-01/managedcluster/version.go | 12 + .../managedclusterversion/README.md | 84 + .../managedclusterversion/client.go | 26 + .../managedclusterversion/constants.go | 48 + .../id_environmentmanagedclusterversion.go | 132 + ...d_environmentmanagedclusterversion_test.go | 312 + .../managedclusterversion/id_location.go | 121 + .../managedclusterversion/id_location_test.go | 237 + .../id_managedclusterversion.go | 130 + .../id_managedclusterversion_test.go | 282 + .../managedclusterversion/method_get.go | 54 + .../method_getbyenvironment.go | 54 + .../managedclusterversion/method_list.go | 55 + .../method_listbyenvironment.go | 55 + .../model_managedclustercodeversionresult.go | 11 + .../model_managedclusterversiondetails.go | 10 + .../managedclusterversion/version.go | 12 + .../managedmaintenancewindowstatus/README.md | 36 + .../managedmaintenancewindowstatus/client.go | 26 + .../id_managedcluster.go | 130 + .../id_managedcluster_test.go | 282 + .../method_get.go | 55 + .../model_managedmaintenancewindowstatus.go | 56 + .../managedmaintenancewindowstatus/version.go | 12 + .../2024-04-01/managedvmsizes/README.md | 53 + .../2024-04-01/managedvmsizes/client.go | 26 + .../2024-04-01/managedvmsizes/id_location.go | 121 + .../managedvmsizes/id_location_test.go | 237 + .../id_managedunsupportedvmsize.go | 130 + .../id_managedunsupportedvmsize_test.go | 282 + .../method_managedunsupportedvmsizesget.go | 54 + .../method_managedunsupportedvmsizeslist.go | 91 + .../managedvmsizes/model_managedvmsize.go | 11 + .../2024-04-01/managedvmsizes/model_vmsize.go | 8 + .../2024-04-01/managedvmsizes/predicates.go | 27 + .../2024-04-01/managedvmsizes/version.go | 12 + .../2024-04-01/nodetype/README.md | 171 + .../2024-04-01/nodetype/client.go | 26 + .../2024-04-01/nodetype/constants.go | 626 ++ .../2024-04-01/nodetype/id_managedcluster.go | 130 + .../nodetype/id_managedcluster_test.go | 282 + .../2024-04-01/nodetype/id_nodetype.go | 139 + .../2024-04-01/nodetype/id_nodetype_test.go | 327 + .../nodetype/method_createorupdate.go | 75 + .../2024-04-01/nodetype/method_delete.go | 71 + .../2024-04-01/nodetype/method_deletenode.go | 74 + .../2024-04-01/nodetype/method_get.go | 54 + .../nodetype/method_listbymanagedclusters.go | 91 + .../2024-04-01/nodetype/method_reimage.go | 74 + .../2024-04-01/nodetype/method_restart.go | 74 + .../2024-04-01/nodetype/method_skuslist.go | 91 + .../2024-04-01/nodetype/method_update.go | 58 + ...additionalnetworkinterfaceconfiguration.go | 11 + .../model_endpointrangedescription.go | 9 + .../nodetype/model_frontendconfiguration.go | 11 + .../nodetype/model_ipconfiguration.go | 14 + ...nfigurationpublicipaddressconfiguration.go | 10 + .../2024-04-01/nodetype/model_iptag.go | 9 + .../nodetype/model_networksecurityrule.go | 21 + .../2024-04-01/nodetype/model_nodetype.go | 14 + .../model_nodetypeactionparameters.go | 10 + .../nodetype/model_nodetypeavailablesku.go | 10 + .../nodetype/model_nodetypenatconfig.go | 10 + .../nodetype/model_nodetypeproperties.go | 61 + .../2024-04-01/nodetype/model_nodetypesku.go | 10 + .../nodetype/model_nodetypeskucapacity.go | 11 + .../nodetype/model_nodetypesupportedsku.go | 9 + .../model_nodetypeupdateparameters.go | 9 + .../2024-04-01/nodetype/model_subresource.go | 8 + .../2024-04-01/nodetype/model_systemdata.go | 43 + .../nodetype/model_vaultcertificate.go | 9 + .../nodetype/model_vaultsecretgroup.go | 9 + .../2024-04-01/nodetype/model_vmimageplan.go | 11 + .../2024-04-01/nodetype/model_vmssdatadisk.go | 11 + .../nodetype/model_vmssextension.go | 9 + .../nodetype/model_vmssextensionproperties.go | 18 + .../2024-04-01/nodetype/predicates.go | 40 + .../2024-04-01/nodetype/version.go | 12 + .../2024-04-01/service/README.md | 82 + .../2024-04-01/service/client.go | 26 + .../2024-04-01/service/constants.go | 403 + .../2024-04-01/service/id_application.go | 139 + .../2024-04-01/service/id_application_test.go | 327 + .../2024-04-01/service/id_service.go | 148 + .../2024-04-01/service/id_service_test.go | 372 + .../service/method_createorupdate.go | 75 + .../2024-04-01/service/method_delete.go | 71 + .../2024-04-01/service/method_get.go | 54 + .../service/method_listbyapplications.go | 91 + ...crementalnamedpartitionscalingmechanism.go | 43 + ...odel_averagepartitionloadscalingtrigger.go | 44 + .../model_averageserviceloadscalingtrigger.go | 45 + .../service/model_namedpartitionscheme.go | 41 + .../2024-04-01/service/model_partition.go | 69 + ...el_partitioninstancecountscalemechanism.go | 43 + .../service/model_scalingmechanism.go | 61 + .../2024-04-01/service/model_scalingpolicy.go | 41 + .../service/model_scalingtrigger.go | 61 + .../service/model_servicecorrelation.go | 9 + .../service/model_serviceloadmetric.go | 12 + ...del_serviceplacementinvaliddomainpolicy.go | 41 + ...placementnonpartiallyplaceservicepolicy.go | 40 + .../service/model_serviceplacementpolicy.go | 85 + ...rviceplacementpreferprimarydomainpolicy.go | 41 + ...el_serviceplacementrequireddomainpolicy.go | 41 + ...lacementrequiredomaindistributionpolicy.go | 41 + .../service/model_serviceresource.go | 50 + .../model_serviceresourceproperties.go | 61 + .../service/model_singletonpartitionscheme.go | 40 + .../model_statefulserviceproperties.go | 116 + .../model_statelessserviceproperties.go | 108 + .../2024-04-01/service/model_systemdata.go | 43 + .../model_uniformint64rangepartitionscheme.go | 43 + .../2024-04-01/service/predicates.go | 32 + .../2024-04-01/service/version.go | 12 + .../2024-04-01/services/README.md | 41 + .../2024-04-01/services/client.go | 26 + .../2024-04-01/services/constants.go | 403 + .../2024-04-01/services/id_service.go | 148 + .../2024-04-01/services/id_service_test.go | 372 + .../2024-04-01/services/method_update.go | 58 + ...crementalnamedpartitionscalingmechanism.go | 43 + ...odel_averagepartitionloadscalingtrigger.go | 44 + .../model_averageserviceloadscalingtrigger.go | 45 + .../services/model_namedpartitionscheme.go | 41 + .../2024-04-01/services/model_partition.go | 69 + ...el_partitioninstancecountscalemechanism.go | 43 + .../services/model_scalingmechanism.go | 61 + .../services/model_scalingpolicy.go | 41 + .../services/model_scalingtrigger.go | 61 + .../services/model_servicecorrelation.go | 9 + .../services/model_serviceloadmetric.go | 12 + ...del_serviceplacementinvaliddomainpolicy.go | 41 + ...placementnonpartiallyplaceservicepolicy.go | 40 + .../services/model_serviceplacementpolicy.go | 85 + ...rviceplacementpreferprimarydomainpolicy.go | 41 + ...el_serviceplacementrequireddomainpolicy.go | 41 + ...lacementrequiredomaindistributionpolicy.go | 41 + .../services/model_serviceresource.go | 50 + .../model_serviceresourceproperties.go | 61 + .../services/model_serviceupdateparameters.go | 8 + .../model_singletonpartitionscheme.go | 40 + .../model_statefulserviceproperties.go | 116 + .../model_statelessserviceproperties.go | 108 + .../2024-04-01/services/model_systemdata.go | 43 + .../model_uniformint64rangepartitionscheme.go | 43 + .../2024-04-01/services/version.go | 12 + .../availabilitygrouplisteners/README.md | 82 + .../availabilitygrouplisteners/client.go | 26 + .../availabilitygrouplisteners/constants.go | 177 + .../id_availabilitygrouplistener.go | 139 + .../id_availabilitygrouplistener_test.go | 327 + .../id_sqlvirtualmachinegroup.go | 130 + .../id_sqlvirtualmachinegroup_test.go | 282 + .../method_createorupdate.go | 75 + .../method_delete.go | 71 + .../availabilitygrouplisteners/method_get.go | 83 + .../method_listbygroup.go | 91 + .../model_agconfiguration.go | 8 + .../model_agreplica.go | 12 + .../model_availabilitygrouplistener.go | 16 + ...del_availabilitygrouplistenerproperties.go | 14 + .../model_loadbalancerconfiguration.go | 12 + .../model_multisubnetipconfiguration.go | 9 + .../model_privateipaddress.go | 9 + .../availabilitygrouplisteners/predicates.go | 27 + .../availabilitygrouplisteners/version.go | 12 + .../sqlvirtualmachine/2023-10-01/client.go | 55 + .../sqlvirtualmachinegroups/README.md | 117 + .../sqlvirtualmachinegroups/client.go | 26 + .../sqlvirtualmachinegroups/constants.go | 206 + .../id_sqlvirtualmachinegroup.go | 130 + .../id_sqlvirtualmachinegroup_test.go | 282 + .../method_createorupdate.go | 75 + .../sqlvirtualmachinegroups/method_delete.go | 71 + .../sqlvirtualmachinegroups/method_get.go | 54 + .../sqlvirtualmachinegroups/method_list.go | 92 + .../method_listbyresourcegroup.go | 92 + .../sqlvirtualmachinegroups/method_update.go | 74 + .../model_sqlvirtualmachinegroup.go | 18 + .../model_sqlvirtualmachinegroupproperties.go | 14 + .../model_sqlvirtualmachinegroupupdate.go | 8 + .../model_wsfcdomainprofile.go | 17 + .../sqlvirtualmachinegroups/predicates.go | 32 + .../sqlvirtualmachinegroups/version.go | 12 + .../2023-10-01/sqlvirtualmachines/README.md | 175 + .../2023-10-01/sqlvirtualmachines/client.go | 26 + .../sqlvirtualmachines/constants.go | 873 ++ .../id_sqlvirtualmachine.go | 130 + .../id_sqlvirtualmachine_test.go | 282 + .../id_sqlvirtualmachinegroup.go | 130 + .../id_sqlvirtualmachinegroup_test.go | 282 + .../method_createorupdate.go | 75 + .../sqlvirtualmachines/method_delete.go | 71 + .../method_fetchdcassessment.go | 73 + .../sqlvirtualmachines/method_get.go | 83 + .../sqlvirtualmachines/method_list.go | 92 + .../method_listbyresourcegroup.go | 92 + .../method_listbysqlvmgroup.go | 91 + .../sqlvirtualmachines/method_redeploy.go | 69 + .../method_startassessment.go | 69 + .../sqlvirtualmachines/method_update.go | 74 + .../model_aadauthenticationsettings.go | 8 + ..._additionalfeaturesserverconfigurations.go | 8 + .../model_assessmentsettings.go | 10 + .../model_autobackupsettings.go | 21 + .../model_autopatchingsettings.go | 12 + .../model_diskconfigassessmentrequest.go | 8 + .../model_keyvaultcredentialsettings.go | 12 + .../model_resourceidentity.go | 10 + .../sqlvirtualmachines/model_schedule.go | 12 + ..._serverconfigurationsmanagementsettings.go | 13 + .../model_sqlconnectivityupdatesettings.go | 11 + .../model_sqlinstancesettings.go | 14 + .../model_sqlstoragesettings.go | 10 + .../model_sqlstorageupdatesettings.go | 10 + .../model_sqltempdbsettings.go | 17 + .../model_sqlvirtualmachine.go | 19 + .../model_sqlvirtualmachineproperties.go | 28 + .../model_sqlvirtualmachineupdate.go | 8 + .../model_sqlworkloadtypeupdatesettings.go | 8 + .../model_storageconfigurationsettings.go | 14 + ...del_troubleshootingadditionalproperties.go | 8 + .../model_troubleshootingstatus.go | 55 + .../model_unhealthyreplicainfo.go | 8 + .../model_virtualmachineidentity.go | 9 + .../model_wsfcdomaincredentials.go | 10 + .../sqlvirtualmachines/predicates.go | 32 + .../2023-10-01/sqlvirtualmachines/version.go | 12 + .../sqlvirtualmachinetroubleshoot/README.md | 37 + .../sqlvirtualmachinetroubleshoot/client.go | 26 + .../constants.go | 48 + .../id_sqlvirtualmachine.go | 130 + .../id_sqlvirtualmachine_test.go | 282 + .../method_troubleshoot.go | 75 + .../model_sqlvmtroubleshooting.go | 42 + ...del_troubleshootingadditionalproperties.go | 8 + .../model_unhealthyreplicainfo.go | 8 + .../sqlvirtualmachinetroubleshoot/version.go | 12 + .../model_siteproperties.go | 1 + .../appserviceplans/model_siteproperties.go | 1 + .../webapps/model_siteproperties.go | 1 + .../appservicecertificateorders/README.md | 381 + .../appservicecertificateorders/client.go | 26 + .../appservicecertificateorders/constants.go | 355 + .../id_certificate.go | 139 + .../id_certificate_test.go | 327 + .../id_certificateorder.go | 130 + .../id_certificateorder_test.go | 282 + .../method_createorupdate.go | 75 + .../method_createorupdatecertificate.go | 75 + .../method_delete.go | 47 + .../method_deletecertificate.go | 47 + .../appservicecertificateorders/method_get.go | 54 + .../method_getcertificate.go | 54 + .../method_list.go | 92 + .../method_listbyresourcegroup.go | 92 + .../method_listcertificates.go | 91 + .../method_reissue.go | 51 + .../method_renew.go | 51 + .../method_resendemail.go} | 10 +- .../method_resendrequestemails.go | 51 + .../method_retrievecertificateactions.go | 55 + .../method_retrievecertificateemailhistory.go | 55 + .../method_retrievesiteseal.go | 59 + .../method_update.go | 58 + .../method_updatecertificate.go | 58 + .../method_validatepurchaseinformation.go | 52 + .../method_verifydomainownership.go | 47 + .../model_appservicecertificate.go | 10 + .../model_appservicecertificateorder.go | 14 + ...appservicecertificateorderpatchresource.go | 12 + ...certificateorderpatchresourceproperties.go | 69 + ...el_appservicecertificateorderproperties.go | 69 + ...odel_appservicecertificatepatchresource.go | 12 + .../model_appservicecertificateresource.go | 14 + .../model_certificatedetails.go | 46 + .../model_certificateemail.go | 27 + .../model_certificateorderaction.go | 27 + .../model_certificateordercontact.go | 11 + .../model_nameidentifier.go | 8 + .../model_reissuecertificateorderrequest.go | 12 + ...eissuecertificateorderrequestproperties.go | 11 + .../model_renewcertificateorderrequest.go | 12 + ..._renewcertificateorderrequestproperties.go | 10 + .../model_siteseal.go | 8 + .../model_sitesealrequest.go | 9 + .../appservicecertificateorders/predicates.go | 70 + .../appservicecertificateorders/version.go | 12 + .../appserviceenvironments/README.md | 833 ++ .../appserviceenvironments/client.go | 26 + .../appserviceenvironments/constants.go | 1621 ++++ .../id_defaultinstance.go | 141 + .../id_defaultinstance_test.go | 357 + .../id_hostingenvironmentdiagnostic.go | 139 + .../id_hostingenvironmentdiagnostic_test.go | 327 + ...ingenvironmentprivateendpointconnection.go | 139 + ...vironmentprivateendpointconnection_test.go | 327 + .../appserviceenvironments/id_workerpool.go | 139 + .../id_workerpool_test.go | 327 + .../id_workerpoolinstance.go | 148 + .../id_workerpoolinstance_test.go | 372 + ...pproveorrejectprivateendpointconnection.go | 75 + .../method_changevnet.go | 81 + .../method_createorupdate.go | 77 + .../method_createorupdatemultirolepool.go | 76 + .../method_createorupdateworkerpool.go | 75 + .../appserviceenvironments/method_delete.go | 99 + ...d_deleteasecustomdnssuffixconfiguration.go | 57 + .../method_deleteprivateendpointconnection.go | 72 + .../appserviceenvironments/method_get.go | 55 + ...thod_getasecustomdnssuffixconfiguration.go | 56 + .../method_getasev3networkingconfiguration.go | 56 + .../method_getdiagnosticsitem.go | 54 + ..._getinboundnetworkdependenciesendpoints.go | 92 + .../method_getmultirolepool.go | 56 + ...getoutboundnetworkdependenciesendpoints.go | 92 + .../method_getprivateendpointconnection.go | 54 + ...method_getprivateendpointconnectionlist.go | 92 + .../method_getprivatelinkresources.go | 56 + .../method_getvipinfo.go | 56 + .../method_getworkerpool.go | 54 + .../appserviceenvironments/method_list.go | 92 + .../method_listappserviceplans.go | 92 + .../method_listbyresourcegroup.go | 92 + .../method_listcapacities.go | 92 + .../method_listdiagnostics.go | 56 + .../method_listmultirolemetricdefinitions.go | 92 + ...tmultirolepoolinstancemetricdefinitions.go | 91 + .../method_listmultirolepools.go | 92 + .../method_listmultirolepoolskus.go | 92 + .../method_listmultiroleusages.go | 92 + .../method_listoperations.go | 56 + .../method_listusages.go | 120 + .../method_listwebapps.go | 120 + .../method_listwebworkermetricdefinitions.go | 91 + .../method_listwebworkerusages.go | 91 + ...listworkerpoolinstancemetricdefinitions.go | 91 + .../method_listworkerpools.go | 92 + .../method_listworkerpoolskus.go | 91 + .../appserviceenvironments/method_reboot.go | 48 + .../appserviceenvironments/method_resume.go | 77 + .../appserviceenvironments/method_suspend.go | 77 + ...method_testupgradeavailablenotification.go | 48 + .../appserviceenvironments/method_update.go | 61 + ...d_updateasecustomdnssuffixconfiguration.go | 60 + ...method_updateasenetworkingconfiguration.go | 60 + .../method_updatemultirolepool.go | 61 + .../method_updateworkerpool.go | 59 + .../appserviceenvironments/method_upgrade.go | 70 + .../model_addressresponse.go | 12 + .../model_addressresponseproperties.go | 11 + .../model_apidefinitioninfo.go | 8 + .../model_apimanagementconfig.go | 8 + .../model_appserviceenvironment.go | 27 + ...odel_appserviceenvironmentpatchresource.go | 12 + .../model_appserviceenvironmentresource.go | 14 + .../model_appserviceplan.go | 16 + .../model_appserviceplanproperties.go | 60 + .../model_armidwrapper.go | 8 + .../model_asev3networkingconfiguration.go | 12 + ..._asev3networkingconfigurationproperties.go | 15 + .../model_autohealactions.go | 10 + .../model_autohealcustomaction.go | 9 + .../model_autohealrules.go | 9 + .../model_autohealtriggers.go | 13 + .../model_azurestorageinfovalue.go | 14 + .../model_capability.go | 10 + .../model_cloninginfo.go | 18 + .../model_connstringinfo.go | 10 + .../model_corssettings.go | 9 + .../model_csmusagequota.go | 30 + .../model_customdnssuffixconfiguration.go | 12 + ..._customdnssuffixconfigurationproperties.go | 12 + .../model_daprconfig.go | 14 + .../model_endpointdependency.go | 9 + .../model_endpointdetail.go | 11 + .../model_errorentity.go | 15 + .../model_experiments.go | 8 + .../model_extendedlocation.go | 9 + .../model_functionappconfig.go | 10 + .../model_functionsalwaysreadyconfig.go | 9 + .../model_functionsdeployment.go | 8 + .../model_functionsdeploymentstorage.go | 10 + ...unctionsdeploymentstorageauthentication.go | 10 + .../model_functionsruntime.go | 9 + .../model_functionsscaleandconcurrency.go | 11 + ...el_functionsscaleandconcurrencytriggers.go | 8 + ...unctionsscaleandconcurrencytriggershttp.go | 8 + .../model_handlermapping.go | 10 + .../model_hostingenvironmentdiagnostics.go | 9 + .../model_hostingenvironmentprofile.go | 10 + .../model_hostnamesslstate.go | 13 + .../model_inboundenvironmentendpoint.go | 10 + .../model_ipsecurityrestriction.go | 18 + .../model_kubeenvironmentprofile.go | 10 + .../model_localizablestring.go | 9 + .../model_namevaluepair.go | 9 + .../appserviceenvironments/model_operation.go | 57 + .../model_outboundenvironmentendpoint.go | 9 + .../model_privatelinkconnectionstate.go | 10 + .../model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 10 + .../model_privatelinkresourceswrapper.go | 8 + .../model_pushsettings.go | 12 + .../model_pushsettingsproperties.go | 11 + .../model_rampuprule.go | 15 + ...oteprivateendpointconnectionarmresource.go | 12 + ...endpointconnectionarmresourceproperties.go | 11 + .../model_requestsbasedtrigger.go | 9 + .../model_resourceconfig.go | 9 + .../model_resourcemetricavailability.go | 9 + .../model_resourcemetricdefinition.go | 12 + ...odel_resourcemetricdefinitionproperties.go | 12 + .../appserviceenvironments/model_site.go | 20 + .../model_siteconfig.go | 97 + .../model_sitednsconfig.go | 13 + .../model_sitelimits.go | 10 + .../model_sitemachinekey.go | 11 + .../model_siteproperties.go | 89 + .../model_skucapacity.go | 12 + .../model_skudescription.go | 15 + .../appserviceenvironments/model_skuinfo.go | 10 + .../model_slotswapstatus.go | 28 + .../model_slowrequestsbasedtrigger.go | 11 + .../model_stampcapacity.go | 18 + .../model_statuscodesbasedtrigger.go | 13 + .../model_statuscodesrangebasedtrigger.go | 11 + .../appserviceenvironments/model_usage.go | 12 + .../model_usageproperties.go | 33 + .../model_virtualapplication.go | 11 + .../model_virtualdirectory.go | 9 + .../model_virtualipmapping.go | 12 + .../model_virtualnetworkprofile.go | 11 + .../model_workerpool.go | 12 + .../model_workerpoolresource.go | 13 + .../appserviceenvironments/predicates.go | 335 + .../appserviceenvironments/version.go | 12 + .../web/2023-12-01/appserviceplans/README.md | 480 ++ .../web/2023-12-01/appserviceplans/client.go | 26 + .../2023-12-01/appserviceplans/constants.go | 1271 +++ .../id_hybridconnectionnamespacerelay.go | 148 + .../id_hybridconnectionnamespacerelay_test.go | 372 + .../2023-12-01/appserviceplans/id_route.go | 148 + .../appserviceplans/id_route_test.go | 372 + .../id_serverfarmvirtualnetworkconnection.go | 139 + ...serverfarmvirtualnetworkconnection_test.go | 327 + .../id_virtualnetworkconnectiongateway.go | 148 + ...id_virtualnetworkconnectiongateway_test.go | 372 + .../2023-12-01/appserviceplans/id_worker.go | 139 + .../appserviceplans/id_worker_test.go | 327 + .../appserviceplans/method_createorupdate.go | 76 + .../method_createorupdatevnetroute.go | 58 + .../appserviceplans/method_delete.go | 48 + .../method_deletehybridconnection.go | 47 + .../appserviceplans/method_deletevnetroute.go | 46 + .../2023-12-01/appserviceplans/method_get.go | 55 + .../method_gethybridconnection.go | 54 + .../method_gethybridconnectionplanlimit.go | 56 + .../appserviceplans/method_getrouteforvnet.go | 54 + .../method_getserverfarmskus.go | 56 + .../method_getvnetfromserverfarm.go | 54 + .../appserviceplans/method_getvnetgateway.go | 54 + .../2023-12-01/appserviceplans/method_list.go | 120 + .../method_listbyresourcegroup.go | 92 + .../method_listcapabilities.go | 56 + .../method_listhybridconnectionkeys.go | 55 + .../method_listhybridconnections.go | 92 + .../method_listroutesforvnet.go | 55 + .../appserviceplans/method_listusages.go | 120 + .../appserviceplans/method_listvnets.go | 56 + .../appserviceplans/method_listwebapps.go | 124 + .../method_listwebappsbyhybridconnection.go | 84 + .../appserviceplans/method_rebootworker.go | 47 + .../appserviceplans/method_restartwebapps.go | 76 + .../appserviceplans/method_update.go | 60 + .../method_updatevnetgateway.go | 58 + .../appserviceplans/method_updatevnetroute.go | 58 + .../model_apidefinitioninfo.go | 8 + .../model_apimanagementconfig.go | 8 + .../appserviceplans/model_appserviceplan.go | 16 + .../model_appserviceplanpatchresource.go | 12 + ...l_appserviceplanpatchresourceproperties.go | 60 + .../model_appserviceplanproperties.go | 60 + .../appserviceplans/model_autohealactions.go | 10 + .../model_autohealcustomaction.go | 9 + .../appserviceplans/model_autohealrules.go | 9 + .../appserviceplans/model_autohealtriggers.go | 13 + .../model_azurestorageinfovalue.go | 14 + .../appserviceplans/model_capability.go | 10 + .../appserviceplans/model_cloninginfo.go | 18 + .../appserviceplans/model_connstringinfo.go | 10 + .../appserviceplans/model_corssettings.go | 9 + .../appserviceplans/model_csmusagequota.go | 30 + .../appserviceplans/model_daprconfig.go | 14 + .../appserviceplans/model_experiments.go | 8 + .../appserviceplans/model_extendedlocation.go | 9 + .../model_functionappconfig.go | 10 + .../model_functionsalwaysreadyconfig.go | 9 + .../model_functionsdeployment.go | 8 + .../model_functionsdeploymentstorage.go | 10 + ...unctionsdeploymentstorageauthentication.go | 10 + .../appserviceplans/model_functionsruntime.go | 9 + .../model_functionsscaleandconcurrency.go | 11 + ...el_functionsscaleandconcurrencytriggers.go | 8 + ...unctionsscaleandconcurrencytriggershttp.go | 8 + .../appserviceplans/model_handlermapping.go | 10 + .../model_hostingenvironmentprofile.go | 10 + .../appserviceplans/model_hostnamesslstate.go | 13 + .../appserviceplans/model_hybridconnection.go | 12 + .../model_hybridconnectionkey.go | 12 + .../model_hybridconnectionkeyproperties.go | 9 + .../model_hybridconnectionlimits.go | 12 + .../model_hybridconnectionlimitsproperties.go | 9 + .../model_hybridconnectionproperties.go | 15 + .../model_ipsecurityrestriction.go | 18 + .../model_kubeenvironmentprofile.go | 10 + .../model_localizablestring.go | 9 + .../appserviceplans/model_namevaluepair.go | 9 + .../appserviceplans/model_pushsettings.go | 12 + .../model_pushsettingsproperties.go | 11 + .../appserviceplans/model_rampuprule.go | 15 + .../model_requestsbasedtrigger.go | 9 + .../appserviceplans/model_resourceconfig.go | 9 + .../2023-12-01/appserviceplans/model_site.go | 20 + .../appserviceplans/model_siteconfig.go | 97 + .../appserviceplans/model_sitednsconfig.go | 13 + .../appserviceplans/model_sitelimits.go | 10 + .../appserviceplans/model_sitemachinekey.go | 11 + .../appserviceplans/model_siteproperties.go | 89 + .../appserviceplans/model_skucapacity.go | 12 + .../appserviceplans/model_skudescription.go | 15 + .../appserviceplans/model_slotswapstatus.go | 28 + .../model_slowrequestsbasedtrigger.go | 11 + .../model_statuscodesbasedtrigger.go | 13 + .../model_statuscodesrangebasedtrigger.go | 11 + .../model_virtualapplication.go | 11 + .../appserviceplans/model_virtualdirectory.go | 9 + .../appserviceplans/model_vnetgateway.go | 12 + .../model_vnetgatewayproperties.go | 9 + .../appserviceplans/model_vnetinfo.go | 14 + .../appserviceplans/model_vnetinforesource.go | 12 + .../appserviceplans/model_vnetroute.go | 12 + .../model_vnetrouteproperties.go | 10 + .../2023-12-01/appserviceplans/predicates.go | 126 + .../web/2023-12-01/appserviceplans/version.go | 12 + .../certificateordersdiagnostics/README.md | 53 + .../certificateordersdiagnostics/client.go | 26 + .../certificateordersdiagnostics/constants.go | 214 + .../id_certificateorder.go | 130 + .../id_certificateorder_test.go | 282 + .../id_detector.go | 139 + .../id_detector_test.go | 327 + ...servicecertificateorderdetectorresponse.go | 91 + ...servicecertificateorderdetectorresponse.go | 91 + .../model_dataprovidermetadata.go | 9 + .../model_datatableresponsecolumn.go | 10 + .../model_datatableresponseobject.go | 10 + .../model_detectorinfo.go | 16 + .../model_detectorresponse.go | 12 + .../model_detectorresponseproperties.go | 12 + .../model_diagnosticdata.go | 9 + .../model_keyvaluepairstringobject.go | 9 + .../model_queryutterancesresult.go | 9 + .../model_queryutterancesresults.go | 9 + .../model_rendering.go | 10 + .../model_sampleutterance.go | 10 + .../model_status.go | 9 + .../model_supporttopic.go | 9 + .../predicates.go | 32 + .../certificateordersdiagnostics/version.go | 12 + .../web/2023-12-01/certificates/README.md | 129 + .../web/2023-12-01/certificates/client.go | 26 + .../web/2023-12-01/certificates/constants.go | 78 + .../2023-12-01/certificates/id_certificate.go | 130 + .../certificates/id_certificate_test.go | 282 + .../certificates/method_createorupdate.go | 58 + .../2023-12-01/certificates/method_delete.go | 47 + .../web/2023-12-01/certificates/method_get.go | 54 + .../2023-12-01/certificates/method_list.go | 120 + .../method_listbyresourcegroup.go | 92 + .../2023-12-01/certificates/method_update.go | 58 + .../certificates/model_certificate.go | 14 + .../model_certificatepatchresource.go | 12 + ...odel_certificatepatchresourceproperties.go | 58 + .../model_certificateproperties.go | 58 + .../model_hostingenvironmentprofile.go | 10 + .../web/2023-12-01/certificates/predicates.go | 37 + .../web/2023-12-01/certificates/version.go | 12 + resource-manager/web/2023-12-01/client.go | 244 + .../web/2023-12-01/containerapps/README.md | 116 + .../web/2023-12-01/containerapps/client.go | 26 + .../web/2023-12-01/containerapps/constants.go | 142 + .../containerapps/id_containerapp.go | 121 + .../containerapps/id_containerapp_test.go | 237 + .../containerapps/id_providercontainerapp.go | 130 + .../id_providercontainerapp_test.go | 282 + .../containerapps/method_createorupdate.go | 75 + .../2023-12-01/containerapps/method_delete.go | 71 + .../2023-12-01/containerapps/method_get.go | 54 + .../method_listbyresourcegroup.go | 92 + .../method_listbysubscription.go | 92 + .../containerapps/method_listsecrets.go | 55 + .../containerapps/model_configuration.go | 11 + .../containerapps/model_container.go | 13 + .../containerapps/model_containerapp.go | 14 + .../model_containerappproperties.go | 13 + .../containerapps/model_containerappsecret.go | 9 + .../containerapps/model_containerresources.go | 9 + .../containerapps/model_customscalerule.go | 10 + .../2023-12-01/containerapps/model_dapr.go | 11 + .../containerapps/model_daprcomponent.go | 11 + .../containerapps/model_daprmetadata.go | 10 + .../containerapps/model_environmentvar.go | 10 + .../containerapps/model_httpscalerule.go | 9 + .../2023-12-01/containerapps/model_ingress.go | 13 + .../containerapps/model_queuescalerule.go | 10 + .../model_registrycredentials.go | 10 + .../2023-12-01/containerapps/model_scale.go | 10 + .../containerapps/model_scalerule.go | 11 + .../containerapps/model_scaleruleauth.go | 9 + .../2023-12-01/containerapps/model_secret.go | 9 + .../containerapps/model_secretscollection.go | 8 + .../containerapps/model_template.go | 11 + .../containerapps/model_trafficweight.go | 10 + .../2023-12-01/containerapps/predicates.go | 37 + .../web/2023-12-01/containerapps/version.go | 12 + .../containerappsrevisions/README.md | 101 + .../containerappsrevisions/client.go | 26 + .../containerappsrevisions/constants.go | 104 + .../id_providercontainerapp.go | 130 + .../id_providercontainerapp_test.go | 282 + .../containerappsrevisions/id_revision.go | 139 + .../id_revision_test.go | 327 + .../method_activaterevision.go | 47 + .../method_deactivaterevision.go | 47 + .../method_getrevision.go | 54 + .../method_listrevisions.go | 91 + .../method_restartrevision.go | 47 + .../containerappsrevisions/model_container.go | 13 + .../model_containerresources.go | 9 + .../model_customscalerule.go | 10 + .../containerappsrevisions/model_dapr.go | 11 + .../model_daprcomponent.go | 11 + .../model_daprmetadata.go | 10 + .../model_environmentvar.go | 10 + .../model_httpscalerule.go | 9 + .../model_queuescalerule.go | 10 + .../containerappsrevisions/model_revision.go | 14 + .../model_revisionproperties.go | 34 + .../containerappsrevisions/model_scale.go | 10 + .../containerappsrevisions/model_scalerule.go | 11 + .../model_scaleruleauth.go | 9 + .../containerappsrevisions/model_template.go | 11 + .../containerappsrevisions/predicates.go | 37 + .../containerappsrevisions/version.go | 12 + .../web/2023-12-01/deletedwebapps/README.md | 71 + .../web/2023-12-01/deletedwebapps/client.go | 26 + .../deletedwebapps/id_locationdeletedsite.go | 130 + .../id_locationdeletedsite_test.go | 282 + .../deletedwebapps/id_providerlocation.go | 121 + .../id_providerlocation_test.go | 237 + .../method_getdeletedwebappbylocation.go | 54 + .../2023-12-01/deletedwebapps/method_list.go | 92 + .../deletedwebapps/method_listbylocation.go | 91 + .../deletedwebapps/model_deletedsite.go | 12 + .../model_deletedsiteproperties.go | 15 + .../2023-12-01/deletedwebapps/predicates.go | 32 + .../web/2023-12-01/deletedwebapps/version.go | 12 + .../web/2023-12-01/diagnostics/README.md | 382 + .../web/2023-12-01/diagnostics/client.go | 26 + .../web/2023-12-01/diagnostics/constants.go | 317 + .../web/2023-12-01/diagnostics/id_analysis.go | 148 + .../diagnostics/id_analysis_test.go | 372 + .../web/2023-12-01/diagnostics/id_detector.go | 139 + .../diagnostics/id_detector_test.go | 327 + .../2023-12-01/diagnostics/id_diagnostic.go | 139 + .../diagnostics/id_diagnostic_test.go | 327 + .../diagnostics/id_diagnosticanalysis.go | 157 + .../diagnostics/id_diagnosticanalysis_test.go | 417 + .../diagnostics/id_diagnosticdetector.go | 148 + .../diagnostics/id_diagnosticdetector_test.go | 372 + .../id_hostingenvironmentdetector.go | 139 + .../id_hostingenvironmentdetector_test.go | 327 + .../web/2023-12-01/diagnostics/id_slot.go | 139 + .../2023-12-01/diagnostics/id_slot_test.go | 327 + .../2023-12-01/diagnostics/id_slotdetector.go | 148 + .../diagnostics/id_slotdetector_test.go | 372 + .../diagnostics/id_slotdiagnostic.go | 148 + .../diagnostics/id_slotdiagnostic_test.go | 372 + .../diagnostics/id_slotdiagnosticdetector.go | 157 + .../id_slotdiagnosticdetector_test.go | 417 + .../diagnostics/method_executesiteanalysis.go | 91 + .../method_executesiteanalysisslot.go | 91 + .../diagnostics/method_executesitedetector.go | 91 + .../method_executesitedetectorslot.go | 91 + ...d_gethostingenvironmentdetectorresponse.go | 91 + .../diagnostics/method_getsiteanalysis.go | 54 + .../diagnostics/method_getsiteanalysisslot.go | 54 + .../diagnostics/method_getsitedetector.go | 54 + .../method_getsitedetectorresponse.go | 91 + .../method_getsitedetectorresponseslot.go | 91 + .../diagnostics/method_getsitedetectorslot.go | 54 + .../method_getsitediagnosticcategory.go | 54 + .../method_getsitediagnosticcategoryslot.go | 54 + ...listhostingenvironmentdetectorresponses.go | 92 + .../diagnostics/method_listsiteanalyses.go | 91 + .../method_listsiteanalysesslot.go | 91 + .../method_listsitedetectorresponses.go | 92 + .../method_listsitedetectorresponsesslot.go | 91 + .../diagnostics/method_listsitedetectors.go | 91 + .../method_listsitedetectorsslot.go | 91 + .../method_listsitediagnosticcategories.go | 92 + ...method_listsitediagnosticcategoriesslot.go | 91 + .../diagnostics/model_abnormaltimeperiod.go | 41 + .../diagnostics/model_analysisdata.go | 12 + .../diagnostics/model_analysisdefinition.go | 12 + .../model_analysisdefinitionproperties.go | 8 + .../diagnostics/model_dataprovidermetadata.go | 9 + .../diagnostics/model_datasource.go | 9 + .../model_datatableresponsecolumn.go | 10 + .../model_datatableresponseobject.go | 10 + .../model_detectorabnormaltimeperiod.go | 45 + .../diagnostics/model_detectordefinition.go | 11 + .../model_detectordefinitionresource.go | 12 + .../diagnostics/model_detectorinfo.go | 16 + .../diagnostics/model_detectorresponse.go | 12 + .../model_detectorresponseproperties.go | 12 + .../diagnostics/model_diagnosticanalysis.go | 12 + .../model_diagnosticanalysisproperties.go | 42 + .../diagnostics/model_diagnosticcategory.go | 12 + .../model_diagnosticcategoryproperties.go | 8 + .../diagnostics/model_diagnosticdata.go | 9 + .../model_diagnosticdetectorresponse.go | 12 + ...el_diagnosticdetectorresponseproperties.go | 45 + .../model_diagnosticmetricsample.go | 31 + .../diagnostics/model_diagnosticmetricset.go | 43 + .../model_keyvaluepairstringobject.go | 9 + .../diagnostics/model_namevaluepair.go | 9 + .../model_queryutterancesresult.go | 9 + .../model_queryutterancesresults.go | 9 + .../2023-12-01/diagnostics/model_rendering.go | 10 + .../diagnostics/model_responsemetadata.go | 8 + .../diagnostics/model_sampleutterance.go | 10 + .../2023-12-01/diagnostics/model_solution.go | 14 + .../2023-12-01/diagnostics/model_status.go | 9 + .../diagnostics/model_supporttopic.go | 9 + .../web/2023-12-01/diagnostics/predicates.go | 116 + .../web/2023-12-01/diagnostics/version.go | 12 + .../web/2023-12-01/domains/README.md | 307 + .../web/2023-12-01/domains/client.go | 26 + .../web/2023-12-01/domains/constants.go | 407 + .../web/2023-12-01/domains/id_domain.go | 130 + .../web/2023-12-01/domains/id_domain_test.go | 282 + .../domains/id_domainownershipidentifier.go | 139 + .../id_domainownershipidentifier_test.go | 327 + .../domains/method_checkavailability.go | 60 + .../domains/method_createorupdate.go | 75 + ...ethod_createorupdateownershipidentifier.go | 58 + .../web/2023-12-01/domains/method_delete.go | 76 + .../method_deleteownershipidentifier.go | 47 + .../web/2023-12-01/domains/method_get.go | 54 + .../method_getcontrolcenterssorequest.go | 56 + .../domains/method_getownershipidentifier.go | 54 + .../web/2023-12-01/domains/method_list.go | 92 + .../domains/method_listbyresourcegroup.go | 92 + .../method_listownershipidentifiers.go | 91 + .../domains/method_listrecommendations.go | 92 + .../web/2023-12-01/domains/method_renew.go | 49 + .../2023-12-01/domains/method_transferout.go | 55 + .../web/2023-12-01/domains/method_update.go | 59 + .../method_updateownershipidentifier.go | 58 + .../web/2023-12-01/domains/model_address.go | 13 + .../web/2023-12-01/domains/model_contact.go | 16 + .../web/2023-12-01/domains/model_domain.go | 14 + .../model_domainavailabilitycheckresult.go | 10 + .../model_domaincontrolcenterssorequest.go | 10 + .../model_domainownershipidentifier.go | 12 + ...del_domainownershipidentifierproperties.go | 8 + .../domains/model_domainpatchresource.go | 12 + .../model_domainpatchresourceproperties.go | 69 + .../domains/model_domainproperties.go | 69 + .../domains/model_domainpurchaseconsent.go | 28 + ...el_domainrecommendationsearchparameters.go | 9 + .../web/2023-12-01/domains/model_hostname.go | 13 + .../domains/model_nameidentifier.go | 8 + .../web/2023-12-01/domains/predicates.go | 78 + .../web/2023-12-01/domains/version.go | 12 + .../web/2023-12-01/global/README.md | 52 + .../web/2023-12-01/global/client.go | 26 + .../web/2023-12-01/global/id_deletedsite.go | 121 + .../2023-12-01/global/id_deletedsite_test.go | 237 + .../global/method_getdeletedwebapp.go | 54 + .../method_getdeletedwebappsnapshots.go | 55 + .../2023-12-01/global/model_deletedsite.go | 12 + .../global/model_deletedsiteproperties.go | 15 + .../web/2023-12-01/global/model_snapshot.go | 12 + .../global/model_snapshotproperties.go | 8 + .../web/2023-12-01/global/version.go | 12 + .../web/2023-12-01/kubeenvironments/README.md | 121 + .../web/2023-12-01/kubeenvironments/client.go | 26 + .../2023-12-01/kubeenvironments/constants.go | 157 + .../kubeenvironments/id_kubeenvironment.go | 130 + .../id_kubeenvironment_test.go | 282 + .../kubeenvironments/method_createorupdate.go | 75 + .../kubeenvironments/method_delete.go | 71 + .../2023-12-01/kubeenvironments/method_get.go | 54 + .../method_listbyresourcegroup.go | 92 + .../method_listbysubscription.go | 92 + .../kubeenvironments/method_update.go | 59 + .../model_applogsconfiguration.go | 9 + .../model_arcconfiguration.go | 14 + .../model_containerappsconfiguration.go | 13 + .../model_extendedlocation.go | 9 + .../model_frontendconfiguration.go | 8 + .../kubeenvironments/model_kubeenvironment.go | 15 + .../model_kubeenvironmentpatchresource.go | 12 + ..._kubeenvironmentpatchresourceproperties.go | 16 + .../model_kubeenvironmentproperties.go | 17 + .../model_loganalyticsconfiguration.go | 9 + .../2023-12-01/kubeenvironments/predicates.go | 37 + .../2023-12-01/kubeenvironments/version.go | 12 + .../web/2023-12-01/provider/README.md | 123 + .../web/2023-12-01/provider/client.go | 26 + .../web/2023-12-01/provider/constants.go | 145 + .../web/2023-12-01/provider/id_location.go | 112 + .../2023-12-01/provider/id_location_test.go | 192 + .../provider/method_getavailablestacks.go | 119 + .../method_getavailablestacksonprem.go | 120 + .../provider/method_getfunctionappstacks.go | 119 + .../method_getfunctionappstacksforlocation.go | 119 + .../provider/method_getwebappstacks.go | 119 + .../method_getwebappstacksforlocation.go | 119 + .../model_appinsightswebappstacksettings.go | 9 + .../provider/model_applicationstack.go | 13 + .../model_applicationstackresource.go | 12 + .../provider/model_functionappmajorversion.go | 10 + .../provider/model_functionappminorversion.go | 10 + .../provider/model_functionappruntimes.go | 9 + .../model_functionappruntimesettings.go | 39 + .../provider/model_functionappstack.go | 13 + .../model_functionappstackproperties.go | 11 + .../model_githubactionwebappstacksettings.go | 9 + .../model_linuxjavacontainersettings.go | 33 + .../model_siteconfigpropertiesdictionary.go | 11 + .../provider/model_stackmajorversion.go | 17 + .../provider/model_stackminorversion.go | 11 + .../provider/model_webappmajorversion.go | 10 + .../provider/model_webappminorversion.go | 10 + .../provider/model_webappruntimes.go | 11 + .../provider/model_webappruntimesettings.go | 35 + .../2023-12-01/provider/model_webappstack.go | 13 + .../provider/model_webappstackproperties.go | 11 + .../model_windowsjavacontainersettings.go | 33 + .../web/2023-12-01/provider/predicates.go | 98 + .../web/2023-12-01/provider/version.go | 12 + .../web/2023-12-01/recommendations/README.md | 266 + .../web/2023-12-01/recommendations/client.go | 26 + .../2023-12-01/recommendations/constants.go | 151 + .../id_hostingenvironmentrecommendation.go | 139 + ...d_hostingenvironmentrecommendation_test.go | 327 + .../recommendations/id_recommendation.go | 121 + .../recommendations/id_recommendation_test.go | 237 + .../recommendations/id_siterecommendation.go | 139 + .../id_siterecommendation_test.go | 327 + .../method_disableallforhostingenvironment.go | 76 + .../method_disableallforwebapp.go | 48 + ...ablerecommendationforhostingenvironment.go | 75 + .../method_disablerecommendationforsite.go | 47 + ...od_disablerecommendationforsubscription.go | 47 + ...thod_getruledetailsbyhostingenvironment.go | 87 + .../method_getruledetailsbywebapp.go | 87 + .../2023-12-01/recommendations/method_list.go | 124 + ...method_listhistoryforhostingenvironment.go | 124 + .../method_listhistoryforwebapp.go | 124 + ...strecommendedrulesforhostingenvironment.go | 124 + .../method_listrecommendedrulesforwebapp.go | 124 + .../recommendations/method_resetallfilters.go | 48 + ...od_resetallfiltersforhostingenvironment.go | 76 + .../method_resetallfiltersforwebapp.go | 48 + .../recommendations/model_recommendation.go | 12 + .../model_recommendationproperties.go | 108 + .../model_recommendationrule.go | 12 + .../model_recommendationruleproperties.go | 20 + .../2023-12-01/recommendations/predicates.go | 32 + .../web/2023-12-01/recommendations/version.go | 12 + .../resourcehealthmetadata/README.md | 121 + .../resourcehealthmetadata/client.go | 26 + .../resourcehealthmetadata/id_slot.go | 139 + .../resourcehealthmetadata/id_slot_test.go | 327 + .../method_getbysite.go | 56 + .../method_getbysiteslot.go | 55 + .../resourcehealthmetadata/method_list.go | 92 + .../method_listbyresourcegroup.go | 92 + .../method_listbysite.go | 92 + .../method_listbysiteslot.go | 91 + .../model_resourcehealthmetadata.go | 12 + .../model_resourcehealthmetadataproperties.go | 9 + .../resourcehealthmetadata/predicates.go | 32 + .../resourcehealthmetadata/version.go | 12 + .../2023-12-01/resourceproviders/README.md | 372 + .../2023-12-01/resourceproviders/client.go | 26 + .../2023-12-01/resourceproviders/constants.go | 563 ++ .../resourceproviders/id_providerlocation.go | 121 + .../id_providerlocation_test.go | 237 + .../resourceproviders/id_sourcecontrol.go | 112 + .../id_sourcecontrol_test.go | 192 + .../method_checknameavailability.go | 60 + .../method_getpublishinguser.go | 54 + .../method_getsourcecontrol.go | 54 + ...thod_getsubscriptiondeploymentlocations.go | 56 + .../method_getusagesinlocationlist.go | 91 + .../method_listaseregions.go | 92 + .../method_listbillingmeters.go | 124 + .../method_listcustomhostnamesites.go | 120 + .../method_listgeoregions.go | 132 + .../method_listpremieraddonoffers.go | 92 + ...d_listsiteidentifiersassignedtohostname.go | 92 + .../resourceproviders/method_listskus.go | 56 + .../method_listsourcecontrols.go | 91 + .../resourceproviders/method_move.go | 52 + .../method_updatepublishinguser.go | 58 + .../method_updatesourcecontrol.go | 58 + .../resourceproviders/method_validate.go | 60 + .../resourceproviders/method_validatemove.go | 52 + .../method_verifyhostingenvironmentvnet.go | 60 + .../model_appserviceenvironment.go | 27 + .../resourceproviders/model_aseregion.go | 12 + .../model_aseregionproperties.go | 13 + .../model_asev3networkingconfiguration.go | 12 + ..._asev3networkingconfigurationproperties.go | 15 + .../resourceproviders/model_billingmeter.go | 12 + .../model_billingmeterproperties.go | 14 + .../resourceproviders/model_capability.go | 10 + .../model_csmmoveresourceenvelope.go | 9 + .../resourceproviders/model_csmusagequota.go | 30 + .../model_customdnssuffixconfiguration.go | 12 + ..._customdnssuffixconfigurationproperties.go | 12 + .../model_customhostnamesites.go | 12 + .../model_customhostnamesitesproperties.go | 10 + .../model_deploymentlocations.go | 10 + .../resourceproviders/model_georegion.go | 12 + .../model_georegionproperties.go | 10 + .../model_globalcsmskudescription.go | 14 + .../model_hostingenvironmentdeploymentinfo.go | 9 + .../resourceproviders/model_identifier.go | 12 + .../model_identifierproperties.go | 8 + .../model_localizablestring.go | 9 + .../resourceproviders/model_nameidentifier.go | 8 + .../resourceproviders/model_namevaluepair.go | 9 + .../model_premieraddonoffer.go | 12 + .../model_premieraddonofferproperties.go | 17 + .../model_resourcenameavailability.go | 10 + .../model_resourcenameavailabilityrequest.go | 11 + .../resourceproviders/model_skucapacity.go | 12 + .../resourceproviders/model_skuinfos.go | 9 + .../resourceproviders/model_sourcecontrol.go | 12 + .../model_sourcecontrolproperties.go | 29 + .../resourceproviders/model_user.go | 12 + .../resourceproviders/model_userproperties.go | 12 + .../model_validateproperties.go | 21 + .../model_validaterequest.go | 11 + .../model_validateresponse.go | 9 + .../model_validateresponseerror.go | 9 + .../model_virtualnetworkprofile.go | 11 + .../resourceproviders/model_vnetparameters.go | 12 + .../model_vnetparametersproperties.go | 11 + .../model_vnetvalidationfailuredetails.go | 12 + ..._vnetvalidationfailuredetailsproperties.go | 11 + .../model_vnetvalidationtestfailure.go | 12 + ...del_vnetvalidationtestfailureproperties.go | 9 + .../resourceproviders/predicates.go | 228 + .../2023-12-01/resourceproviders/version.go | 12 + .../web/2023-12-01/staticsites/README.md | 1300 +++ .../web/2023-12-01/staticsites/client.go | 26 + .../web/2023-12-01/staticsites/constants.go | 251 + .../2023-12-01/staticsites/id_authprovider.go | 139 + .../staticsites/id_authprovider_test.go | 327 + .../web/2023-12-01/staticsites/id_build.go | 139 + .../2023-12-01/staticsites/id_build_test.go | 327 + .../staticsites/id_builddatabaseconnection.go | 148 + .../id_builddatabaseconnection_test.go | 372 + .../staticsites/id_buildlinkedbackend.go | 148 + .../staticsites/id_buildlinkedbackend_test.go | 372 + .../id_builduserprovidedfunctionapp.go | 148 + .../id_builduserprovidedfunctionapp_test.go | 372 + .../2023-12-01/staticsites/id_customdomain.go | 139 + .../staticsites/id_customdomain_test.go | 327 + .../staticsites/id_databaseconnection.go | 139 + .../staticsites/id_databaseconnection_test.go | 327 + .../staticsites/id_linkedbackend.go | 139 + .../staticsites/id_linkedbackend_test.go | 327 + .../staticsites/id_providerlocation.go | 121 + .../staticsites/id_providerlocation_test.go | 237 + .../2023-12-01/staticsites/id_staticsite.go | 130 + .../staticsites/id_staticsite_test.go | 282 + .../id_staticsiteprivateendpointconnection.go | 139 + ...taticsiteprivateendpointconnection_test.go | 327 + .../web/2023-12-01/staticsites/id_user.go | 148 + .../2023-12-01/staticsites/id_user_test.go | 372 + .../staticsites/id_userprovidedfunctionapp.go | 139 + .../id_userprovidedfunctionapp_test.go | 327 + ...pproveorrejectprivateendpointconnection.go | 75 + .../method_createorupdatebasicauth.go | 59 + ...d_createorupdatebuilddatabaseconnection.go | 58 + ...method_createorupdatedatabaseconnection.go | 58 + .../method_createorupdatestaticsite.go | 75 + ...hod_createorupdatestaticsiteappsettings.go | 59 + ...reateorupdatestaticsitebuildappsettings.go | 59 + ...pdatestaticsitebuildfunctionappsettings.go | 59 + ...od_createorupdatestaticsitecustomdomain.go | 75 + ...teorupdatestaticsitefunctionappsettings.go | 59 + .../method_createuserrolesinvitationlink.go | 59 + ...method_createzipdeploymentforstaticsite.go | 74 + ...d_createzipdeploymentforstaticsitebuild.go | 74 + .../method_deletebuilddatabaseconnection.go | 47 + .../method_deletedatabaseconnection.go | 47 + .../method_deleteprivateendpointconnection.go | 72 + .../staticsites/method_deletestaticsite.go | 70 + .../method_deletestaticsitebuild.go | 71 + .../method_deletestaticsitecustomdomain.go | 70 + .../method_deletestaticsiteuser.go | 46 + .../staticsites/method_detachstaticsite.go | 70 + ...chuserprovidedfunctionappfromstaticsite.go | 47 + ...rprovidedfunctionappfromstaticsitebuild.go | 47 + .../staticsites/method_getbasicauth.go | 55 + .../method_getbuilddatabaseconnection.go | 54 + .../method_getbuilddatabaseconnections.go | 91 + ..._getbuilddatabaseconnectionswithdetails.go | 91 + ...d_getbuilddatabaseconnectionwithdetails.go | 55 + .../method_getdatabaseconnection.go | 54 + .../method_getdatabaseconnections.go | 91 + ...ethod_getdatabaseconnectionswithdetails.go | 91 + ...method_getdatabaseconnectionwithdetails.go | 55 + .../staticsites/method_getlinkedbackend.go | 54 + .../method_getlinkedbackendforbuild.go | 54 + .../staticsites/method_getlinkedbackends.go | 91 + .../method_getlinkedbackendsforbuild.go | 91 + .../method_getprivateendpointconnection.go | 54 + ...method_getprivateendpointconnectionlist.go | 91 + .../method_getprivatelinkresources.go | 55 + .../staticsites/method_getstaticsite.go | 54 + .../staticsites/method_getstaticsitebuild.go | 54 + .../staticsites/method_getstaticsitebuilds.go | 91 + .../method_getstaticsitecustomdomain.go | 54 + .../method_getstaticsitesbyresourcegroup.go | 92 + ...getuserprovidedfunctionappforstaticsite.go | 54 + ...erprovidedfunctionappforstaticsitebuild.go | 54 + ...etuserprovidedfunctionappsforstaticsite.go | 91 + ...rprovidedfunctionappsforstaticsitebuild.go | 91 + .../staticsites/method_linkbackend.go | 74 + .../staticsites/method_linkbackendtobuild.go | 74 + .../web/2023-12-01/staticsites/method_list.go | 92 + .../staticsites/method_listbasicauth.go | 91 + .../method_liststaticsiteappsettings.go | 55 + .../method_liststaticsitebuildappsettings.go | 55 + ..._liststaticsitebuildfunctionappsettings.go | 55 + .../method_liststaticsitebuildfunctions.go | 91 + .../method_liststaticsiteconfiguredroles.go | 55 + .../method_liststaticsitecustomdomains.go | 91 + ...ethod_liststaticsitefunctionappsettings.go | 55 + .../method_liststaticsitefunctions.go | 91 + .../method_liststaticsitesecrets.go | 55 + .../staticsites/method_liststaticsiteusers.go | 91 + .../staticsites/method_previewworkflow.go | 59 + ...eruserprovidedfunctionappwithstaticsite.go | 103 + ...rprovidedfunctionappwithstaticsitebuild.go | 103 + .../method_resetstaticsiteapikey.go | 51 + .../staticsites/method_unlinkbackend.go | 76 + .../method_unlinkbackendfrombuild.go | 76 + .../method_updatebuilddatabaseconnection.go | 58 + .../method_updatedatabaseconnection.go | 58 + .../staticsites/method_updatestaticsite.go | 59 + .../method_updatestaticsiteuser.go | 58 + .../staticsites/method_validatebackend.go | 74 + .../method_validatebackendforbuild.go | 74 + ...idatecustomdomaincanbeaddedtostaticsite.go | 74 + .../staticsites/model_armidwrapper.go | 8 + .../2023-12-01/staticsites/model_armplan.go | 12 + .../staticsites/model_capability.go | 10 + .../staticsites/model_databaseconnection.go | 12 + .../model_databaseconnectionoverview.go | 12 + .../model_databaseconnectionpatchrequest.go | 8 + ...atabaseconnectionpatchrequestproperties.go | 11 + .../model_databaseconnectionproperties.go | 12 + .../staticsites/model_errorentity.go | 15 + .../model_privatelinkconnectionstate.go | 10 + .../staticsites/model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 10 + .../model_privatelinkresourceswrapper.go | 8 + .../model_remoteprivateendpointconnection.go | 12 + ...oteprivateendpointconnectionarmresource.go | 12 + ...endpointconnectionarmresourceproperties.go | 11 + ...moteprivateendpointconnectionproperties.go | 11 + ...enveloperemoteprivateendpointconnection.go | 24 + .../staticsites/model_skucapacity.go | 12 + .../staticsites/model_skudescription.go | 15 + .../staticsites/model_staticsite.go | 25 + .../model_staticsitearmresource.go | 20 + ...taticsitebasicauthpropertiesarmresource.go | 12 + ...asicauthpropertiesarmresourceproperties.go | 12 + .../model_staticsitebuildarmresource.go | 12 + ...el_staticsitebuildarmresourceproperties.go | 47 + .../model_staticsitebuildproperties.go | 15 + ...aticsitecustomdomainoverviewarmresource.go | 12 + ...stomdomainoverviewarmresourceproperties.go | 30 + ...ustomdomainrequestpropertiesarmresource.go | 12 + ...nrequestpropertiesarmresourceproperties.go | 8 + ...baseconnectionconfigurationfileoverview.go | 10 + ...l_staticsitefunctionoverviewarmresource.go | 12 + ...tefunctionoverviewarmresourceproperties.go | 9 + .../model_staticsitelinkedbackend.go | 29 + ...odel_staticsitelinkedbackendarmresource.go | 12 + ...csitelinkedbackendarmresourceproperties.go | 29 + .../model_staticsitepatchresource.go | 12 + ...el_staticsiteresetpropertiesarmresource.go | 12 + ...iteresetpropertiesarmresourceproperties.go | 9 + .../model_staticsitesworkflowpreview.go | 12 + ...el_staticsitesworkflowpreviewproperties.go | 9 + ...model_staticsitesworkflowpreviewrequest.go | 12 + ...icsitesworkflowpreviewrequestproperties.go | 10 + .../model_staticsitetemplateoptions.go | 12 + .../model_staticsiteuserarmresource.go | 12 + ...del_staticsiteuserarmresourceproperties.go | 11 + ...staticsiteuserinvitationrequestresource.go | 12 + ...userinvitationrequestresourceproperties.go | 12 + ...taticsiteuserinvitationresponseresource.go | 12 + ...serinvitationresponseresourceproperties.go | 27 + ...model_staticsiteuserprovidedfunctionapp.go | 12 + ...csiteuserprovidedfunctionapparmresource.go | 12 + ...rovidedfunctionapparmresourceproperties.go | 28 + ...icsiteuserprovidedfunctionappproperties.go | 28 + .../model_staticsitezipdeployment.go | 12 + ...odel_staticsitezipdeploymentarmresource.go | 12 + .../staticsites/model_stringdictionary.go | 12 + .../staticsites/model_stringlist.go | 12 + .../web/2023-12-01/staticsites/predicates.go | 289 + .../web/2023-12-01/staticsites/version.go | 12 + .../web/2023-12-01/topleveldomains/README.md | 76 + .../web/2023-12-01/topleveldomains/client.go | 26 + .../topleveldomains/id_topleveldomain.go | 121 + .../topleveldomains/id_topleveldomain_test.go | 237 + .../2023-12-01/topleveldomains/method_get.go | 54 + .../2023-12-01/topleveldomains/method_list.go | 92 + .../topleveldomains/method_listagreements.go | 91 + .../model_tldlegalagreement.go | 11 + .../topleveldomains/model_topleveldomain.go | 12 + .../model_topleveldomainagreementoption.go | 9 + .../model_topleveldomainproperties.go | 8 + .../2023-12-01/topleveldomains/predicates.go | 60 + .../web/2023-12-01/topleveldomains/version.go | 12 + .../web/2023-12-01/webapps/README.md | 7053 +++++++++++++++++ .../web/2023-12-01/webapps/client.go | 26 + .../web/2023-12-01/webapps/constants.go | 2725 +++++++ .../web/2023-12-01/webapps/id_appsetting.go | 141 + .../2023-12-01/webapps/id_appsetting_test.go | 357 + .../web/2023-12-01/webapps/id_backup.go | 139 + .../web/2023-12-01/webapps/id_backup_test.go | 327 + .../webapps/id_configreferenceappsetting.go | 150 + .../id_configreferenceappsetting_test.go | 402 + .../id_configreferenceconnectionstring.go | 150 + ...id_configreferenceconnectionstring_test.go | 402 + .../2023-12-01/webapps/id_connectionstring.go | 141 + .../webapps/id_connectionstring_test.go | 357 + .../2023-12-01/webapps/id_continuouswebjob.go | 139 + .../webapps/id_continuouswebjob_test.go | 327 + .../web/2023-12-01/webapps/id_default.go | 148 + .../web/2023-12-01/webapps/id_default_test.go | 372 + .../web/2023-12-01/webapps/id_deployment.go | 139 + .../2023-12-01/webapps/id_deployment_test.go | 327 + .../webapps/id_domainownershipidentifier.go | 139 + .../id_domainownershipidentifier_test.go | 327 + .../web/2023-12-01/webapps/id_function.go | 139 + .../2023-12-01/webapps/id_function_test.go | 327 + .../web/2023-12-01/webapps/id_functionkey.go | 157 + .../2023-12-01/webapps/id_functionkey_test.go | 417 + .../web/2023-12-01/webapps/id_gateway.go | 148 + .../web/2023-12-01/webapps/id_gateway_test.go | 372 + .../web/2023-12-01/webapps/id_history.go | 148 + .../web/2023-12-01/webapps/id_history_test.go | 372 + .../web/2023-12-01/webapps/id_hostdefault.go | 157 + .../2023-12-01/webapps/id_hostdefault_test.go | 417 + .../2023-12-01/webapps/id_hostnamebinding.go | 139 + .../webapps/id_hostnamebinding_test.go | 327 + .../2023-12-01/webapps/id_hybridconnection.go | 139 + .../webapps/id_hybridconnection_test.go | 327 + .../web/2023-12-01/webapps/id_instance.go | 139 + .../2023-12-01/webapps/id_instance_test.go | 327 + .../2023-12-01/webapps/id_instanceprocess.go | 148 + .../webapps/id_instanceprocess_test.go | 372 + .../webapps/id_instanceprocessmodule.go | 157 + .../webapps/id_instanceprocessmodule_test.go | 417 + .../web/2023-12-01/webapps/id_key.go | 148 + .../web/2023-12-01/webapps/id_key_test.go | 372 + .../web/2023-12-01/webapps/id_module.go | 148 + .../web/2023-12-01/webapps/id_module_test.go | 372 + .../2023-12-01/webapps/id_networkfeature.go | 139 + .../webapps/id_networkfeature_test.go | 327 + .../web/2023-12-01/webapps/id_networktrace.go | 139 + .../webapps/id_networktrace_test.go | 327 + .../web/2023-12-01/webapps/id_premieraddon.go | 139 + .../webapps/id_premieraddon_test.go | 327 + .../webapps/id_privateendpointconnection.go | 139 + .../id_privateendpointconnection_test.go | 327 + .../web/2023-12-01/webapps/id_process.go | 139 + .../web/2023-12-01/webapps/id_process_test.go | 327 + .../2023-12-01/webapps/id_processmodule.go | 157 + .../webapps/id_processmodule_test.go | 417 + .../webapps/id_publiccertificate.go | 139 + .../webapps/id_publiccertificate_test.go | 327 + .../web/2023-12-01/webapps/id_relay.go | 148 + .../web/2023-12-01/webapps/id_relay_test.go | 372 + .../2023-12-01/webapps/id_sitecontainer.go | 139 + .../webapps/id_sitecontainer_test.go | 327 + .../2023-12-01/webapps/id_siteextension.go | 139 + .../webapps/id_siteextension_test.go | 327 + .../2023-12-01/webapps/id_sitenetworktrace.go | 139 + .../webapps/id_sitenetworktrace_test.go | 327 + .../webapps/id_siteslotnetworktrace.go | 148 + .../webapps/id_siteslotnetworktrace_test.go | 372 + .../web/2023-12-01/webapps/id_slot.go | 139 + .../web/2023-12-01/webapps/id_slot_test.go | 327 + .../web/2023-12-01/webapps/id_slotbackup.go | 148 + .../2023-12-01/webapps/id_slotbackup_test.go | 372 + .../webapps/id_slotcontinuouswebjob.go | 148 + .../webapps/id_slotcontinuouswebjob_test.go | 372 + .../2023-12-01/webapps/id_slotdeployment.go | 148 + .../webapps/id_slotdeployment_test.go | 372 + .../id_slotdomainownershipidentifier.go | 148 + .../id_slotdomainownershipidentifier_test.go | 372 + .../web/2023-12-01/webapps/id_slotfunction.go | 148 + .../webapps/id_slotfunction_test.go | 372 + .../webapps/id_slothostnamebinding.go | 148 + .../webapps/id_slothostnamebinding_test.go | 372 + .../webapps/id_slothybridconnection.go | 148 + .../webapps/id_slothybridconnection_test.go | 372 + .../id_slothybridconnectionnamespacerelay.go | 157 + ...slothybridconnectionnamespacerelay_test.go | 417 + .../web/2023-12-01/webapps/id_slotinstance.go | 148 + .../webapps/id_slotinstance_test.go | 372 + .../webapps/id_slotinstanceprocess.go | 157 + .../webapps/id_slotinstanceprocess_test.go | 417 + .../webapps/id_slotinstanceprocessmodule.go | 166 + .../id_slotinstanceprocessmodule_test.go | 462 ++ .../webapps/id_slotnetworkfeature.go | 148 + .../webapps/id_slotnetworkfeature_test.go | 372 + .../2023-12-01/webapps/id_slotnetworktrace.go | 148 + .../webapps/id_slotnetworktrace_test.go | 372 + .../2023-12-01/webapps/id_slotpremieraddon.go | 148 + .../webapps/id_slotpremieraddon_test.go | 372 + .../id_slotprivateendpointconnection.go | 148 + .../id_slotprivateendpointconnection_test.go | 372 + .../web/2023-12-01/webapps/id_slotprocess.go | 148 + .../2023-12-01/webapps/id_slotprocess_test.go | 372 + .../webapps/id_slotpubliccertificate.go | 148 + .../webapps/id_slotpubliccertificate_test.go | 372 + .../webapps/id_slotsitecontainer.go | 148 + .../webapps/id_slotsitecontainer_test.go | 372 + .../webapps/id_slotsiteextension.go | 148 + .../webapps/id_slotsiteextension_test.go | 372 + .../webapps/id_slottriggeredwebjob.go | 148 + .../webapps/id_slottriggeredwebjob_test.go | 372 + .../id_slotvirtualnetworkconnection.go | 148 + .../id_slotvirtualnetworkconnection_test.go | 372 + .../id_slotvirtualnetworkconnectiongateway.go | 157 + ...lotvirtualnetworkconnectiongateway_test.go | 417 + .../web/2023-12-01/webapps/id_slotwebjob.go | 148 + .../2023-12-01/webapps/id_slotwebjob_test.go | 372 + .../web/2023-12-01/webapps/id_slotworkflow.go | 148 + .../webapps/id_slotworkflow_test.go | 372 + .../web/2023-12-01/webapps/id_snapshot.go | 141 + .../2023-12-01/webapps/id_snapshot_test.go | 357 + .../2023-12-01/webapps/id_triggeredwebjob.go | 139 + .../webapps/id_triggeredwebjob_test.go | 327 + .../webapps/id_triggeredwebjobhistory.go | 157 + .../webapps/id_triggeredwebjobhistory_test.go | 417 + .../webapps/id_virtualnetworkconnection.go | 139 + .../id_virtualnetworkconnection_test.go | 327 + .../web/2023-12-01/webapps/id_webjob.go | 139 + .../web/2023-12-01/webapps/id_webjob_test.go | 327 + .../web/2023-12-01/webapps/id_websnapshot.go | 150 + .../2023-12-01/webapps/id_websnapshot_test.go | 402 + .../web/2023-12-01/webapps/id_workflow.go | 139 + .../2023-12-01/webapps/id_workflow_test.go | 327 + .../webapps/method_addpremieraddon.go | 58 + .../webapps/method_addpremieraddonslot.go | 58 + .../webapps/method_analyzecustomhostname.go | 84 + .../method_analyzecustomhostnameslot.go | 83 + .../method_applyslotconfigtoproduction.go | 52 + .../method_applyslotconfigurationslot.go | 51 + ...pproveorrejectprivateendpointconnection.go | 75 + ...veorrejectprivateendpointconnectionslot.go | 75 + .../web/2023-12-01/webapps/method_backup.go | 60 + .../2023-12-01/webapps/method_backupslot.go | 59 + .../webapps/method_createdeployment.go | 58 + .../webapps/method_createdeploymentslot.go | 58 + .../webapps/method_createfunction.go | 74 + .../method_createinstancefunctionslot.go | 74 + .../method_createinstancemsdeployoperation.go | 74 + ...hod_createinstancemsdeployoperationslot.go | 74 + .../webapps/method_createmsdeployoperation.go | 75 + .../method_createmsdeployoperationslot.go | 74 + .../method_createonedeployoperation.go | 56 + .../webapps/method_createorupdate.go | 76 + .../method_createorupdateconfiguration.go | 60 + .../method_createorupdateconfigurationslot.go | 59 + ...createorupdatedomainownershipidentifier.go | 58 + ...teorupdatedomainownershipidentifierslot.go | 58 + .../method_createorupdatefunctionsecret.go | 59 + ...method_createorupdatefunctionsecretslot.go | 59 + .../method_createorupdatehostnamebinding.go | 58 + ...ethod_createorupdatehostnamebindingslot.go | 58 + .../method_createorupdatehostsecret.go | 59 + .../method_createorupdatehostsecretslot.go | 59 + .../method_createorupdatehybridconnection.go | 58 + ...thod_createorupdatehybridconnectionslot.go | 58 + .../method_createorupdatepubliccertificate.go | 58 + ...hod_createorupdatepubliccertificateslot.go | 58 + ...od_createorupdaterelayserviceconnection.go | 58 + ...reateorupdaterelayserviceconnectionslot.go | 58 + .../method_createorupdatesitecontainer.go | 59 + .../method_createorupdatesitecontainerslot.go | 59 + .../webapps/method_createorupdateslot.go | 75 + .../method_createorupdatesourcecontrol.go | 77 + .../method_createorupdatesourcecontrolslot.go | 76 + ...eswiftvirtualnetworkconnectionwithcheck.go | 60 + ...ftvirtualnetworkconnectionwithcheckslot.go | 59 + .../method_createorupdatevnetconnection.go | 58 + ...hod_createorupdatevnetconnectiongateway.go | 58 + ...createorupdatevnetconnectiongatewayslot.go | 58 + ...method_createorupdatevnetconnectionslot.go | 58 + .../web/2023-12-01/webapps/method_delete.go | 81 + .../2023-12-01/webapps/method_deletebackup.go | 46 + .../method_deletebackupconfiguration.go | 48 + .../method_deletebackupconfigurationslot.go | 47 + .../webapps/method_deletebackupslot.go | 46 + .../webapps/method_deletecontinuouswebjob.go | 47 + .../method_deletecontinuouswebjobslot.go | 47 + .../webapps/method_deletedeployment.go | 47 + .../webapps/method_deletedeploymentslot.go | 47 + .../method_deletedomainownershipidentifier.go | 47 + ...hod_deletedomainownershipidentifierslot.go | 47 + .../webapps/method_deletefunction.go | 46 + .../webapps/method_deletefunctionsecret.go | 46 + .../method_deletefunctionsecretslot.go | 46 + .../webapps/method_deletehostnamebinding.go | 47 + .../method_deletehostnamebindingslot.go | 47 + .../webapps/method_deletehostsecret.go | 46 + .../webapps/method_deletehostsecretslot.go | 46 + .../webapps/method_deletehybridconnection.go | 46 + .../method_deletehybridconnectionslot.go | 46 + .../method_deleteinstancefunctionslot.go | 46 + .../webapps/method_deleteinstanceprocess.go | 46 + .../method_deleteinstanceprocessslot.go | 46 + .../webapps/method_deletepremieraddon.go | 46 + .../webapps/method_deletepremieraddonslot.go | 46 + .../method_deleteprivateendpointconnection.go | 72 + ...hod_deleteprivateendpointconnectionslot.go | 72 + .../webapps/method_deleteprocess.go | 46 + .../webapps/method_deleteprocessslot.go | 46 + .../webapps/method_deletepubliccertificate.go | 47 + .../method_deletepubliccertificateslot.go | 47 + .../method_deleterelayserviceconnection.go | 46 + ...method_deleterelayserviceconnectionslot.go | 46 + .../webapps/method_deletesitecontainer.go | 47 + .../webapps/method_deletesitecontainerslot.go | 47 + .../webapps/method_deletesiteextension.go | 46 + .../webapps/method_deletesiteextensionslot.go | 46 + .../2023-12-01/webapps/method_deleteslot.go | 80 + .../webapps/method_deletesourcecontrol.go | 77 + .../webapps/method_deletesourcecontrolslot.go | 76 + .../method_deleteswiftvirtualnetwork.go | 48 + .../method_deleteswiftvirtualnetworkslot.go | 47 + .../webapps/method_deletetriggeredwebjob.go | 47 + .../method_deletetriggeredwebjobslot.go | 47 + .../webapps/method_deletevnetconnection.go | 46 + .../method_deletevnetconnectionslot.go | 46 + .../webapps/method_deployworkflowartifacts.go | 52 + .../method_deployworkflowartifactsslot.go | 51 + .../webapps/method_discoverbackup.go | 60 + .../webapps/method_discoverbackupslot.go | 59 + ...ethod_generatenewsitepublishingpassword.go | 49 + ...d_generatenewsitepublishingpasswordslot.go | 48 + .../web/2023-12-01/webapps/method_get.go | 55 + .../method_getappsettingkeyvaultreference.go | 54 + ...thod_getappsettingkeyvaultreferenceslot.go | 54 + ...method_getappsettingskeyvaultreferences.go | 92 + ...od_getappsettingskeyvaultreferencesslot.go | 91 + .../webapps/method_getauthsettings.go | 56 + .../webapps/method_getauthsettingsslot.go | 55 + .../webapps/method_getauthsettingsv2.go | 56 + .../webapps/method_getauthsettingsv2slot.go | 55 + .../method_getauthsettingsv2withoutsecrets.go | 56 + ...hod_getauthsettingsv2withoutsecretsslot.go | 55 + .../webapps/method_getbackupconfiguration.go | 56 + .../method_getbackupconfigurationslot.go | 55 + .../webapps/method_getbackupstatus.go | 54 + .../webapps/method_getbackupstatusslot.go | 54 + .../webapps/method_getconfiguration.go | 56 + .../webapps/method_getconfigurationslot.go | 55 + .../method_getconfigurationsnapshot.go | 54 + .../method_getconfigurationsnapshotslot.go | 54 + .../webapps/method_getcontainerlogszip.go | 57 + .../webapps/method_getcontainerlogszipslot.go | 56 + .../webapps/method_getcontinuouswebjob.go | 54 + .../webapps/method_getcontinuouswebjobslot.go | 54 + .../webapps/method_getdeployment.go | 54 + .../webapps/method_getdeploymentslot.go | 54 + .../method_getdiagnosticlogsconfiguration.go | 56 + ...thod_getdiagnosticlogsconfigurationslot.go | 55 + .../method_getdomainownershipidentifier.go | 54 + ...method_getdomainownershipidentifierslot.go | 54 + .../webapps/method_getftpallowed.go | 56 + .../webapps/method_getftpallowedslot.go | 55 + .../2023-12-01/webapps/method_getfunction.go | 54 + .../webapps/method_getfunctionsadmintoken.go | 56 + .../method_getfunctionsadmintokenslot.go | 55 + .../webapps/method_gethostnamebinding.go | 54 + .../webapps/method_gethostnamebindingslot.go | 54 + .../webapps/method_gethybridconnection.go | 54 + .../webapps/method_gethybridconnectionslot.go | 54 + .../webapps/method_getinstancefunctionslot.go | 54 + .../webapps/method_getinstanceinfo.go | 54 + .../webapps/method_getinstanceinfoslot.go | 54 + .../webapps/method_getinstancemsdeploylog.go | 55 + .../method_getinstancemsdeploylogslot.go | 55 + .../method_getinstancemsdeploystatus.go | 55 + .../method_getinstancemsdeploystatusslot.go | 55 + .../webapps/method_getinstanceprocess.go | 54 + .../webapps/method_getinstanceprocessdump.go | 55 + .../method_getinstanceprocessdumpslot.go | 55 + .../method_getinstanceprocessmodule.go | 54 + .../method_getinstanceprocessmoduleslot.go | 54 + .../webapps/method_getinstanceprocessslot.go | 54 + .../webapps/method_getinstanceworkflowslot.go | 54 + .../webapps/method_getmigratemysqlstatus.go | 56 + .../method_getmigratemysqlstatusslot.go | 55 + .../webapps/method_getmsdeploylog.go | 56 + .../webapps/method_getmsdeploylogslot.go | 55 + .../webapps/method_getmsdeploystatus.go | 56 + .../webapps/method_getmsdeploystatusslot.go | 55 + .../webapps/method_getnetworktraces.go | 54 + .../webapps/method_getnetworktracesslot.go | 54 + .../webapps/method_getnetworktracesslotv2.go | 54 + .../webapps/method_getnetworktracesv2.go | 54 + .../webapps/method_getonedeploystatus.go | 56 + .../webapps/method_getpremieraddon.go | 54 + .../webapps/method_getpremieraddonslot.go | 54 + .../webapps/method_getprivateaccess.go | 56 + .../webapps/method_getprivateaccessslot.go | 55 + .../method_getprivateendpointconnection.go | 54 + ...method_getprivateendpointconnectionlist.go | 92 + ...od_getprivateendpointconnectionlistslot.go | 91 + ...method_getprivateendpointconnectionslot.go | 54 + .../webapps/method_getprivatelinkresources.go | 56 + .../method_getprivatelinkresourcesslot.go | 55 + .../2023-12-01/webapps/method_getprocess.go | 54 + .../webapps/method_getprocessdump.go | 55 + .../webapps/method_getprocessdumpslot.go | 55 + .../webapps/method_getprocessmodule.go | 54 + .../webapps/method_getprocessmoduleslot.go | 54 + .../webapps/method_getprocessslot.go | 54 + .../webapps/method_getpubliccertificate.go | 54 + .../method_getpubliccertificateslot.go | 54 + .../method_getrelayserviceconnection.go | 54 + .../method_getrelayserviceconnectionslot.go | 54 + .../webapps/method_getscmallowed.go | 56 + .../webapps/method_getscmallowedslot.go | 55 + ...etsiteconnectionstringkeyvaultreference.go | 54 + ...tsiteconnectionstringkeyvaultreferences.go | 92 + ...teconnectionstringkeyvaultreferenceslot.go | 54 + ...econnectionstringkeyvaultreferencesslot.go | 91 + .../webapps/method_getsitecontainer.go | 54 + .../webapps/method_getsitecontainerslot.go | 54 + .../webapps/method_getsiteextension.go | 54 + .../webapps/method_getsiteextensionslot.go | 54 + .../webapps/method_getsitephperrorlogflag.go | 56 + .../method_getsitephperrorlogflagslot.go | 55 + .../web/2023-12-01/webapps/method_getslot.go | 54 + .../webapps/method_getsourcecontrol.go | 58 + .../webapps/method_getsourcecontrolslot.go | 57 + ...method_getswiftvirtualnetworkconnection.go | 56 + ...od_getswiftvirtualnetworkconnectionslot.go | 55 + .../webapps/method_gettriggeredwebjob.go | 54 + .../method_gettriggeredwebjobhistory.go | 54 + .../method_gettriggeredwebjobhistoryslot.go | 54 + .../webapps/method_gettriggeredwebjobslot.go | 54 + .../webapps/method_getvnetconnection.go | 54 + .../method_getvnetconnectiongateway.go | 54 + .../method_getvnetconnectiongatewayslot.go | 54 + .../webapps/method_getvnetconnectionslot.go | 54 + .../2023-12-01/webapps/method_getwebjob.go | 54 + .../webapps/method_getwebjobslot.go | 54 + .../webapps/method_getwebsitecontainerlogs.go | 57 + .../method_getwebsitecontainerlogsslot.go | 56 + .../2023-12-01/webapps/method_getworkflow.go | 54 + .../webapps/method_installsiteextension.go | 71 + .../method_installsiteextensionslot.go | 71 + .../2023-12-01/webapps/method_iscloneable.go | 56 + .../webapps/method_iscloneableslot.go | 55 + .../web/2023-12-01/webapps/method_list.go | 92 + .../webapps/method_listapplicationsettings.go | 56 + .../method_listapplicationsettingsslot.go | 55 + .../method_listazurestorageaccounts.go | 56 + .../method_listazurestorageaccountsslot.go | 55 + .../2023-12-01/webapps/method_listbackups.go | 92 + .../webapps/method_listbackupsslot.go | 91 + .../webapps/method_listbackupstatussecrets.go | 59 + .../method_listbackupstatussecretsslot.go | 59 + ..._listbasicpublishingcredentialspolicies.go | 92 + ...tbasicpublishingcredentialspoliciesslot.go | 91 + .../webapps/method_listbyresourcegroup.go | 120 + .../webapps/method_listconfigurations.go | 92 + .../method_listconfigurationsnapshotinfo.go | 92 + ...ethod_listconfigurationsnapshotinfoslot.go | 91 + .../webapps/method_listconfigurationsslot.go | 91 + .../webapps/method_listconnectionstrings.go | 56 + .../method_listconnectionstringsslot.go | 55 + .../webapps/method_listcontinuouswebjobs.go | 92 + .../method_listcontinuouswebjobsslot.go | 91 + .../webapps/method_listdeploymentlog.go | 55 + .../webapps/method_listdeploymentlogslot.go | 55 + .../webapps/method_listdeployments.go | 92 + .../webapps/method_listdeploymentsslot.go | 91 + .../method_listdomainownershipidentifiers.go | 92 + ...thod_listdomainownershipidentifiersslot.go | 91 + .../webapps/method_listfunctionkeys.go | 55 + .../webapps/method_listfunctionkeysslot.go | 55 + .../webapps/method_listfunctions.go | 92 + .../webapps/method_listfunctionsecrets.go | 55 + .../webapps/method_listfunctionsecretsslot.go | 55 + .../2023-12-01/webapps/method_listhostkeys.go | 56 + .../webapps/method_listhostkeysslot.go | 55 + .../webapps/method_listhostnamebindings.go | 92 + .../method_listhostnamebindingsslot.go | 91 + .../webapps/method_listhybridconnections.go | 56 + .../method_listhybridconnectionsslot.go | 55 + .../method_listinstancefunctionsslot.go | 91 + .../webapps/method_listinstanceidentifiers.go | 92 + .../method_listinstanceidentifiersslot.go | 91 + .../webapps/method_listinstanceprocesses.go | 91 + .../method_listinstanceprocessesslot.go | 91 + .../method_listinstanceprocessmodules.go | 91 + .../method_listinstanceprocessmodulesslot.go | 91 + .../method_listinstanceprocessthreads.go | 91 + .../method_listinstanceprocessthreadsslot.go | 91 + .../method_listinstanceworkflowsslot.go | 91 + .../2023-12-01/webapps/method_listmetadata.go | 56 + .../webapps/method_listmetadataslot.go | 55 + .../webapps/method_listnetworkfeatures.go | 54 + .../webapps/method_listnetworkfeaturesslot.go | 54 + .../webapps/method_listperfmoncounters.go | 120 + .../webapps/method_listperfmoncountersslot.go | 119 + .../webapps/method_listpremieraddons.go | 56 + .../webapps/method_listpremieraddonsslot.go | 55 + .../webapps/method_listprocesses.go | 92 + .../webapps/method_listprocessesslot.go | 91 + .../webapps/method_listprocessmodules.go | 91 + .../webapps/method_listprocessmodulesslot.go | 91 + .../webapps/method_listprocessthreads.go | 91 + .../webapps/method_listprocessthreadsslot.go | 91 + ...od_listproductionsitedeploymentstatuses.go | 92 + .../webapps/method_listpubliccertificates.go | 92 + .../method_listpubliccertificatesslot.go | 91 + .../method_listpublishingcredentials.go | 71 + .../method_listpublishingcredentialsslot.go | 70 + ...hod_listpublishingprofilexmlwithsecrets.go | 60 + ...listpublishingprofilexmlwithsecretsslot.go | 59 + .../method_listrelayserviceconnections.go | 56 + .../method_listrelayserviceconnectionsslot.go | 55 + .../webapps/method_listsitebackups.go | 92 + .../webapps/method_listsitebackupsslot.go | 91 + .../webapps/method_listsitecontainers.go | 92 + .../webapps/method_listsitecontainersslot.go | 91 + .../webapps/method_listsiteextensions.go | 92 + .../webapps/method_listsiteextensionsslot.go | 91 + .../webapps/method_listsitepushsettings.go | 56 + .../method_listsitepushsettingsslot.go | 55 + .../method_listslotconfigurationnames.go | 56 + ...ethod_listslotdifferencesfromproduction.go | 92 + .../webapps/method_listslotdifferencesslot.go | 91 + .../2023-12-01/webapps/method_listslots.go | 92 + ...thod_listslotsitedeploymentstatusesslot.go | 91 + .../webapps/method_listsnapshots.go | 92 + .../method_listsnapshotsfromdrsecondary.go | 92 + ...method_listsnapshotsfromdrsecondaryslot.go | 91 + .../webapps/method_listsnapshotsslot.go | 91 + .../method_listsyncfunctiontriggers.go | 56 + .../method_listsyncfunctiontriggersslot.go | 55 + .../webapps/method_listsyncstatus.go | 48 + .../webapps/method_listsyncstatusslot.go | 47 + .../method_listtriggeredwebjobhistory.go | 91 + .../method_listtriggeredwebjobhistoryslot.go | 91 + .../webapps/method_listtriggeredwebjobs.go | 92 + .../method_listtriggeredwebjobsslot.go | 91 + .../2023-12-01/webapps/method_listusages.go | 120 + .../webapps/method_listusagesslot.go | 119 + .../webapps/method_listvnetconnections.go | 56 + .../webapps/method_listvnetconnectionsslot.go | 55 + .../2023-12-01/webapps/method_listwebjobs.go | 92 + .../webapps/method_listwebjobsslot.go | 91 + .../webapps/method_listworkflows.go | 92 + .../method_listworkflowsconnections.go | 56 + .../method_listworkflowsconnectionsslot.go | 55 + .../2023-12-01/webapps/method_migratemysql.go | 75 + .../webapps/method_migratestorage.go | 103 + .../webapps/method_putprivateaccessvnet.go | 60 + .../method_putprivateaccessvnetslot.go | 59 + ...method_recoversiteconfigurationsnapshot.go | 47 + ...od_recoversiteconfigurationsnapshotslot.go | 47 + .../method_resetproductionslotconfig.go | 48 + .../method_resetslotconfigurationslot.go | 47 + .../web/2023-12-01/webapps/method_restart.go | 80 + .../2023-12-01/webapps/method_restartslot.go | 79 + .../web/2023-12-01/webapps/method_restore.go | 74 + .../webapps/method_restorefrombackupblob.go | 75 + .../method_restorefrombackupblobslot.go | 74 + .../webapps/method_restorefromdeletedapp.go | 75 + .../method_restorefromdeletedappslot.go | 74 + .../2023-12-01/webapps/method_restoreslot.go | 74 + .../webapps/method_restoresnapshot.go | 75 + .../webapps/method_restoresnapshotslot.go | 74 + .../webapps/method_runtriggeredwebjob.go | 47 + .../webapps/method_runtriggeredwebjobslot.go | 47 + .../web/2023-12-01/webapps/method_start.go | 48 + .../webapps/method_startcontinuouswebjob.go | 47 + .../method_startcontinuouswebjobslot.go | 47 + .../webapps/method_startnetworktrace.go | 108 + .../webapps/method_startnetworktraceslot.go | 107 + .../2023-12-01/webapps/method_startslot.go | 47 + .../method_startwebsitenetworktrace.go | 92 + ...ethod_startwebsitenetworktraceoperation.go | 108 + ...d_startwebsitenetworktraceoperationslot.go | 107 + .../method_startwebsitenetworktraceslot.go | 91 + .../web/2023-12-01/webapps/method_stop.go | 48 + .../webapps/method_stopcontinuouswebjob.go | 47 + .../method_stopcontinuouswebjobslot.go | 47 + .../webapps/method_stopnetworktrace.go | 49 + .../webapps/method_stopnetworktraceslot.go | 48 + .../web/2023-12-01/webapps/method_stopslot.go | 47 + .../webapps/method_stopwebsitenetworktrace.go | 49 + .../method_stopwebsitenetworktraceslot.go | 48 + .../2023-12-01/webapps/method_swapslotslot.go | 74 + .../webapps/method_swapslotwithproduction.go | 75 + .../webapps/method_syncfunctions.go | 48 + .../webapps/method_syncfunctionsslot.go | 47 + .../webapps/method_syncfunctiontriggers.go | 48 + .../method_syncfunctiontriggersslot.go | 47 + .../webapps/method_syncrepository.go | 48 + .../webapps/method_syncrepositoryslot.go | 47 + .../web/2023-12-01/webapps/method_update.go | 60 + .../method_updateapplicationsettings.go | 60 + .../method_updateapplicationsettingsslot.go | 59 + .../webapps/method_updateauthsettings.go | 60 + .../webapps/method_updateauthsettingsslot.go | 59 + .../webapps/method_updateauthsettingsv2.go | 60 + .../method_updateauthsettingsv2slot.go | 59 + .../method_updateazurestorageaccounts.go | 60 + .../method_updateazurestorageaccountsslot.go | 59 + .../method_updatebackupconfiguration.go | 60 + .../method_updatebackupconfigurationslot.go | 59 + .../webapps/method_updateconfiguration.go | 60 + .../webapps/method_updateconfigurationslot.go | 59 + .../webapps/method_updateconnectionstrings.go | 60 + .../method_updateconnectionstringsslot.go | 59 + .../method_updatediagnosticlogsconfig.go | 60 + .../method_updatediagnosticlogsconfigslot.go | 59 + .../method_updatedomainownershipidentifier.go | 58 + ...hod_updatedomainownershipidentifierslot.go | 58 + .../webapps/method_updateftpallowed.go | 60 + .../webapps/method_updateftpallowedslot.go | 59 + .../webapps/method_updatehybridconnection.go | 58 + .../method_updatehybridconnectionslot.go | 58 + .../webapps/method_updatemetadata.go | 60 + .../webapps/method_updatemetadataslot.go | 59 + .../webapps/method_updatepremieraddon.go | 58 + .../webapps/method_updatepremieraddonslot.go | 58 + .../method_updaterelayserviceconnection.go | 58 + ...method_updaterelayserviceconnectionslot.go | 58 + .../webapps/method_updatescmallowed.go | 60 + .../webapps/method_updatescmallowedslot.go | 59 + .../webapps/method_updatesitepushsettings.go | 60 + .../method_updatesitepushsettingsslot.go | 59 + .../2023-12-01/webapps/method_updateslot.go | 59 + .../method_updateslotconfigurationnames.go | 60 + .../webapps/method_updatesourcecontrol.go | 62 + .../webapps/method_updatesourcecontrolslot.go | 61 + ...eswiftvirtualnetworkconnectionwithcheck.go | 60 + ...ftvirtualnetworkconnectionwithcheckslot.go | 59 + .../webapps/method_updatevnetconnection.go | 58 + .../method_updatevnetconnectiongateway.go | 58 + .../method_updatevnetconnectiongatewayslot.go | 58 + .../method_updatevnetconnectionslot.go | 58 + .../model_allowedaudiencesvalidation.go | 8 + .../webapps/model_allowedprincipals.go | 9 + .../webapps/model_apidefinitioninfo.go | 8 + .../webapps/model_apikvreference.go | 12 + .../webapps/model_apikvreferenceproperties.go | 20 + .../webapps/model_apimanagementconfig.go | 8 + .../web/2023-12-01/webapps/model_apple.go | 10 + .../webapps/model_appleregistration.go | 9 + .../webapps/model_applicationlogsconfig.go | 10 + .../webapps/model_appregistration.go | 9 + .../2023-12-01/webapps/model_armidwrapper.go | 8 + .../2023-12-01/webapps/model_authplatform.go | 10 + .../webapps/model_autohealactions.go | 10 + .../webapps/model_autohealcustomaction.go | 9 + .../2023-12-01/webapps/model_autohealrules.go | 9 + .../webapps/model_autohealtriggers.go | 13 + .../webapps/model_azureactivedirectory.go | 12 + .../model_azureactivedirectorylogin.go | 9 + .../model_azureactivedirectoryregistration.go | 13 + .../model_azureactivedirectoryvalidation.go | 10 + ...l_azureblobstorageapplicationlogsconfig.go | 10 + .../model_azureblobstoragehttplogsconfig.go | 10 + .../webapps/model_azurestaticwebapps.go | 9 + .../model_azurestaticwebappsregistration.go | 8 + .../webapps/model_azurestorageinfovalue.go | 14 + ..._azurestoragepropertydictionaryresource.go | 12 + ..._azuretablestorageapplicationlogsconfig.go | 9 + .../2023-12-01/webapps/model_backupitem.go | 12 + .../webapps/model_backupitemproperties.go | 63 + .../2023-12-01/webapps/model_backuprequest.go | 12 + .../webapps/model_backuprequestproperties.go | 12 + .../webapps/model_backupschedule.go | 43 + .../webapps/model_blobstoragetokenstore.go | 8 + .../webapps/model_clientregistration.go | 9 + .../2023-12-01/webapps/model_cloninginfo.go | 18 + .../model_connectionstringdictionary.go | 12 + .../webapps/model_connstringinfo.go | 10 + .../webapps/model_connstringvaluetypepair.go | 9 + .../webapps/model_containercpustatistics.go | 11 + .../webapps/model_containercpuusage.go | 11 + .../2023-12-01/webapps/model_containerinfo.go | 45 + .../model_containermemorystatistics.go | 10 + ...del_containernetworkinterfacestatistics.go | 15 + .../webapps/model_containerthrottlingdata.go | 10 + .../webapps/model_continuouswebjob.go | 12 + .../model_continuouswebjobproperties.go | 17 + .../webapps/model_cookieexpiration.go | 9 + .../2023-12-01/webapps/model_corssettings.go | 9 + .../webapps/model_csmdeploymentstatus.go | 12 + .../model_csmdeploymentstatusproperties.go | 14 + ..._csmpublishingcredentialspoliciesentity.go | 12 + ...hingcredentialspoliciesentityproperties.go | 8 + .../model_csmpublishingprofileoptions.go | 9 + .../2023-12-01/webapps/model_csmslotentity.go | 9 + .../2023-12-01/webapps/model_csmusagequota.go | 30 + .../model_customhostnameanalysisresult.go | 12 + ..._customhostnameanalysisresultproperties.go | 18 + .../model_customopenidconnectprovider.go | 10 + .../2023-12-01/webapps/model_daprconfig.go | 14 + .../webapps/model_databasebackupsetting.go | 11 + .../model_defaultauthorizationpolicy.go | 9 + .../webapps/model_deletedapprestorerequest.go | 12 + ...odel_deletedapprestorerequestproperties.go | 11 + .../2023-12-01/webapps/model_deployment.go | 12 + .../webapps/model_deploymentproperties.go | 46 + .../2023-12-01/webapps/model_enabledconfig.go | 8 + .../webapps/model_environmentvariable.go | 9 + .../2023-12-01/webapps/model_errorentity.go | 15 + .../2023-12-01/webapps/model_experiments.go | 8 + .../webapps/model_extendedlocation.go | 9 + .../web/2023-12-01/webapps/model_facebook.go | 11 + .../model_filesystemapplicationlogsconfig.go | 8 + .../webapps/model_filesystemhttplogsconfig.go | 10 + .../webapps/model_filesystemtokenstore.go | 8 + .../2023-12-01/webapps/model_forwardproxy.go | 10 + .../webapps/model_functionappconfig.go | 10 + .../webapps/model_functionenvelope.go | 12 + .../model_functionenvelopeproperties.go | 20 + .../model_functionsalwaysreadyconfig.go | 9 + .../webapps/model_functionsdeployment.go | 8 + .../model_functionsdeploymentstorage.go | 10 + ...unctionsdeploymentstorageauthentication.go | 10 + .../webapps/model_functionsecrets.go | 9 + .../webapps/model_functionsruntime.go | 9 + .../model_functionsscaleandconcurrency.go | 11 + ...el_functionsscaleandconcurrencytriggers.go | 8 + ...unctionsscaleandconcurrencytriggershttp.go | 8 + .../web/2023-12-01/webapps/model_github.go | 10 + .../model_githubactioncodeconfiguration.go | 9 + .../model_githubactionconfiguration.go | 11 + ...odel_githubactioncontainerconfiguration.go | 11 + .../webapps/model_globalvalidation.go | 11 + .../web/2023-12-01/webapps/model_google.go | 11 + .../webapps/model_handlermapping.go | 10 + .../model_hostingenvironmentprofile.go | 10 + .../web/2023-12-01/webapps/model_hostkeys.go | 10 + .../webapps/model_hostnamebinding.go | 12 + .../model_hostnamebindingproperties.go | 16 + .../webapps/model_hostnamesslstate.go | 13 + .../webapps/model_httplogsconfig.go | 9 + .../2023-12-01/webapps/model_httpsettings.go | 10 + .../webapps/model_httpsettingsroutes.go | 8 + .../webapps/model_hybridconnection.go | 12 + .../model_hybridconnectionproperties.go | 15 + .../2023-12-01/webapps/model_identifier.go | 12 + .../webapps/model_identifierproperties.go | 8 + .../webapps/model_identityproviders.go | 16 + .../webapps/model_ipsecurityrestriction.go | 18 + .../webapps/model_jwtclaimchecks.go | 9 + .../web/2023-12-01/webapps/model_keyinfo.go | 9 + .../webapps/model_legacymicrosoftaccount.go | 11 + .../webapps/model_localizablestring.go | 9 + .../web/2023-12-01/webapps/model_login.go | 13 + .../2023-12-01/webapps/model_loginroutes.go | 8 + .../2023-12-01/webapps/model_loginscopes.go | 8 + .../webapps/model_migratemysqlrequest.go | 12 + .../model_migratemysqlrequestproperties.go | 9 + .../webapps/model_migratemysqlstatus.go | 12 + .../model_migratemysqlstatusproperties.go | 10 + .../web/2023-12-01/webapps/model_msdeploy.go | 12 + .../2023-12-01/webapps/model_msdeploycore.go | 14 + .../2023-12-01/webapps/model_msdeploylog.go | 12 + .../webapps/model_msdeploylogentry.go | 28 + .../webapps/model_msdeploylogproperties.go | 8 + .../webapps/model_msdeployproperties.go | 8 + .../webapps/model_msdeploystatus.go | 12 + .../webapps/model_msdeploystatusproperties.go | 42 + .../2023-12-01/webapps/model_namevaluepair.go | 9 + .../webapps/model_networkfeatures.go | 12 + .../model_networkfeaturesproperties.go | 11 + .../2023-12-01/webapps/model_networktrace.go | 10 + .../web/2023-12-01/webapps/model_nonce.go | 9 + .../model_openidconnectclientcredential.go | 9 + .../webapps/model_openidconnectconfig.go | 12 + .../webapps/model_openidconnectlogin.go | 9 + .../model_openidconnectregistration.go | 10 + .../web/2023-12-01/webapps/model_operation.go | 57 + .../webapps/model_perfmonresponse.go | 10 + .../2023-12-01/webapps/model_perfmonsample.go | 28 + .../2023-12-01/webapps/model_perfmonset.go | 42 + .../2023-12-01/webapps/model_premieraddon.go | 14 + .../model_premieraddonpatchresource.go | 12 + ...del_premieraddonpatchresourceproperties.go | 12 + .../webapps/model_premieraddonproperties.go | 12 + .../2023-12-01/webapps/model_privateaccess.go | 12 + .../webapps/model_privateaccessproperties.go | 9 + .../webapps/model_privateaccesssubnet.go | 9 + .../model_privateaccessvirtualnetwork.go | 11 + .../model_privatelinkconnectionstate.go | 10 + .../webapps/model_privatelinkresource.go | 11 + .../model_privatelinkresourceproperties.go | 10 + .../model_privatelinkresourceswrapper.go | 8 + .../2023-12-01/webapps/model_processinfo.go | 12 + .../webapps/model_processinfoproperties.go | 73 + .../webapps/model_processmoduleinfo.go | 12 + .../model_processmoduleinfoproperties.go | 18 + .../webapps/model_processthreadinfo.go | 12 + .../model_processthreadinfoproperties.go | 37 + .../webapps/model_publiccertificate.go | 12 + .../model_publiccertificateproperties.go | 10 + .../2023-12-01/webapps/model_pushsettings.go | 12 + .../webapps/model_pushsettingsproperties.go | 11 + .../2023-12-01/webapps/model_rampuprule.go | 15 + .../model_relayserviceconnectionentity.go | 12 + ..._relayserviceconnectionentityproperties.go | 14 + ...oteprivateendpointconnectionarmresource.go | 12 + ...endpointconnectionarmresourceproperties.go | 11 + .../webapps/model_requestsbasedtrigger.go | 9 + .../webapps/model_resourceconfig.go | 9 + .../webapps/model_restorerequest.go | 12 + .../webapps/model_restorerequestproperties.go | 18 + .../web/2023-12-01/webapps/model_site.go | 20 + .../webapps/model_siteauthsettings.go | 12 + .../model_siteauthsettingsproperties.go | 45 + .../webapps/model_siteauthsettingsv2.go | 12 + .../model_siteauthsettingsv2properties.go | 12 + .../webapps/model_sitecloneability.go | 11 + .../model_sitecloneabilitycriterion.go | 9 + .../2023-12-01/webapps/model_siteconfig.go | 97 + .../webapps/model_siteconfigresource.go | 12 + .../model_siteconfigurationsnapshotinfo.go | 12 + ...siteconfigurationsnapshotinfoproperties.go | 27 + .../2023-12-01/webapps/model_sitecontainer.go | 12 + .../webapps/model_sitecontainerproperties.go | 49 + .../2023-12-01/webapps/model_sitednsconfig.go | 13 + .../webapps/model_siteextensioninfo.go | 12 + .../model_siteextensioninfoproperties.go | 57 + .../2023-12-01/webapps/model_sitelimits.go | 10 + .../webapps/model_sitelogsconfig.go | 12 + .../webapps/model_sitelogsconfigproperties.go | 11 + .../webapps/model_sitemachinekey.go | 11 + .../webapps/model_sitepatchresource.go | 17 + .../model_sitepatchresourceproperties.go | 79 + .../webapps/model_sitephperrorlogflag.go | 12 + .../model_sitephperrorlogflagproperties.go | 11 + .../webapps/model_siteproperties.go | 89 + .../webapps/model_sitesourcecontrol.go | 12 + .../model_sitesourcecontrolproperties.go | 14 + .../webapps/model_slotconfignames.go | 10 + .../webapps/model_slotconfignamesresource.go | 12 + .../webapps/model_slotdifference.go | 12 + .../webapps/model_slotdifferenceproperties.go | 14 + .../webapps/model_slotswapstatus.go | 28 + .../webapps/model_slowrequestsbasedtrigger.go | 11 + .../web/2023-12-01/webapps/model_snapshot.go | 12 + .../webapps/model_snapshotproperties.go | 8 + .../webapps/model_snapshotrecoverysource.go | 9 + .../webapps/model_snapshotrestorerequest.go | 12 + .../model_snapshotrestorerequestproperties.go | 13 + .../webapps/model_statuscodesbasedtrigger.go | 13 + .../model_statuscodesrangebasedtrigger.go | 11 + .../webapps/model_storagemigrationoptions.go | 12 + ...model_storagemigrationoptionsproperties.go | 11 + .../webapps/model_storagemigrationresponse.go | 12 + ...odel_storagemigrationresponseproperties.go | 8 + .../webapps/model_stringdictionary.go | 12 + .../webapps/model_swiftvirtualnetwork.go | 12 + .../model_swiftvirtualnetworkproperties.go | 9 + .../2023-12-01/webapps/model_tokenstore.go | 11 + .../webapps/model_triggeredjobhistory.go | 12 + .../model_triggeredjobhistoryproperties.go | 8 + .../webapps/model_triggeredjobrun.go | 48 + .../webapps/model_triggeredwebjob.go | 12 + .../model_triggeredwebjobproperties.go | 19 + .../web/2023-12-01/webapps/model_twitter.go | 9 + .../webapps/model_twitterregistration.go | 9 + .../web/2023-12-01/webapps/model_user.go | 12 + .../webapps/model_userproperties.go | 12 + .../webapps/model_virtualapplication.go | 11 + .../webapps/model_virtualdirectory.go | 9 + .../2023-12-01/webapps/model_vnetgateway.go | 12 + .../webapps/model_vnetgatewayproperties.go | 9 + .../web/2023-12-01/webapps/model_vnetinfo.go | 14 + .../webapps/model_vnetinforesource.go | 12 + .../web/2023-12-01/webapps/model_vnetroute.go | 12 + .../webapps/model_vnetrouteproperties.go | 10 + .../2023-12-01/webapps/model_volumemount.go | 11 + .../web/2023-12-01/webapps/model_webjob.go | 12 + .../webapps/model_webjobproperties.go | 14 + .../webapps/model_websiteinstancestatus.go | 12 + .../model_websiteinstancestatusproperties.go | 13 + .../webapps/model_workflowartifacts.go | 10 + .../webapps/model_workflowenvelope.go | 13 + .../model_workflowenvelopeproperties.go | 10 + .../webapps/model_workflowhealth.go | 9 + .../web/2023-12-01/webapps/predicates.go | 788 ++ .../web/2023-12-01/webapps/version.go | 12 + .../2023-12-01/workflowrunactions/README.md | 186 + .../2023-12-01/workflowrunactions/client.go | 26 + .../workflowrunactions/constants.go | 84 + .../workflowrunactions/id_action.go | 163 + .../workflowrunactions/id_action_test.go | 507 ++ .../workflowrunactions/id_repetition.go | 172 + .../workflowrunactions/id_repetition_test.go | 552 ++ .../workflowrunactions/id_requesthistory.go | 181 + .../id_requesthistory_test.go | 597 ++ .../2023-12-01/workflowrunactions/id_run.go | 154 + .../workflowrunactions/id_run_test.go | 462 ++ .../workflowrunactions/id_scoperepetition.go | 172 + .../id_scoperepetition_test.go | 552 ++ .../method_coperepetitionsget.go | 54 + .../method_coperepetitionslist.go | 91 + .../workflowrunactions/method_get.go | 54 + .../workflowrunactions/method_list.go | 123 + .../method_listexpressiontraces.go | 84 + .../method_workflowrunactionrepetitionsget.go | 54 + ...method_workflowrunactionrepetitionslist.go | 91 + ...unactionrepetitionslistexpressiontraces.go | 84 + ...runactionrepetitionsrequesthistoriesget.go | 54 + ...unactionrepetitionsrequesthistorieslist.go | 91 + .../workflowrunactions/model_contenthash.go | 9 + .../workflowrunactions/model_contentlink.go | 12 + .../model_errorproperties.go | 9 + .../workflowrunactions/model_errorresponse.go | 8 + .../model_repetitionindex.go | 9 + .../workflowrunactions/model_request.go | 10 + .../model_requesthistory.go | 13 + .../model_requesthistoryproperties.go | 41 + .../workflowrunactions/model_response.go | 10 + .../workflowrunactions/model_retryhistory.go | 43 + .../model_runactioncorrelation.go | 10 + .../model_workflowrunaction.go | 11 + .../model_workflowrunactionproperties.go | 48 + ...l_workflowrunactionrepetitiondefinition.go | 13 + ...l_workflowrunactionrepetitionproperties.go | 52 + .../workflowrunactions/predicates.go | 83 + .../2023-12-01/workflowrunactions/version.go | 12 + .../web/2023-12-01/workflowruns/README.md | 69 + .../web/2023-12-01/workflowruns/client.go | 26 + .../web/2023-12-01/workflowruns/constants.go | 146 + .../workflowruns/id_managementworkflow.go | 145 + .../id_managementworkflow_test.go | 417 + .../web/2023-12-01/workflowruns/id_run.go | 154 + .../2023-12-01/workflowruns/id_run_test.go | 462 ++ .../2023-12-01/workflowruns/method_cancel.go | 47 + .../web/2023-12-01/workflowruns/method_get.go | 54 + .../2023-12-01/workflowruns/method_list.go | 123 + .../workflowruns/model_contenthash.go | 9 + .../workflowruns/model_contentlink.go | 12 + .../workflowruns/model_correlation.go | 8 + .../workflowruns/model_resourcereference.go | 10 + .../model_workflowoutputparameter.go | 12 + .../workflowruns/model_workflowrun.go | 11 + .../model_workflowrunproperties.go | 61 + .../workflowruns/model_workflowruntrigger.go | 63 + .../web/2023-12-01/workflowruns/predicates.go | 27 + .../web/2023-12-01/workflowruns/version.go | 12 + .../web/2023-12-01/workflows/README.md | 62 + .../web/2023-12-01/workflows/client.go | 26 + .../web/2023-12-01/workflows/constants.go | 402 + .../workflows/id_managementworkflow.go | 145 + .../workflows/id_managementworkflow_test.go | 417 + .../workflows/method_regenerateaccesskey.go | 51 + .../2023-12-01/workflows/method_validate.go | 51 + .../model_flowaccesscontrolconfiguration.go | 11 + ...el_flowaccesscontrolconfigurationpolicy.go | 9 + .../workflows/model_flowendpoints.go | 9 + .../model_flowendpointsconfiguration.go | 9 + .../2023-12-01/workflows/model_ipaddress.go | 8 + .../workflows/model_ipaddressrange.go | 8 + .../model_openauthenticationaccesspolicies.go | 8 + .../model_openauthenticationaccesspolicy.go | 9 + .../model_openauthenticationpolicyclaim.go | 9 + .../model_regenerateactionparameter.go | 8 + .../workflows/model_resourcereference.go | 10 + .../2023-12-01/workflows/model_workflow.go | 18 + .../workflows/model_workflowparameter.go | 11 + .../workflows/model_workflowproperties.go | 51 + .../2023-12-01/workflows/model_workflowsku.go | 9 + .../web/2023-12-01/workflows/version.go | 12 + .../workflowtriggerhistories/README.md | 65 + .../workflowtriggerhistories/client.go | 26 + .../workflowtriggerhistories/constants.go | 84 + .../workflowtriggerhistories/id_trigger.go | 154 + .../id_trigger_test.go | 462 ++ .../id_triggerhistory.go | 163 + .../id_triggerhistory_test.go | 507 ++ .../workflowtriggerhistories/method_get.go | 54 + .../workflowtriggerhistories/method_list.go | 123 + .../method_resubmit.go | 69 + .../model_contenthash.go | 9 + .../model_contentlink.go | 12 + .../model_correlation.go | 8 + .../model_resourcereference.go | 10 + .../model_workflowtriggerhistory.go | 11 + .../model_workflowtriggerhistoryproperties.go | 61 + .../workflowtriggerhistories/predicates.go | 27 + .../workflowtriggerhistories/version.go | 12 + .../web/2023-12-01/workflowtriggers/README.md | 97 + .../web/2023-12-01/workflowtriggers/client.go | 26 + .../2023-12-01/workflowtriggers/constants.go | 397 + .../workflowtriggers/id_managementworkflow.go | 145 + .../id_managementworkflow_test.go | 417 + .../2023-12-01/workflowtriggers/id_trigger.go | 154 + .../workflowtriggers/id_trigger_test.go | 462 ++ .../2023-12-01/workflowtriggers/method_get.go | 54 + .../workflowtriggers/method_getschemajson.go | 55 + .../workflowtriggers/method_list.go | 123 + .../method_listcallbackurl.go | 55 + .../2023-12-01/workflowtriggers/method_run.go | 70 + .../workflowtriggers/model_jsonschema.go | 9 + .../model_recurrenceschedule.go | 12 + .../model_recurrencescheduleoccurrence.go | 9 + .../model_resourcereference.go | 10 + .../workflowtriggers/model_workflowtrigger.go | 11 + .../model_workflowtriggercallbackurl.go | 13 + ...l_workflowtriggerlistcallbackurlqueries.go | 12 + .../model_workflowtriggerproperties.go | 70 + .../model_workflowtriggerrecurrence.go | 13 + .../2023-12-01/workflowtriggers/predicates.go | 27 + .../2023-12-01/workflowtriggers/version.go | 12 + .../web/2023-12-01/workflowversions/README.md | 53 + .../web/2023-12-01/workflowversions/client.go | 26 + .../2023-12-01/workflowversions/constants.go | 317 + .../workflowversions/id_managementworkflow.go | 145 + .../id_managementworkflow_test.go | 417 + .../2023-12-01/workflowversions/id_version.go | 154 + .../workflowversions/id_version_test.go | 462 ++ .../2023-12-01/workflowversions/method_get.go | 54 + .../workflowversions/method_list.go | 119 + .../model_flowaccesscontrolconfiguration.go | 11 + ...el_flowaccesscontrolconfigurationpolicy.go | 9 + .../workflowversions/model_flowendpoints.go | 9 + .../model_flowendpointsconfiguration.go | 9 + .../workflowversions/model_ipaddress.go | 8 + .../workflowversions/model_ipaddressrange.go | 8 + .../model_openauthenticationaccesspolicies.go | 8 + .../model_openauthenticationaccesspolicy.go | 9 + .../model_openauthenticationpolicyclaim.go | 9 + .../model_resourcereference.go | 10 + .../model_workflowparameter.go | 11 + .../workflowversions/model_workflowsku.go | 9 + .../workflowversions/model_workflowversion.go | 13 + .../model_workflowversionproperties.go | 49 + .../2023-12-01/workflowversions/predicates.go | 32 + .../2023-12-01/workflowversions/version.go | 12 + 4115 files changed, 312069 insertions(+), 218 deletions(-) create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/README.md create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/client.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location_test.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofile.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofileproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/availableworkloadprofiles/version.go create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/README.md create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/client.go create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/id_location.go create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/id_location_test.go create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeter.go create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/model_billingmetercollection.go create mode 100644 resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeterproperties.go rename resource-manager/{eventhub/2024-01-01/eventhubsclustersupgrade => containerapps/2024-03-01/billingmeters}/version.go (54%) create mode 100644 resource-manager/containerapps/2024-03-01/certificates/README.md create mode 100644 resource-manager/containerapps/2024-03-01/certificates/client.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_certificate.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_certificate_test.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate_test.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/id_managedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatescreateorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesdelete.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesget.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificateslist.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_list.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/method_update.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/model_certificate.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/model_certificatepatch.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/model_certificateproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/certificates/version.go create mode 100644 resource-manager/containerapps/2024-03-01/client.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/README.md create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/client.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate_test.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatescreateorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesdelete.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesget.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificateslist.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_checknameavailability.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbyresourcegroup.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbysubscription.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/method_update.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificate.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificatepatch.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificateproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityrequest.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityresponse.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironmentproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_customdomainconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/model_extendedlocation.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironments/version.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/README.md create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/client.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage_test.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_list.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_azurefileproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorage.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorageproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstoragescollection.go create mode 100644 resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/version.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/README.md create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/client.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/id_containerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/id_containerapp_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/id_containerappdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/id_containerappdetector_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/id_revisionsapirevision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/id_revisionsapirevision_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetrevision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetroot.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistdetectors.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistrevisions.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_getauthtoken.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_listbyresourcegroup.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_listbysubscription.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_listcustomhostnameanalysis.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_listsecrets.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_start.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_stop.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/method_update.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_basecontainer.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_configuration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_container.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtoken.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtokenproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobe.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpget.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpgethttpheadersinlined.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobetcpsocket.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerappsecret.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_containerresources.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_corspolicy.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_customdomain.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresult.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfo.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_customscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_dapr.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadata.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadatapropertybaginlined.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponsecolumn.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponseobject.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticrendering.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnostics.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdataapiresponse.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdefinition.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsstatus.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsupporttopic.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_environmentvar.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_extendedlocation.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_httpscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_ingress.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_ingressportmapping.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_ingressstickysessions.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_ipsecurityrestrictionrule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_queuescalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_registrycredentials.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_revision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_revisionproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_scale.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_scalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_scaleruleauth.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_secret.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_secretscollection.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_secretvolumeitem.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_service.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_servicebind.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_tcpscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_template.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_trafficweight.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_volume.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/model_volumemount.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/containerapps/version.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/README.md rename resource-manager/{eventhub/2024-01-01/eventhubsclustersupgrade => containerapps/2024-03-01/containerappsauthconfigs}/client.go (57%) create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_listbycontainerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedaudiencesvalidation.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedprincipals.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_apple.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appleregistration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appregistration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfigproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authplatform.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectory.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectorylogin.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryregistration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryvalidation.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebapps.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebappsregistration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_blobstoragetokenstore.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_clientregistration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_cookieexpiration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_customopenidconnectprovider.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_defaultauthorizationpolicy.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_encryptionsettings.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_facebook.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_forwardproxy.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_github.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_globalvalidation.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_google.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettings.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettingsroutes.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_identityproviders.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_jwtclaimchecks.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_login.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginroutes.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginscopes.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_nonce.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectclientcredential.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectlogin.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectregistration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_tokenstore.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitter.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitterregistration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsauthconfigs/version.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/README.md create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/client.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/method_getreplica.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/method_listreplicas.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replica.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacollection.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacontainer.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicaproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/version.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/README.md create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/client.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/id_revision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/id_revision_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/method_activaterevision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/method_deactivaterevision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/method_getrevision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/method_listrevisions.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/method_restartrevision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_basecontainer.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_container.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobe.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpget.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpgethttpheadersinlined.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobetcpsocket.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerresources.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_customscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_environmentvar.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_httpscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_queuescalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revision.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revisionproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scale.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scaleruleauth.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_secretvolumeitem.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_servicebind.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_tcpscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_template.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volume.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volumemount.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappsrevisions/version.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/README.md create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/client.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol_test.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_listbycontainerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_azurecredentials.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_githubactionconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_registryinfo.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrol.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrolproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/containerappssourcecontrols/version.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/README.md create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/client.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent_test.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_daprcomponent.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_daprcomponent_test.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/id_managedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentscreateorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsdelete.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsget.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslist.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslistsecrets.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_list.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/method_listsecrets.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponent.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponentproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/model_daprmetadata.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecret.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecretscollection.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/model_secret.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/daprcomponents/version.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/README.md create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/client.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp_test.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_containerappdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_containerappdetector_test.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_detector.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_detector_test.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_detectorproperty.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_detectorproperty_test.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_job.go rename resource-manager/{eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster_test.go => containerapps/2024-03-01/diagnostics/id_job_test.go} (72%) create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector_test.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_revisionsapirevision.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/id_revisionsapirevision_test.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetrevision.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetroot.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistdetectors.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistrevisions.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_jobsgetdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_jobslistdetectors.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_jobsproxyget.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticsgetdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticslistdetectors.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentsdiagnosticsgetroot.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_applogsconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_basecontainer.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_configuration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_container.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_containerapp.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobe.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpget.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpgethttpheadersinlined.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobetcpsocket.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_containerappproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_containerresources.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_corspolicy.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_customdomain.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_customdomainconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_customscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_dapr.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_daprconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadata.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadatapropertybaginlined.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponsecolumn.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponseobject.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticrendering.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnostics.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdataapiresponse.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdefinition.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsstatus.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsupporttopic.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_environmentvar.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_extendedlocation.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_httpscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_ingress.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_ingressportmapping.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_ingressstickysessions.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_ipsecurityrestrictionrule.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_job.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationeventtriggerconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationmanualtriggerconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationscheduletriggerconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobscale.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_jobtemplate.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_kedaconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_loganalyticsconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeerauthentication.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_mtls.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_queuescalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_registrycredentials.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_revision.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_revisionproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_scale.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_scalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_scaleruleauth.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_secret.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_secretvolumeitem.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_service.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_servicebind.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_tcpscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_template.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_trafficweight.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_vnetconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_volume.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_volumemount.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/model_workloadprofile.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/diagnostics/version.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/README.md create mode 100644 resource-manager/containerapps/2024-03-01/jobs/client.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_detector.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_detector_test.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_detectorproperty.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_detectorproperty_test.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_execution.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_execution_test.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_job.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/id_job_test.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_executionslist.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_getdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_jobexecution.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_listbyresourcegroup.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_listbysubscription.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_listdetectors.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_listsecrets.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_proxyget.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_start.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_stopexecution.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_stopmultipleexecutions.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/method_update.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_basecontainer.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_container.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_containerappprobe.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpget.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpgethttpheadersinlined.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_containerappprobetcpsocket.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_containerresources.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadata.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadatapropertybaginlined.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponsecolumn.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponseobject.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticrendering.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnostics.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdataapiresponse.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdefinition.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsstatus.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsupporttopic.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_environmentvar.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_job.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationeventtriggerconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationmanualtriggerconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationscheduletriggerconfig.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobexecution.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionbase.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobexecutioncontainer.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobexecutiontemplate.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobpatchproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobpatchpropertiesproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobscale.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobscalerule.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobsecretscollection.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_jobtemplate.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_registrycredentials.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_scaleruleauth.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_secret.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_secretvolumeitem.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_volume.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/model_volumemount.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/jobs/version.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/README.md create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/client.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/id_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/id_managedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/method_list.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/method_update.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificatepatch.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificateproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/managedcertificates/version.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/README.md create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/client.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatescreateorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesdelete.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesget.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_certificateslist.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_diagnosticsgetroot.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_getauthtoken.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_listbyresourcegroup.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_listbysubscription.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_listworkloadprofilestates.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatescreateorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesdelete.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesget.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificateslist.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticsgetdetector.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticslistdetectors.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_namespaceschecknameavailability.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/method_update.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_applogsconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_certificate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_certificatepatch.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_certificateproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityrequest.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityresponse.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_customdomainconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_daprconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadata.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadatapropertybaginlined.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponsecolumn.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponseobject.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticrendering.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnostics.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdataapiresponse.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdefinition.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsstatus.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsupporttopic.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtoken.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtokenproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_kedaconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_loganalyticsconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificatepatch.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificateproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeerauthentication.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_mtls.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_vnetconfiguration.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofile.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestates.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestatesproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironments/version.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/README.md create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/client.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_storage.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_storage_test.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_createorupdate.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_delete.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_get.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_list.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_azurefileproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorage.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorageproperties.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstoragescollection.go create mode 100644 resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/version.go create mode 100644 resource-manager/containerapps/2024-03-01/subscriptions/client.go create mode 100644 resource-manager/containerapps/2024-03-01/subscriptions/method_getcustomdomainverificationid.go create mode 100644 resource-manager/containerapps/2024-03-01/subscriptions/version.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/README.md create mode 100644 resource-manager/containerapps/2024-03-01/usages/client.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/constants.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/id_location.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/id_location_test.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/id_managedenvironment.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/id_managedenvironment_test.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/method_list.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/method_managedenvironmentusageslist.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/model_usage.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/model_usagename.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/predicates.go create mode 100644 resource-manager/containerapps/2024-03-01/usages/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/id_operationid.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/id_operationid_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/method_exportjobsoperationresultget.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/method_exportjobstrigger.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/method_jobsget.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjob.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjobresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_exportjobsresult.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_innererror.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobextendedinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobsubtask.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_restorejobrecoverypointdetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingerror.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingwarningdetail.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjob/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/method_jobslist.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjob.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjobresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_innererror.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobextendedinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobsubtask.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_restorejobrecoverypointdetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingerror.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingwarningdetail.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/azurebackupjobs/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/id_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/id_backupvault_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/id_providerlocation.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/id_providerlocation_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_adhocbackup.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_createorupdate.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_delete.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_get.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_list.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_resumebackups.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_resumeprotection.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_stopprotection.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_suspendbackups.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_syncbackupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_triggercrossregionrestore.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrehydrate.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrestore.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_validatecrossregionrestore.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforbackup.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforrestore.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackupruleoptions.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackuptriggeroption.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_authcredentials.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverypointbasedrestorerequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverytimebasedrestorerequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprehydrationrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorerequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorewithrehydrationrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_azureoperationalstoreparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_backupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstanceresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_baseresourceproperties.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_blobbackupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestoredetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestorerequestobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_datasource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_datasourceset.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_datastoreparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_defaultresourceproperties.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_identitydetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_innererror.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestorecriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestoretargetinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_itempathbasedrestorecriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterbackupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterrestorecriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclustervaulttierrestorecriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetespvrestorecriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesstorageclassrestorecriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_namespacednameresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_operationextendedinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_operationjobextendedinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_policyinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_policyparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_protectionstatusdetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_rangebaseditemlevelrestorecriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_restorefilestargetinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfobase.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstorebasedauthcredentials.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstoreresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_stopprotectionrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_suspendbackuprequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_syncbackupinstancerequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_targetdetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_triggerbackuprequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_userfacingerror.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_validatecrossregionrestorerequestobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_validateforbackuprequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/model_validaterestorerequestobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstances/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/method_list.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_authcredentials.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_azureoperationalstoreparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstanceresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_baseresourceproperties.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_blobbackupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasourceset.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datastoreparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_defaultresourceproperties.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_identitydetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_innererror.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_kubernetesclusterbackupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_namespacednameresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_protectionstatusdetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstorebasedauthcredentials.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstoreresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_userfacingerror.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/method_createorupdate.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/method_delete.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/method_get.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/method_list.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_absolutedeleteoption.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtaggingcriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtriggercontext.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackupparams.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackuprule.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_azureretentionrule.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupcriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_backuppolicy.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupschedule.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicy.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicyresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_basepolicyrule.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyonexpiryoption.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyoption.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_customcopyoption.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_datastoreinfobase.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_day.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_deleteoption.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_immediatecopyoption.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_retentiontag.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedbackupcriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedtriggercontext.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_sourcelifecycle.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_taggingcriteria.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_targetcopysetting.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/model_triggercontext.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/backuppolicies/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/id_providerlocation.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/id_providerlocation_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/method_checknameavailability.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/method_createorupdate.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/method_delete.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/method_get.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/method_getinresourcegroup.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/method_getinsubscription.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/method_update.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_azuremonitoralertsettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvaultresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityresult.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkekidentity.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkeyvaultproperties.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_crossregionrestoresettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_crosssubscriptionrestoresettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_dppidentitydetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_encryptionsettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_featuresettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_immutabilitysettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_monitoringsettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_patchbackupvaultinput.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_patchresourcerequestinput.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_resourcemovedetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_securitysettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_softdeletesettings.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_storagesetting.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/model_userassignedidentity.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/backupvaults/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_get.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_list.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_undelete.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_authcredentials.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_azureoperationalstoreparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_backupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_baseresourceproperties.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_blobbackupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasource.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasourceset.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datastoreparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_defaultresourceproperties.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstanceresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletioninfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_identitydetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_innererror.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_kubernetesclusterbackupdatasourceparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_namespacednameresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_protectionstatusdetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstorebasedauthcredentials.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstoreresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_userfacingerror.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/deletedbackupinstances/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/method_dataprotectioncheckfeaturesupport.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequestbase.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponse.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponsebase.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_supportedfeature.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppfeaturesupport/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobget.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobslist.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjob.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjobresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobsrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_innererror.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_jobextendedinfo.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_jobsubtask.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_restorejobrecoverypointdetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingerror.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingwarningdetail.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppjob/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxycreateorupdate.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxydelete.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyget.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxylist.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyunlockdelete.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardoperationdetail.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybase.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybaseresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleterequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleteresponse.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/method_list.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackupdiscreterecoverypoint.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypoint.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypointresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_fetchsecondaryrpsrequestparameters.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_recoverypointdatastoredetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/method_restorabletimerangesfind.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponse.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponseresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_restorabletimerange.go create mode 100644 resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/id_recoverypoint.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/id_recoverypoint_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/method_get.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/method_list.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackupdiscreterecoverypoint.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypoint.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypointresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/model_recoverypointdatastoredetails.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/recoverypoint/version.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/README.md create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/client.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/constants.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_resourceguard.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_resourceguard_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest_test.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_delete.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_get.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getbackupsecuritypinrequestsobjects.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultbackupsecuritypinrequestsobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteprotecteditemrequestsobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteresourceguardproxyrequestsobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdisablesoftdeleterequestsobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotecteditemrequestsobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotectionpolicyrequestsobject.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteprotecteditemrequestsobjects.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteresourceguardproxyrequestsobjects.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getdisablesoftdeleterequestsobjects.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinresourcegroup.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinsubscription.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotecteditemrequestsobjects.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotectionpolicyrequestsobjects.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_patch.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/method_put.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/model_dppbaseresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/model_patchresourceguardinput.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguard.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardoperation.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardresource.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/predicates.go create mode 100644 resource-manager/dataprotection/2024-04-01/resourceguards/version.go delete mode 100644 resource-manager/eventhub/2024-01-01/eventhubsclusters/model_upgradepreferences.go create mode 100644 resource-manager/recoveryservices/2024-04-01/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource.go create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/method_privatelinkresourcesget.go create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresource.go create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresourceproperties.go create mode 100644 resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/client.go rename resource-manager/{eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster.go => recoveryservices/2024-04-01/listprivatelinkresources/id_vault.go} (54%) create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/method_privatelinkresourceslist.go create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresource.go create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresourceproperties.go create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/predicates.go create mode 100644 resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/constants.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/method_capabilities.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/method_checknameavailability.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesproperties.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponse.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponseproperties.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityparameters.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityresult.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszone.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszoneresponse.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/model_resourcecapabilities.go create mode 100644 resource-manager/recoveryservices/2024-04-01/recoveryservices/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/registeredidentities/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity.go create mode 100644 resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/registeredidentities/method_delete.go create mode 100644 resource-manager/recoveryservices/2024-04-01/registeredidentities/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/method_list.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/model_jobssummary.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/model_monitoringsummary.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusage.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusagelist.go create mode 100644 resource-manager/recoveryservices/2024-04-01/replicationusages/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/constants.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/method_create.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_certificaterequest.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_rawcertificatedata.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandaaddetails.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandacsdetails.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificatedetails.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_vaultcertificateresponse.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultcertificates/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_createorupdate.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_get.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_update.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinfo.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinforesource.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/constants.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/method_createorupdate.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/method_delete.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/method_get.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/method_listbyresourcegroup.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/method_listbysubscriptionid.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/method_update.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_azuremonitoralertsettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_classicalertsettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkekidentity.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkeyvaultproperties.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_crosssubscriptionrestoresettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_immutabilitysettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_monitoringsettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_patchvault.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpoint.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnection.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnectionvaultproperties.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_restoresettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_securitysettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_sku.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_softdeletesettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_upgradedetails.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_vault.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_vaultproperties.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesencryption.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesmovedetails.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesredundancysettings.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/predicates.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaults/version.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/README.md create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/client.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/constants.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/id_vault.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/id_vault_test.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/method_usageslistbyvaults.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/model_nameinfo.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusage.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusagelist.go create mode 100644 resource-manager/recoveryservices/2024-04-01/vaultusages/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_azurebackupserverengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupengineextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_dpmbackupengine.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupengines/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestorageerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloaderrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_job.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_jobresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_maberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjoberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurefileshareprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azureiaasvmprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azuresqlprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_day.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_genericprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_hourlyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_instantrpadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_logschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_mabprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_monthlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicyresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionduration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_schedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_settings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicyv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_snapshotbackupadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_subprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_tieringpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_vaultretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_yearlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurefileshareprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_iaasvmprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_prebackupvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_diskexclusionproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_extendedproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_genericprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_kpiresourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_resourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureresourceprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintentresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_update_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azurefilesharebackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azureworkloadbackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/model_iaasvmbackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backups/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusage.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusagelist.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_nameinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmspreparedatamove_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmstriggerdatamove_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_preparedatamoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_triggerdatamoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/datamove/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_featuresupportrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/method_post_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinforequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostsavinginfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_provision_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_revoke_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestorageerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloaderrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmerrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_job.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_jobresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_maberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobtaskdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjob.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjoberrorinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjobextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobs/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobs/method_export_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/jobs/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateiaasvmrestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationsresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validaterestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/operation/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnection.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnectionresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurestorageprotectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaascomputevmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_diskexclusionproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_extendedproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_genericprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_kpiresourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditemresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_resourcehealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_inquire_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_refresh_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_register_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_unregister_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_validate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureresourceprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackuprequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackupresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintent.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintentresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_createorupdate_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurefileshareprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azuresqlprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_day.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_genericprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_hourlyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_instantrpadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_logschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_mabprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_monthlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicyresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionduration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_schedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_settings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicyv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_snapshotbackupadditionaldetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_subprotectionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_tieringpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_vaultretentionpolicy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionformat.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_yearlyretentionschedule.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/method_moverecoverypoint_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/model_moverpacrosstiersrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azurefilesharerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_bekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_diskinformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_genericrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_iaasvmrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_kekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_keyandsecretdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_pointintimerange.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointdiskconfiguration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointmovereadinessinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointtierinformationv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/method_list_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_bekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_diskinformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_kekdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_pointintimerange.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_sqldatadirectory.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardoperationdetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_delete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_put_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_unlockdelete_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardoperationdetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybaseresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleteresponse.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/restores/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/method_get_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_securitypinbase.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_tokeninformation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/securitypins/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurebackupservercontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurestoragecontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_containeridentityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_distributednodesinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_errordetail.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_iaasvmcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryvalidation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerextendedinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerhealthdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainer.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainerresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_workloadinquirydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/predicates.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/version.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/README.md create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/client.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/constants.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault_test.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/method_trigger_autorest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azurefilesharerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_encryptiondetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_extendedlocation.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identitybasedrestoredetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identityinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_recoverypointrehydrationinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorefilespecs.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorerequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_securedvmdetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_snapshotrestoreparameters.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_sqldatadirectorymapping.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetafsrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetdisknetworkaccesssettings.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetrestoreinfo.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedidentityproperties.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedmanagedidentitydetails.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequestresource.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validaterestoreoperationrequest.go create mode 100644 resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/constants.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_createorupdate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_delete.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_list.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_readupgrade.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_resumeupgrade.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_startrollback.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_update.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationhealthpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresource.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresourceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupdateparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupgradepolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationuserassignedidentity.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_rollingupgrademonitoringpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_runtimeresumeapplicationupgradeparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_servicetypehealthpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_systemdata.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/predicates.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/application/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_createorupdate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_delete.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_list.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_update.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesource.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesourceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtypeupdateparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_systemdata.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/predicates.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_createorupdate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_delete.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_listbyapplicationtypes.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_update.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresource.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresourceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionupdateparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_systemdata.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/predicates.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/method_post.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_managedazresiliencystatus.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_resourceazstatus.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/constants.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_createorupdate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_delete.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbyresourcegroup.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbysubscription.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_update.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_applicationtypeversionscleanuppolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_azureactivedirectory.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clientcertificate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterhealthpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clustermonitoringpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradedeltahealthpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradepolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_iptag.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_loadbalancingrule.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterupdateparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_networksecurityrule.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_serviceendpoint.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingsparameterdescription.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingssectiondescription.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_sku.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_subnet.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_systemdata.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/predicates.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/constants.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_getbyenvironment.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_list.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_listbyenvironment.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclustercodeversionresult.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclusterversiondetails.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/model_managedmaintenancewindowstatus.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizesget.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizeslist.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_managedvmsize.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_vmsize.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/predicates.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/constants.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_createorupdate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_delete.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_deletenode.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_listbymanagedclusters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_reimage.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_restart.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_skuslist.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_update.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_additionalnetworkinterfaceconfiguration.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_endpointrangedescription.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_frontendconfiguration.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfiguration.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfigurationpublicipaddressconfiguration.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_iptag.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_networksecurityrule.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetype.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeactionparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeavailablesku.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypenatconfig.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesku.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeskucapacity.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesupportedsku.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeupdateparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_subresource.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_systemdata.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultcertificate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultsecretgroup.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmimageplan.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssdatadisk.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextension.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextensionproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/predicates.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/constants.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_service.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_service_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_createorupdate.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_delete.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_get.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_listbyapplications.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_addremoveincrementalnamedpartitionscalingmechanism.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averagepartitionloadscalingtrigger.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averageserviceloadscalingtrigger.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_namedpartitionscheme.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partition.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partitioninstancecountscalemechanism.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingmechanism.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingtrigger.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_servicecorrelation.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceloadmetric.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementinvaliddomainpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementnonpartiallyplaceservicepolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpreferprimarydomainpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequireddomainpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequiredomaindistributionpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresource.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresourceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_singletonpartitionscheme.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statefulserviceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statelessserviceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_systemdata.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_uniformint64rangepartitionscheme.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/predicates.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/service/version.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/README.md create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/client.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/constants.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service_test.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/method_update.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_addremoveincrementalnamedpartitionscalingmechanism.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averagepartitionloadscalingtrigger.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averageserviceloadscalingtrigger.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_namedpartitionscheme.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partition.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partitioninstancecountscalemechanism.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingmechanism.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingtrigger.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_servicecorrelation.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceloadmetric.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementinvaliddomainpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementnonpartiallyplaceservicepolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpreferprimarydomainpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequireddomainpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequiredomaindistributionpolicy.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresource.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresourceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceupdateparameters.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_singletonpartitionscheme.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statefulserviceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statelessserviceproperties.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_systemdata.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_uniformint64rangepartitionscheme.go create mode 100644 resource-manager/servicefabricmanagedcluster/2024-04-01/services/version.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/README.md create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/client.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/constants.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener_test.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup_test.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_createorupdate.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_delete.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_get.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_listbygroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agconfiguration.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agreplica.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistener.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistenerproperties.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_loadbalancerconfiguration.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_multisubnetipconfiguration.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_privateipaddress.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/predicates.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/version.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/client.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/README.md create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/client.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/constants.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup_test.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_createorupdate.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_delete.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_get.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_list.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_listbyresourcegroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_update.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupproperties.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupupdate.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_wsfcdomainprofile.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/predicates.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/version.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/README.md create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/client.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/constants.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine_test.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup_test.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_createorupdate.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_delete.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_fetchdcassessment.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_get.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_list.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbyresourcegroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbysqlvmgroup.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_redeploy.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_startassessment.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_update.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_aadauthenticationsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_additionalfeaturesserverconfigurations.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_assessmentsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autobackupsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autopatchingsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_diskconfigassessmentrequest.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_keyvaultcredentialsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_resourceidentity.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_schedule.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_serverconfigurationsmanagementsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlconnectivityupdatesettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlinstancesettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstoragesettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstorageupdatesettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqltempdbsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachine.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineproperties.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineupdate.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlworkloadtypeupdatesettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_storageconfigurationsettings.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingadditionalproperties.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingstatus.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_unhealthyreplicainfo.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_virtualmachineidentity.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_wsfcdomaincredentials.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/predicates.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/version.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/README.md create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/client.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/constants.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine_test.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/method_troubleshoot.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_sqlvmtroubleshooting.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_troubleshootingadditionalproperties.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_unhealthyreplicainfo.go create mode 100644 resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/version.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/README.md create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/client.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/constants.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate_test.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder_test.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_delete.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_deletecertificate.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_get.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_getcertificate.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_list.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_listcertificates.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_reissue.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_renew.go rename resource-manager/{eventhub/2024-01-01/eventhubsclustersupgrade/method_clusterstriggerupgradepost.go => web/2023-12-01/appservicecertificateorders/method_resendemail.go} (69%) create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_resendrequestemails.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_update.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_updatecertificate.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/method_verifydomainownership.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificate.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_certificatedetails.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateemail.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateorderaction.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateordercontact.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_nameidentifier.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_siteseal.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/model_sitesealrequest.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/predicates.go create mode 100644 resource-manager/web/2023-12-01/appservicecertificateorders/version.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/README.md create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/client.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/constants.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_workerpool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_workerpool_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_workerpoolinstance.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/id_workerpoolinstance_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_changevnet.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdatemultirolepool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdateworkerpool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_delete.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_deleteprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_get.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getasev3networkingconfiguration.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getdiagnosticsitem.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getmultirolepool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnectionlist.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getprivatelinkresources.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getvipinfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_getworkerpool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_list.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listappserviceplans.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listcapacities.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listdiagnostics.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolemetricdefinitions.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepools.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolskus.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listmultiroleusages.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listoperations.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listusages.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listwebapps.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkermetricdefinitions.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkerusages.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpools.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolskus.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_reboot.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_resume.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_suspend.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_testupgradeavailablenotification.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_update.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_updateasenetworkingconfiguration.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_updatemultirolepool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_updateworkerpool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/method_upgrade.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponse.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponseproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_apidefinitioninfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_apimanagementconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironment.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentresource.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplan.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplanproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_armidwrapper.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfiguration.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_autohealactions.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_autohealcustomaction.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_autohealrules.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_autohealtriggers.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_azurestorageinfovalue.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_capability.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_cloninginfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_connstringinfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_corssettings.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_csmusagequota.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfiguration.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_daprconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdependency.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdetail.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_errorentity.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_experiments.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_extendedlocation.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionappconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsalwaysreadyconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeployment.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorage.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsruntime.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrency.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_handlermapping.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentprofile.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_hostnamesslstate.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_inboundenvironmentendpoint.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_ipsecurityrestriction.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_kubeenvironmentprofile.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_localizablestring.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_namevaluepair.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_operation.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_outboundenvironmentendpoint.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkconnectionstate.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresource.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceswrapper.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettings.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettingsproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_rampuprule.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_requestsbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_resourceconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricavailability.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinition.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_site.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_siteconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_sitednsconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_sitelimits.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_sitemachinekey.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_skucapacity.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_skudescription.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_skuinfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_slotswapstatus.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_slowrequestsbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_stampcapacity.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_usage.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_usageproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_virtualapplication.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_virtualdirectory.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_virtualipmapping.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_virtualnetworkprofile.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_workerpool.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/model_workerpoolresource.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/predicates.go create mode 100644 resource-manager/web/2023-12-01/appserviceenvironments/version.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/README.md create mode 100644 resource-manager/web/2023-12-01/appserviceplans/client.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/constants.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_route.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_route_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_worker.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/id_worker_test.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_createorupdatevnetroute.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_delete.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_deletehybridconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_deletevnetroute.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_get.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnectionplanlimit.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_getrouteforvnet.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_getserverfarmskus.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_getvnetfromserverfarm.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_getvnetgateway.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_list.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listcapabilities.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnectionkeys.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnections.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listroutesforvnet.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listusages.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listvnets.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listwebapps.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_listwebappsbyhybridconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_rebootworker.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_restartwebapps.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_update.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_updatevnetgateway.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/method_updatevnetroute.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_apidefinitioninfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_apimanagementconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_appserviceplan.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresource.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_autohealactions.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_autohealcustomaction.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_autohealrules.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_autohealtriggers.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_azurestorageinfovalue.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_capability.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_cloninginfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_connstringinfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_corssettings.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_csmusagequota.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_daprconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_experiments.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_extendedlocation.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionappconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsalwaysreadyconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsdeployment.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorage.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorageauthentication.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsruntime.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrency.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_handlermapping.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hostingenvironmentprofile.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hostnamesslstate.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hybridconnection.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkey.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkeyproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimits.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimitsproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_ipsecurityrestriction.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_kubeenvironmentprofile.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_localizablestring.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_namevaluepair.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_pushsettings.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_pushsettingsproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_rampuprule.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_requestsbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_resourceconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_site.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_siteconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_sitednsconfig.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_sitelimits.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_sitemachinekey.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_skucapacity.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_skudescription.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_slotswapstatus.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_slowrequestsbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_statuscodesbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_statuscodesrangebasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_virtualapplication.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_virtualdirectory.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_vnetgateway.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_vnetgatewayproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_vnetinfo.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_vnetinforesource.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_vnetroute.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/model_vnetrouteproperties.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/predicates.go create mode 100644 resource-manager/web/2023-12-01/appserviceplans/version.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/README.md create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/client.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/constants.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder_test.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/id_detector.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/id_detector_test.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_dataprovidermetadata.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponsecolumn.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponseobject.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorinfo.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponse.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponseproperties.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_diagnosticdata.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresult.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresults.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_rendering.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_sampleutterance.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_status.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/model_supporttopic.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/predicates.go create mode 100644 resource-manager/web/2023-12-01/certificateordersdiagnostics/version.go create mode 100644 resource-manager/web/2023-12-01/certificates/README.md create mode 100644 resource-manager/web/2023-12-01/certificates/client.go create mode 100644 resource-manager/web/2023-12-01/certificates/constants.go create mode 100644 resource-manager/web/2023-12-01/certificates/id_certificate.go create mode 100644 resource-manager/web/2023-12-01/certificates/id_certificate_test.go create mode 100644 resource-manager/web/2023-12-01/certificates/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/certificates/method_delete.go create mode 100644 resource-manager/web/2023-12-01/certificates/method_get.go create mode 100644 resource-manager/web/2023-12-01/certificates/method_list.go create mode 100644 resource-manager/web/2023-12-01/certificates/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/certificates/method_update.go create mode 100644 resource-manager/web/2023-12-01/certificates/model_certificate.go create mode 100644 resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go create mode 100644 resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/certificates/model_certificateproperties.go create mode 100644 resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go create mode 100644 resource-manager/web/2023-12-01/certificates/predicates.go create mode 100644 resource-manager/web/2023-12-01/certificates/version.go create mode 100644 resource-manager/web/2023-12-01/client.go create mode 100644 resource-manager/web/2023-12-01/containerapps/README.md create mode 100644 resource-manager/web/2023-12-01/containerapps/client.go create mode 100644 resource-manager/web/2023-12-01/containerapps/constants.go create mode 100644 resource-manager/web/2023-12-01/containerapps/id_containerapp.go create mode 100644 resource-manager/web/2023-12-01/containerapps/id_containerapp_test.go create mode 100644 resource-manager/web/2023-12-01/containerapps/id_providercontainerapp.go create mode 100644 resource-manager/web/2023-12-01/containerapps/id_providercontainerapp_test.go create mode 100644 resource-manager/web/2023-12-01/containerapps/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/containerapps/method_delete.go create mode 100644 resource-manager/web/2023-12-01/containerapps/method_get.go create mode 100644 resource-manager/web/2023-12-01/containerapps/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/containerapps/method_listbysubscription.go create mode 100644 resource-manager/web/2023-12-01/containerapps/method_listsecrets.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_configuration.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_container.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_containerapp.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_containerappproperties.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_containerappsecret.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_containerresources.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_customscalerule.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_dapr.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_daprcomponent.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_daprmetadata.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_environmentvar.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_httpscalerule.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_ingress.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_queuescalerule.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_registrycredentials.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_scale.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_scalerule.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_scaleruleauth.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_secret.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_secretscollection.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_template.go create mode 100644 resource-manager/web/2023-12-01/containerapps/model_trafficweight.go create mode 100644 resource-manager/web/2023-12-01/containerapps/predicates.go create mode 100644 resource-manager/web/2023-12-01/containerapps/version.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/README.md create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/client.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/constants.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp_test.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/id_revision.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/id_revision_test.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/method_activaterevision.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/method_deactivaterevision.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/method_getrevision.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/method_listrevisions.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/method_restartrevision.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_container.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_containerresources.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_customscalerule.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_dapr.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_daprcomponent.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_daprmetadata.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_environmentvar.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_httpscalerule.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_queuescalerule.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_revision.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_revisionproperties.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_scale.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_scalerule.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_scaleruleauth.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/model_template.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/predicates.go create mode 100644 resource-manager/web/2023-12-01/containerappsrevisions/version.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/README.md create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/client.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite_test.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/id_providerlocation.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/id_providerlocation_test.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/method_getdeletedwebappbylocation.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/method_list.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/method_listbylocation.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/model_deletedsite.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/model_deletedsiteproperties.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/predicates.go create mode 100644 resource-manager/web/2023-12-01/deletedwebapps/version.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/README.md create mode 100644 resource-manager/web/2023-12-01/diagnostics/client.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/constants.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_analysis.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_analysis_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_detector.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_detector_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_diagnostic.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_diagnostic_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_diagnosticanalysis.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_diagnosticanalysis_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_diagnosticdetector.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_diagnosticdetector_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_hostingenvironmentdetector.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_hostingenvironmentdetector_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slot_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slotdetector.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slotdetector_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slotdiagnostic.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slotdiagnostic_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slotdiagnosticdetector.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/id_slotdiagnosticdetector_test.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_executesiteanalysis.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_executesiteanalysisslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_executesitedetector.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_executesitedetectorslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_gethostingenvironmentdetectorresponse.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysis.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysisslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsitedetector.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponse.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponseslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategory.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategoryslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listhostingenvironmentdetectorresponses.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsiteanalyses.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsiteanalysesslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponses.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponsesslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsitedetectors.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorsslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategories.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategoriesslot.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_abnormaltimeperiod.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_analysisdata.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_analysisdefinition.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_analysisdefinitionproperties.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_dataprovidermetadata.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_datasource.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_datatableresponsecolumn.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_datatableresponseobject.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_detectorabnormaltimeperiod.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_detectordefinition.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_detectordefinitionresource.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_detectorinfo.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_detectorresponse.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_detectorresponseproperties.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysis.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysisproperties.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategory.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategoryproperties.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticdata.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponse.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponseproperties.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricsample.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricset.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_keyvaluepairstringobject.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_namevaluepair.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresult.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresults.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_rendering.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_responsemetadata.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_sampleutterance.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_solution.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_status.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/model_supporttopic.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/predicates.go create mode 100644 resource-manager/web/2023-12-01/diagnostics/version.go create mode 100644 resource-manager/web/2023-12-01/domains/README.md create mode 100644 resource-manager/web/2023-12-01/domains/client.go create mode 100644 resource-manager/web/2023-12-01/domains/constants.go create mode 100644 resource-manager/web/2023-12-01/domains/id_domain.go create mode 100644 resource-manager/web/2023-12-01/domains/id_domain_test.go create mode 100644 resource-manager/web/2023-12-01/domains/id_domainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/domains/id_domainownershipidentifier_test.go create mode 100644 resource-manager/web/2023-12-01/domains/method_checkavailability.go create mode 100644 resource-manager/web/2023-12-01/domains/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/domains/method_createorupdateownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/domains/method_delete.go create mode 100644 resource-manager/web/2023-12-01/domains/method_deleteownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/domains/method_get.go create mode 100644 resource-manager/web/2023-12-01/domains/method_getcontrolcenterssorequest.go create mode 100644 resource-manager/web/2023-12-01/domains/method_getownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/domains/method_list.go create mode 100644 resource-manager/web/2023-12-01/domains/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/domains/method_listownershipidentifiers.go create mode 100644 resource-manager/web/2023-12-01/domains/method_listrecommendations.go create mode 100644 resource-manager/web/2023-12-01/domains/method_renew.go create mode 100644 resource-manager/web/2023-12-01/domains/method_transferout.go create mode 100644 resource-manager/web/2023-12-01/domains/method_update.go create mode 100644 resource-manager/web/2023-12-01/domains/method_updateownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/domains/model_address.go create mode 100644 resource-manager/web/2023-12-01/domains/model_contact.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domain.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainavailabilitycheckresult.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domaincontrolcenterssorequest.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainownershipidentifierproperties.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainpatchresource.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainpatchresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainproperties.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainpurchaseconsent.go create mode 100644 resource-manager/web/2023-12-01/domains/model_domainrecommendationsearchparameters.go create mode 100644 resource-manager/web/2023-12-01/domains/model_hostname.go create mode 100644 resource-manager/web/2023-12-01/domains/model_nameidentifier.go create mode 100644 resource-manager/web/2023-12-01/domains/predicates.go create mode 100644 resource-manager/web/2023-12-01/domains/version.go create mode 100644 resource-manager/web/2023-12-01/global/README.md create mode 100644 resource-manager/web/2023-12-01/global/client.go create mode 100644 resource-manager/web/2023-12-01/global/id_deletedsite.go create mode 100644 resource-manager/web/2023-12-01/global/id_deletedsite_test.go create mode 100644 resource-manager/web/2023-12-01/global/method_getdeletedwebapp.go create mode 100644 resource-manager/web/2023-12-01/global/method_getdeletedwebappsnapshots.go create mode 100644 resource-manager/web/2023-12-01/global/model_deletedsite.go create mode 100644 resource-manager/web/2023-12-01/global/model_deletedsiteproperties.go create mode 100644 resource-manager/web/2023-12-01/global/model_snapshot.go create mode 100644 resource-manager/web/2023-12-01/global/model_snapshotproperties.go create mode 100644 resource-manager/web/2023-12-01/global/version.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/README.md create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/client.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/constants.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment_test.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/method_delete.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/method_get.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/method_listbysubscription.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/method_update.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_applogsconfiguration.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_arcconfiguration.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_containerappsconfiguration.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_extendedlocation.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_frontendconfiguration.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironment.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresource.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentproperties.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/model_loganalyticsconfiguration.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/predicates.go create mode 100644 resource-manager/web/2023-12-01/kubeenvironments/version.go create mode 100644 resource-manager/web/2023-12-01/provider/README.md create mode 100644 resource-manager/web/2023-12-01/provider/client.go create mode 100644 resource-manager/web/2023-12-01/provider/constants.go create mode 100644 resource-manager/web/2023-12-01/provider/id_location.go create mode 100644 resource-manager/web/2023-12-01/provider/id_location_test.go create mode 100644 resource-manager/web/2023-12-01/provider/method_getavailablestacks.go create mode 100644 resource-manager/web/2023-12-01/provider/method_getavailablestacksonprem.go create mode 100644 resource-manager/web/2023-12-01/provider/method_getfunctionappstacks.go create mode 100644 resource-manager/web/2023-12-01/provider/method_getfunctionappstacksforlocation.go create mode 100644 resource-manager/web/2023-12-01/provider/method_getwebappstacks.go create mode 100644 resource-manager/web/2023-12-01/provider/method_getwebappstacksforlocation.go create mode 100644 resource-manager/web/2023-12-01/provider/model_appinsightswebappstacksettings.go create mode 100644 resource-manager/web/2023-12-01/provider/model_applicationstack.go create mode 100644 resource-manager/web/2023-12-01/provider/model_applicationstackresource.go create mode 100644 resource-manager/web/2023-12-01/provider/model_functionappmajorversion.go create mode 100644 resource-manager/web/2023-12-01/provider/model_functionappminorversion.go create mode 100644 resource-manager/web/2023-12-01/provider/model_functionappruntimes.go create mode 100644 resource-manager/web/2023-12-01/provider/model_functionappruntimesettings.go create mode 100644 resource-manager/web/2023-12-01/provider/model_functionappstack.go create mode 100644 resource-manager/web/2023-12-01/provider/model_functionappstackproperties.go create mode 100644 resource-manager/web/2023-12-01/provider/model_githubactionwebappstacksettings.go create mode 100644 resource-manager/web/2023-12-01/provider/model_linuxjavacontainersettings.go create mode 100644 resource-manager/web/2023-12-01/provider/model_siteconfigpropertiesdictionary.go create mode 100644 resource-manager/web/2023-12-01/provider/model_stackmajorversion.go create mode 100644 resource-manager/web/2023-12-01/provider/model_stackminorversion.go create mode 100644 resource-manager/web/2023-12-01/provider/model_webappmajorversion.go create mode 100644 resource-manager/web/2023-12-01/provider/model_webappminorversion.go create mode 100644 resource-manager/web/2023-12-01/provider/model_webappruntimes.go create mode 100644 resource-manager/web/2023-12-01/provider/model_webappruntimesettings.go create mode 100644 resource-manager/web/2023-12-01/provider/model_webappstack.go create mode 100644 resource-manager/web/2023-12-01/provider/model_webappstackproperties.go create mode 100644 resource-manager/web/2023-12-01/provider/model_windowsjavacontainersettings.go create mode 100644 resource-manager/web/2023-12-01/provider/predicates.go create mode 100644 resource-manager/web/2023-12-01/provider/version.go create mode 100644 resource-manager/web/2023-12-01/recommendations/README.md create mode 100644 resource-manager/web/2023-12-01/recommendations/client.go create mode 100644 resource-manager/web/2023-12-01/recommendations/constants.go create mode 100644 resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation.go create mode 100644 resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation_test.go create mode 100644 resource-manager/web/2023-12-01/recommendations/id_recommendation.go create mode 100644 resource-manager/web/2023-12-01/recommendations/id_recommendation_test.go create mode 100644 resource-manager/web/2023-12-01/recommendations/id_siterecommendation.go create mode 100644 resource-manager/web/2023-12-01/recommendations/id_siterecommendation_test.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_disableallforhostingenvironment.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_disableallforwebapp.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforhostingenvironment.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsite.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsubscription.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_getruledetailsbyhostingenvironment.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_getruledetailsbywebapp.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_list.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_listhistoryforhostingenvironment.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_listhistoryforwebapp.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforhostingenvironment.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforwebapp.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_resetallfilters.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforhostingenvironment.go create mode 100644 resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforwebapp.go create mode 100644 resource-manager/web/2023-12-01/recommendations/model_recommendation.go create mode 100644 resource-manager/web/2023-12-01/recommendations/model_recommendationproperties.go create mode 100644 resource-manager/web/2023-12-01/recommendations/model_recommendationrule.go create mode 100644 resource-manager/web/2023-12-01/recommendations/model_recommendationruleproperties.go create mode 100644 resource-manager/web/2023-12-01/recommendations/predicates.go create mode 100644 resource-manager/web/2023-12-01/recommendations/version.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/README.md create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/client.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot_test.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/method_getbysite.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/method_getbysiteslot.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/method_list.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysite.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysiteslot.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadata.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/predicates.go create mode 100644 resource-manager/web/2023-12-01/resourcehealthmetadata/version.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/README.md create mode 100644 resource-manager/web/2023-12-01/resourceproviders/client.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/constants.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/id_providerlocation.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/id_providerlocation_test.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol_test.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_checknameavailability.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_getpublishinguser.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_getsourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_getsubscriptiondeploymentlocations.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_getusagesinlocationlist.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listaseregions.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listbillingmeters.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listcustomhostnamesites.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listgeoregions.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listpremieraddonoffers.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listskus.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_listsourcecontrols.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_move.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_updatepublishinguser.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_updatesourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_validate.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_validatemove.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/method_verifyhostingenvironmentvnet.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_appserviceenvironment.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_aseregion.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_aseregionproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfiguration.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfigurationproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_billingmeter.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_billingmeterproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_capability.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_csmmoveresourceenvelope.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_csmusagequota.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfiguration.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfigurationproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesites.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesitesproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_deploymentlocations.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_georegion.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_georegionproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_globalcsmskudescription.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_identifier.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_identifierproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_localizablestring.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_nameidentifier.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_namevaluepair.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_premieraddonoffer.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_premieraddonofferproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailability.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailabilityrequest.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_skucapacity.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_skuinfos.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrolproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_user.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_userproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_validateproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_validaterequest.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_validateresponse.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_validateresponseerror.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_virtualnetworkprofile.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_vnetparameters.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_vnetparametersproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetails.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailure.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailureproperties.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/predicates.go create mode 100644 resource-manager/web/2023-12-01/resourceproviders/version.go create mode 100644 resource-manager/web/2023-12-01/staticsites/README.md create mode 100644 resource-manager/web/2023-12-01/staticsites/client.go create mode 100644 resource-manager/web/2023-12-01/staticsites/constants.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_authprovider.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_authprovider_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_build.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_build_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_builddatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_builddatabaseconnection_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_buildlinkedbackend.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_buildlinkedbackend_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_customdomain.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_customdomain_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_databaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_databaseconnection_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_linkedbackend.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_linkedbackend_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_providerlocation.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_providerlocation_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_staticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_staticsite_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_user.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_user_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_userprovidedfunctionapp.go create mode 100644 resource-manager/web/2023-12-01/staticsites/id_userprovidedfunctionapp_test.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_approveorrejectprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatebasicauth.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatebuilddatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatedatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsiteappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitecustomdomain.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createuserrolesinvitationlink.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsitebuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_deletebuilddatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_deletedatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_deleteprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_deletestaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_deletestaticsitebuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_deletestaticsitecustomdomain.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_deletestaticsiteuser.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_detachstaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getbasicauth.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnections.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnections.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionswithdetails.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionwithdetails.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getlinkedbackend.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendforbuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getlinkedbackends.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendsforbuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnectionlist.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getprivatelinkresources.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getstaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuilds.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getstaticsitecustomdomain.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getstaticsitesbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_linkbackend.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_linkbackendtobuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_list.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_listbasicauth.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsiteappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctionappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctions.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsiteconfiguredroles.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsitecustomdomains.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctionappsettings.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctions.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsitesecrets.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_liststaticsiteusers.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_previewworkflow.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_resetstaticsiteapikey.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_unlinkbackend.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_unlinkbackendfrombuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_updatebuilddatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_updatedatabaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_updatestaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_updatestaticsiteuser.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_validatebackend.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_validatebackendforbuild.go create mode 100644 resource-manager/web/2023-12-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_armidwrapper.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_armplan.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_capability.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_databaseconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_databaseconnectionoverview.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequest.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequestproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_databaseconnectionproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_errorentity.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_privatelinkconnectionstate.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_privatelinkresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceswrapper.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_skucapacity.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_skudescription.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsite.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitearmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitebuildproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackend.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitepatchresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreview.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequest.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitetemplateoptions.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapp.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeployment.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeploymentarmresource.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_stringdictionary.go create mode 100644 resource-manager/web/2023-12-01/staticsites/model_stringlist.go create mode 100644 resource-manager/web/2023-12-01/staticsites/predicates.go create mode 100644 resource-manager/web/2023-12-01/staticsites/version.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/README.md create mode 100644 resource-manager/web/2023-12-01/topleveldomains/client.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain_test.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/method_get.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/method_list.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/method_listagreements.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/model_tldlegalagreement.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/model_topleveldomain.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainagreementoption.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainproperties.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/predicates.go create mode 100644 resource-manager/web/2023-12-01/topleveldomains/version.go create mode 100644 resource-manager/web/2023-12-01/webapps/README.md create mode 100644 resource-manager/web/2023-12-01/webapps/client.go create mode 100644 resource-manager/web/2023-12-01/webapps/constants.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_appsetting.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_appsetting_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_backup.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_backup_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_configreferenceappsetting.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_configreferenceappsetting_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_configreferenceconnectionstring.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_configreferenceconnectionstring_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_connectionstring.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_connectionstring_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_continuouswebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_continuouswebjob_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_default.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_default_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_deployment.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_deployment_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_domainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_domainownershipidentifier_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_function.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_function_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_functionkey.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_functionkey_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_gateway.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_gateway_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_history.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_history_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_hostdefault.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_hostdefault_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_hostnamebinding.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_hostnamebinding_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_hybridconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_hybridconnection_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_instance.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_instance_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_instanceprocess.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_instanceprocess_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_instanceprocessmodule.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_instanceprocessmodule_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_key.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_key_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_module.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_module_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_networkfeature.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_networkfeature_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_networktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_networktrace_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_premieraddon.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_premieraddon_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_privateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_privateendpointconnection_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_process.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_process_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_processmodule.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_processmodule_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_publiccertificate.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_publiccertificate_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_relay.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_relay_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_sitecontainer.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_sitecontainer_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_siteextension.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_siteextension_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_sitenetworktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_sitenetworktrace_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_siteslotnetworktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_siteslotnetworktrace_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slot.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slot_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotbackup.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotbackup_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotcontinuouswebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotcontinuouswebjob_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotdeployment.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotdeployment_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotdomainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotdomainownershipidentifier_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotfunction.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotfunction_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slothostnamebinding.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slothostnamebinding_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slothybridconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slothybridconnection_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotinstance.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotinstance_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotinstanceprocess.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotinstanceprocess_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotinstanceprocessmodule.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotinstanceprocessmodule_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotnetworkfeature.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotnetworkfeature_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotnetworktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotnetworktrace_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotpremieraddon.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotpremieraddon_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotprivateendpointconnection_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotprocess.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotprocess_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotpubliccertificate.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotpubliccertificate_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotsitecontainer.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotsitecontainer_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotsiteextension.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotsiteextension_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slottriggeredwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slottriggeredwebjob_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnection_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotwebjob_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotworkflow.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_slotworkflow_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_snapshot.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_snapshot_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_triggeredwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_triggeredwebjob_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_triggeredwebjobhistory.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_triggeredwebjobhistory_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_virtualnetworkconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_virtualnetworkconnection_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_webjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_webjob_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_websnapshot.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_websnapshot_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_workflow.go create mode 100644 resource-manager/web/2023-12-01/webapps/id_workflow_test.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_addpremieraddon.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_addpremieraddonslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_analyzecustomhostname.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_analyzecustomhostnameslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_applyslotconfigtoproduction.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_applyslotconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_backup.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_backupslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createdeployment.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createdeploymentslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createfunction.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createinstancefunctionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperation.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createmsdeployoperation.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createmsdeployoperationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createonedeployoperation.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdate.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdateconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdateconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifierslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecret.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecretslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebinding.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebindingslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecret.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecretslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificate.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificateslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainer.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainerslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdateslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrolslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongateway.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongatewayslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_delete.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletebackup.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletebackupconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletebackupconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletebackupslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletedeployment.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletedeploymentslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifierslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletefunction.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletefunctionsecret.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletefunctionsecretslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletehostnamebinding.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletehostnamebindingslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletehostsecret.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletehostsecretslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletehybridconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletehybridconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteinstancefunctionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocess.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocessslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletepremieraddon.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletepremieraddonslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteprocess.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteprocessslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletepubliccertificate.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletepubliccertificateslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletesitecontainer.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletesitecontainerslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletesiteextension.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletesiteextensionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletesourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletesourcecontrolslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetwork.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetworkslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletevnetconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deletevnetconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deployworkflowartifacts.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_deployworkflowartifactsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_discoverbackup.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_discoverbackupslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpassword.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpasswordslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_get.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreference.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreferenceslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferences.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferencesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getauthsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getauthsettingsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2slot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecrets.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecretsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getbackupconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getbackupconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getbackupstatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getbackupstatusslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshotslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getcontainerlogszip.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getcontainerlogszipslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getdeployment.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getdeploymentslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifierslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getftpallowed.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getftpallowedslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getfunction.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintoken.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintokenslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gethostnamebinding.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gethostnamebindingslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gethybridconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gethybridconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstancefunctionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceinfoslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylog.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylogslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatusslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceprocess.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdump.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdumpslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmodule.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmoduleslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceprocessslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getinstanceworkflowslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatusslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getmsdeploylog.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getmsdeploylogslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getmsdeploystatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getmsdeploystatusslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getnetworktraces.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getnetworktracesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getnetworktracesslotv2.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getnetworktracesv2.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getonedeploystatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getpremieraddon.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getpremieraddonslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivateaccess.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivateaccessslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlist.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlistslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivatelinkresources.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprivatelinkresourcesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprocess.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprocessdump.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprocessdumpslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprocessmodule.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprocessmoduleslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getprocessslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getpubliccertificate.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getpubliccertificateslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getscmallowed.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getscmallowedslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreference.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsitecontainer.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsitecontainerslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsiteextension.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsiteextensionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflag.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflagslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getsourcecontrolslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistory.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistoryslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getvnetconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongateway.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongatewayslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getvnetconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getwebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogs.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_getworkflow.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_installsiteextension.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_installsiteextensionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_iscloneable.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_iscloneableslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_list.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listapplicationsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listapplicationsettingsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listazurestorageaccounts.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listazurestorageaccountsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listbackups.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listbackupsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listbackupstatussecrets.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listbackupstatussecretsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspolicies.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listbyresourcegroup.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listconfigurations.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfoslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listconfigurationsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listconnectionstrings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listconnectionstringsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobs.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listdeploymentlog.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listdeploymentlogslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listdeployments.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listdeploymentsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiers.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiersslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listfunctionkeys.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listfunctionkeysslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listfunctions.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listfunctionsecrets.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listfunctionsecretsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listhostkeys.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listhostkeysslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listhostnamebindings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listhostnamebindingsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listhybridconnections.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listhybridconnectionsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstancefunctionsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiers.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiersslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceprocesses.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceprocessesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodules.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodulesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreads.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreadsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listinstanceworkflowsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listmetadata.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listmetadataslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listnetworkfeatures.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listnetworkfeaturesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listperfmoncounters.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listperfmoncountersslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpremieraddons.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpremieraddonsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listprocesses.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listprocessesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listprocessmodules.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listprocessmodulesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listprocessthreads.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listprocessthreadsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listproductionsitedeploymentstatuses.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpubliccertificates.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpubliccertificatesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpublishingcredentials.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpublishingcredentialsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecrets.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnections.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnectionsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsitebackups.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsitebackupsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsitecontainers.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsitecontainersslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsiteextensions.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsiteextensionsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsitepushsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsitepushsettingsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listslotconfigurationnames.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listslotdifferencesfromproduction.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listslotdifferencesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listslots.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listslotsitedeploymentstatusesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsnapshots.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondary.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondaryslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsnapshotsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggers.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggersslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsyncstatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listsyncstatusslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistory.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistoryslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobs.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listusages.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listusagesslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listvnetconnections.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listvnetconnectionsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listwebjobs.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listwebjobsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listworkflows.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listworkflowsconnections.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_listworkflowsconnectionsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_migratemysql.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_migratestorage.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnet.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnetslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshotslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_resetproductionslotconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_resetslotconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restart.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restartslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restore.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restorefrombackupblob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restorefrombackupblobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restorefromdeletedapp.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restorefromdeletedappslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restoreslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restoresnapshot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_restoresnapshotslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_start.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startnetworktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startnetworktraceslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperation.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stop.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjobslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stopnetworktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stopnetworktraceslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stopslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktraceslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_swapslotslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_swapslotwithproduction.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_syncfunctions.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_syncfunctionsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggers.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggersslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_syncrepository.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_syncrepositoryslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_update.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateapplicationsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateapplicationsettingsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateauthsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateauthsettingsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2slot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccounts.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccountsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatebackupconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatebackupconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateconfigurationslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateconnectionstrings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateconnectionstringsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfigslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifier.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifierslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateftpallowed.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateftpallowedslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatehybridconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatehybridconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatemetadata.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatemetadataslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatepremieraddon.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatepremieraddonslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatescmallowed.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatescmallowedslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatesitepushsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatesitepushsettingsslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateslotconfigurationnames.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatesourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatesourcecontrolslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatevnetconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongateway.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongatewayslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/method_updatevnetconnectionslot.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_allowedaudiencesvalidation.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_allowedprincipals.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_apidefinitioninfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_apikvreference.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_apikvreferenceproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_apimanagementconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_apple.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_appleregistration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_applicationlogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_appregistration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_armidwrapper.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_authplatform.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_autohealactions.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_autohealcustomaction.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_autohealrules.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_autohealtriggers.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azureactivedirectory.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azureactivedirectorylogin.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryregistration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryvalidation.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azureblobstorageapplicationlogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azureblobstoragehttplogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azurestaticwebapps.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azurestaticwebappsregistration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azurestorageinfovalue.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azurestoragepropertydictionaryresource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_azuretablestorageapplicationlogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_backupitem.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_backupitemproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_backuprequest.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_backuprequestproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_backupschedule.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_blobstoragetokenstore.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_clientregistration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_cloninginfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_connectionstringdictionary.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_connstringinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_connstringvaluetypepair.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_containercpustatistics.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_containercpuusage.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_containerinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_containermemorystatistics.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_containernetworkinterfacestatistics.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_containerthrottlingdata.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_continuouswebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_continuouswebjobproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_cookieexpiration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_corssettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatusproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentity.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_csmpublishingprofileoptions.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_csmslotentity.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_csmusagequota.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresult.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresultproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_customopenidconnectprovider.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_daprconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_databasebackupsetting.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_defaultauthorizationpolicy.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequest.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequestproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_deployment.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_deploymentproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_enabledconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_environmentvariable.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_errorentity.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_experiments.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_extendedlocation.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_facebook.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_filesystemapplicationlogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_filesystemhttplogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_filesystemtokenstore.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_forwardproxy.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionappconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionenvelope.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionenvelopeproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsalwaysreadyconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsdeployment.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorage.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorageauthentication.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsecrets.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsruntime.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrency.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggers.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggershttp.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_github.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_githubactioncodeconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_githubactionconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_githubactioncontainerconfiguration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_globalvalidation.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_google.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_handlermapping.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_hostingenvironmentprofile.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_hostkeys.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_hostnamebinding.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_hostnamebindingproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_hostnamesslstate.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_httplogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_httpsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_httpsettingsroutes.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_hybridconnection.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_hybridconnectionproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_identifier.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_identifierproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_identityproviders.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_ipsecurityrestriction.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_jwtclaimchecks.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_keyinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_legacymicrosoftaccount.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_localizablestring.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_login.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_loginroutes.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_loginscopes.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_migratemysqlrequest.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_migratemysqlrequestproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_migratemysqlstatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_migratemysqlstatusproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeploy.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeploycore.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeploylog.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeploylogentry.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeploylogproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeployproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeploystatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_msdeploystatusproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_namevaluepair.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_networkfeatures.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_networkfeaturesproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_networktrace.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_nonce.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_openidconnectclientcredential.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_openidconnectconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_openidconnectlogin.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_openidconnectregistration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_operation.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_perfmonresponse.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_perfmonsample.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_perfmonset.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_premieraddon.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_premieraddonproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privateaccess.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privateaccessproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privateaccesssubnet.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privateaccessvirtualnetwork.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privatelinkconnectionstate.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privatelinkresource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privatelinkresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_privatelinkresourceswrapper.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_processinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_processinfoproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_processmoduleinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_processmoduleinfoproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_processthreadinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_processthreadinfoproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_publiccertificate.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_publiccertificateproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_pushsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_pushsettingsproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_rampuprule.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentity.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentityproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_requestsbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_resourceconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_restorerequest.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_restorerequestproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_site.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteauthsettings.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteauthsettingsproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2properties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitecloneability.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitecloneabilitycriterion.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteconfigresource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfoproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitecontainer.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitecontainerproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitednsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteextensioninfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteextensioninfoproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitelimits.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitelogsconfig.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitelogsconfigproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitemachinekey.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitepatchresource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitepatchresourceproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflag.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflagproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_siteproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitesourcecontrol.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_sitesourcecontrolproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_slotconfignames.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_slotconfignamesresource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_slotdifference.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_slotdifferenceproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_slotswapstatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_slowrequestsbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_snapshot.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_snapshotproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_snapshotrecoverysource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequest.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequestproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_statuscodesbasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_statuscodesrangebasedtrigger.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_storagemigrationoptions.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_storagemigrationoptionsproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_storagemigrationresponse.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_storagemigrationresponseproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_stringdictionary.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetwork.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetworkproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_tokenstore.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_triggeredjobhistory.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_triggeredjobhistoryproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_triggeredjobrun.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_triggeredwebjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_triggeredwebjobproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_twitter.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_twitterregistration.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_user.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_userproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_virtualapplication.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_virtualdirectory.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_vnetgateway.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_vnetgatewayproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_vnetinfo.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_vnetinforesource.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_vnetroute.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_vnetrouteproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_volumemount.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_webjob.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_webjobproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_websiteinstancestatus.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_websiteinstancestatusproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_workflowartifacts.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_workflowenvelope.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_workflowenvelopeproperties.go create mode 100644 resource-manager/web/2023-12-01/webapps/model_workflowhealth.go create mode 100644 resource-manager/web/2023-12-01/webapps/predicates.go create mode 100644 resource-manager/web/2023-12-01/webapps/version.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/README.md create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/client.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/constants.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_action.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_action_test.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_repetition.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_repetition_test.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_requesthistory.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_requesthistory_test.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_run.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_run_test.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_scoperepetition.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/id_scoperepetition_test.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_coperepetitionsget.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_coperepetitionslist.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_get.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_list.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_listexpressiontraces.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsget.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslist.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_contenthash.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_contentlink.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_errorproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_errorresponse.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_repetitionindex.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_request.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_requesthistory.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_requesthistoryproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_response.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_retryhistory.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_runactioncorrelation.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunaction.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/predicates.go create mode 100644 resource-manager/web/2023-12-01/workflowrunactions/version.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/README.md create mode 100644 resource-manager/web/2023-12-01/workflowruns/client.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/constants.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/id_managementworkflow.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/id_managementworkflow_test.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/id_run.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/id_run_test.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/method_cancel.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/method_get.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/method_list.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_contenthash.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_contentlink.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_correlation.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_resourcereference.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_workflowoutputparameter.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_workflowrun.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_workflowrunproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/model_workflowruntrigger.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/predicates.go create mode 100644 resource-manager/web/2023-12-01/workflowruns/version.go create mode 100644 resource-manager/web/2023-12-01/workflows/README.md create mode 100644 resource-manager/web/2023-12-01/workflows/client.go create mode 100644 resource-manager/web/2023-12-01/workflows/constants.go create mode 100644 resource-manager/web/2023-12-01/workflows/id_managementworkflow.go create mode 100644 resource-manager/web/2023-12-01/workflows/id_managementworkflow_test.go create mode 100644 resource-manager/web/2023-12-01/workflows/method_regenerateaccesskey.go create mode 100644 resource-manager/web/2023-12-01/workflows/method_validate.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfiguration.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfigurationpolicy.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_flowendpoints.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_flowendpointsconfiguration.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_ipaddress.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_ipaddressrange.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicies.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicy.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_openauthenticationpolicyclaim.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_regenerateactionparameter.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_resourcereference.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_workflow.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_workflowparameter.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_workflowproperties.go create mode 100644 resource-manager/web/2023-12-01/workflows/model_workflowsku.go create mode 100644 resource-manager/web/2023-12-01/workflows/version.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/README.md create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/client.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/constants.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger_test.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/id_triggerhistory.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/id_triggerhistory_test.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/method_get.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/method_list.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/method_resubmit.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/model_contenthash.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/model_contentlink.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/model_correlation.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/model_resourcereference.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistory.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/predicates.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggerhistories/version.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/README.md create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/client.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/constants.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow_test.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/id_trigger.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/id_trigger_test.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/method_get.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/method_getschemajson.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/method_list.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/method_listcallbackurl.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/method_run.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_jsonschema.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_recurrenceschedule.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_recurrencescheduleoccurrence.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_resourcereference.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_workflowtrigger.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggercallbackurl.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerrecurrence.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/predicates.go create mode 100644 resource-manager/web/2023-12-01/workflowtriggers/version.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/README.md create mode 100644 resource-manager/web/2023-12-01/workflowversions/client.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/constants.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/id_managementworkflow.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/id_managementworkflow_test.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/id_version.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/id_version_test.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/method_get.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/method_list.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_flowaccesscontrolconfiguration.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_flowendpoints.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_flowendpointsconfiguration.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_ipaddress.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_ipaddressrange.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicies.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicy.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_openauthenticationpolicyclaim.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_resourcereference.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_workflowparameter.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_workflowsku.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_workflowversion.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/model_workflowversionproperties.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/predicates.go create mode 100644 resource-manager/web/2023-12-01/workflowversions/version.go diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/README.md b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/README.md new file mode 100644 index 00000000000..9ac8f3e1ef2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/availableworkloadprofiles` Documentation + +The `availableworkloadprofiles` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/availableworkloadprofiles" +``` + + +### Client Initialization + +```go +client := availableworkloadprofiles.NewAvailableWorkloadProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AvailableWorkloadProfilesClient.Get` + +```go +ctx := context.TODO() +id := availableworkloadprofiles.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.Get(ctx, id)` can be used to do batched pagination +items, err := client.GetComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/client.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/client.go new file mode 100644 index 00000000000..13f22503d96 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/client.go @@ -0,0 +1,26 @@ +package availableworkloadprofiles + +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 AvailableWorkloadProfilesClient struct { + Client *resourcemanager.Client +} + +func NewAvailableWorkloadProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*AvailableWorkloadProfilesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "availableworkloadprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AvailableWorkloadProfilesClient: %+v", err) + } + + return &AvailableWorkloadProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/constants.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/constants.go new file mode 100644 index 00000000000..5001f6a5eda --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/constants.go @@ -0,0 +1,51 @@ +package availableworkloadprofiles + +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 Applicability string + +const ( + ApplicabilityCustom Applicability = "Custom" + ApplicabilityLocationDefault Applicability = "LocationDefault" +) + +func PossibleValuesForApplicability() []string { + return []string{ + string(ApplicabilityCustom), + string(ApplicabilityLocationDefault), + } +} + +func (s *Applicability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicability(input string) (*Applicability, error) { + vals := map[string]Applicability{ + "custom": ApplicabilityCustom, + "locationdefault": ApplicabilityLocationDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Applicability(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location.go new file mode 100644 index 00000000000..4178e6bfbab --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location.go @@ -0,0 +1,121 @@ +package availableworkloadprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.App/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location_test.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location_test.go new file mode 100644 index 00000000000..ca89fe681da --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/id_location_test.go @@ -0,0 +1,237 @@ +package availableworkloadprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/method_get.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/method_get.go new file mode 100644 index 00000000000..5bf9e5cc04a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/method_get.go @@ -0,0 +1,91 @@ +package availableworkloadprofiles + +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 *[]AvailableWorkloadProfile +} + +type GetCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailableWorkloadProfile +} + +// Get ... +func (c AvailableWorkloadProfilesClient) Get(ctx context.Context, id LocationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/availableManagedEnvironmentsWorkloadProfileTypes", 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 *[]AvailableWorkloadProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetComplete retrieves all the results into a single object +func (c AvailableWorkloadProfilesClient) GetComplete(ctx context.Context, id LocationId) (GetCompleteResult, error) { + return c.GetCompleteMatchingPredicate(ctx, id, AvailableWorkloadProfileOperationPredicate{}) +} + +// GetCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AvailableWorkloadProfilesClient) GetCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AvailableWorkloadProfileOperationPredicate) (result GetCompleteResult, err error) { + items := make([]AvailableWorkloadProfile, 0) + + resp, err := c.Get(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 = GetCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofile.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofile.go new file mode 100644 index 00000000000..1e3982c9a81 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofile.go @@ -0,0 +1,17 @@ +package availableworkloadprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableWorkloadProfile struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AvailableWorkloadProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofileproperties.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofileproperties.go new file mode 100644 index 00000000000..598ff5684f4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/model_availableworkloadprofileproperties.go @@ -0,0 +1,13 @@ +package availableworkloadprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableWorkloadProfileProperties struct { + Applicability *Applicability `json:"applicability,omitempty"` + Category *string `json:"category,omitempty"` + Cores *int64 `json:"cores,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Gpus *int64 `json:"gpus,omitempty"` + MemoryGiB *int64 `json:"memoryGiB,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/predicates.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/predicates.go new file mode 100644 index 00000000000..1639daf5d8b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/predicates.go @@ -0,0 +1,32 @@ +package availableworkloadprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableWorkloadProfileOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p AvailableWorkloadProfileOperationPredicate) Matches(input AvailableWorkloadProfile) 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/containerapps/2024-03-01/availableworkloadprofiles/version.go b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/version.go new file mode 100644 index 00000000000..84169219777 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/availableworkloadprofiles/version.go @@ -0,0 +1,12 @@ +package availableworkloadprofiles + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/availableworkloadprofiles/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/README.md b/resource-manager/containerapps/2024-03-01/billingmeters/README.md new file mode 100644 index 00000000000..6f5825f498a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/billingmeters` Documentation + +The `billingmeters` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/billingmeters" +``` + + +### Client Initialization + +```go +client := billingmeters.NewBillingMetersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BillingMetersClient.Get` + +```go +ctx := context.TODO() +id := billingmeters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/client.go b/resource-manager/containerapps/2024-03-01/billingmeters/client.go new file mode 100644 index 00000000000..ca343e3db48 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/client.go @@ -0,0 +1,26 @@ +package billingmeters + +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 BillingMetersClient struct { + Client *resourcemanager.Client +} + +func NewBillingMetersClientWithBaseURI(sdkApi sdkEnv.Api) (*BillingMetersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "billingmeters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BillingMetersClient: %+v", err) + } + + return &BillingMetersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/id_location.go b/resource-manager/containerapps/2024-03-01/billingmeters/id_location.go new file mode 100644 index 00000000000..39035bfc073 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/id_location.go @@ -0,0 +1,121 @@ +package billingmeters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.App/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/id_location_test.go b/resource-manager/containerapps/2024-03-01/billingmeters/id_location_test.go new file mode 100644 index 00000000000..f46c62c407a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/id_location_test.go @@ -0,0 +1,237 @@ +package billingmeters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/method_get.go b/resource-manager/containerapps/2024-03-01/billingmeters/method_get.go new file mode 100644 index 00000000000..0a4c2df9948 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/method_get.go @@ -0,0 +1,55 @@ +package billingmeters + +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 *BillingMeterCollection +} + +// Get ... +func (c BillingMetersClient) Get(ctx context.Context, id LocationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/billingMeters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BillingMeterCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeter.go b/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeter.go new file mode 100644 index 00000000000..78fd132ca4f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeter.go @@ -0,0 +1,17 @@ +package billingmeters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeter struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BillingMeterProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmetercollection.go b/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmetercollection.go new file mode 100644 index 00000000000..d8d25b43e79 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmetercollection.go @@ -0,0 +1,8 @@ +package billingmeters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeterCollection struct { + Value []BillingMeter `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeterproperties.go b/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeterproperties.go new file mode 100644 index 00000000000..21df49710dc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/billingmeters/model_billingmeterproperties.go @@ -0,0 +1,10 @@ +package billingmeters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeterProperties struct { + Category *string `json:"category,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + MeterType *string `json:"meterType,omitempty"` +} diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/version.go b/resource-manager/containerapps/2024-03-01/billingmeters/version.go similarity index 54% rename from resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/version.go rename to resource-manager/containerapps/2024-03-01/billingmeters/version.go index 2e8a619c9bf..f49f12ef030 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/version.go +++ b/resource-manager/containerapps/2024-03-01/billingmeters/version.go @@ -1,12 +1,12 @@ -package eventhubsclustersupgrade +package billingmeters import "fmt" // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -const defaultApiVersion = "2024-01-01" +const defaultApiVersion = "2024-03-01" func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/eventhubsclustersupgrade/%s", defaultApiVersion) + return fmt.Sprintf("hashicorp/go-azure-sdk/billingmeters/%s", defaultApiVersion) } diff --git a/resource-manager/containerapps/2024-03-01/certificates/README.md b/resource-manager/containerapps/2024-03-01/certificates/README.md new file mode 100644 index 00000000000..f9e63105745 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/README.md @@ -0,0 +1,202 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/certificates` Documentation + +The `certificates` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/certificates" +``` + + +### Client Initialization + +```go +client := certificates.NewCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificatesClient.ConnectedEnvironmentsCertificatesCreateOrUpdate` + +```go +ctx := context.TODO() +id := certificates.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +payload := certificates.Certificate{ + // ... +} + + +read, err := client.ConnectedEnvironmentsCertificatesCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.ConnectedEnvironmentsCertificatesDelete` + +```go +ctx := context.TODO() +id := certificates.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +read, err := client.ConnectedEnvironmentsCertificatesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.ConnectedEnvironmentsCertificatesGet` + +```go +ctx := context.TODO() +id := certificates.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +read, err := client.ConnectedEnvironmentsCertificatesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.ConnectedEnvironmentsCertificatesList` + +```go +ctx := context.TODO() +id := certificates.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +// alternatively `client.ConnectedEnvironmentsCertificatesList(ctx, id)` can be used to do batched pagination +items, err := client.ConnectedEnvironmentsCertificatesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.ConnectedEnvironmentsCertificatesUpdate` + +```go +ctx := context.TODO() +id := certificates.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +payload := certificates.CertificatePatch{ + // ... +} + + +read, err := client.ConnectedEnvironmentsCertificatesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +payload := certificates.Certificate{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Delete` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Get` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +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: `CertificatesClient.List` + +```go +ctx := context.TODO() +id := certificates.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// 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: `CertificatesClient.Update` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +payload := certificates.CertificatePatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerapps/2024-03-01/certificates/client.go b/resource-manager/containerapps/2024-03-01/certificates/client.go new file mode 100644 index 00000000000..7248daeda34 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/client.go @@ -0,0 +1,26 @@ +package certificates + +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 CertificatesClient struct { + Client *resourcemanager.Client +} + +func NewCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "certificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificatesClient: %+v", err) + } + + return &CertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/constants.go b/resource-manager/containerapps/2024-03-01/certificates/constants.go new file mode 100644 index 00000000000..bf939247fa5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/constants.go @@ -0,0 +1,60 @@ +package certificates + +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 CertificateProvisioningState string + +const ( + CertificateProvisioningStateCanceled CertificateProvisioningState = "Canceled" + CertificateProvisioningStateDeleteFailed CertificateProvisioningState = "DeleteFailed" + CertificateProvisioningStateFailed CertificateProvisioningState = "Failed" + CertificateProvisioningStatePending CertificateProvisioningState = "Pending" + CertificateProvisioningStateSucceeded CertificateProvisioningState = "Succeeded" +) + +func PossibleValuesForCertificateProvisioningState() []string { + return []string{ + string(CertificateProvisioningStateCanceled), + string(CertificateProvisioningStateDeleteFailed), + string(CertificateProvisioningStateFailed), + string(CertificateProvisioningStatePending), + string(CertificateProvisioningStateSucceeded), + } +} + +func (s *CertificateProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProvisioningState(input string) (*CertificateProvisioningState, error) { + vals := map[string]CertificateProvisioningState{ + "canceled": CertificateProvisioningStateCanceled, + "deletefailed": CertificateProvisioningStateDeleteFailed, + "failed": CertificateProvisioningStateFailed, + "pending": CertificateProvisioningStatePending, + "succeeded": CertificateProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/id_certificate.go b/resource-manager/containerapps/2024-03-01/certificates/id_certificate.go new file mode 100644 index 00000000000..1f3c85bd29a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_certificate.go @@ -0,0 +1,139 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/id_certificate_test.go b/resource-manager/containerapps/2024-03-01/certificates/id_certificate_test.go new file mode 100644 index 00000000000..e0a1b2b9c57 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_certificate_test.go @@ -0,0 +1,327 @@ +package certificates + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment.go b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment.go new file mode 100644 index 00000000000..4147c3edea2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment.go @@ -0,0 +1,130 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentId{} + +// ConnectedEnvironmentId is a struct representing the Resource ID for a Connected Environment +type ConnectedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string +} + +// NewConnectedEnvironmentID returns a new ConnectedEnvironmentId struct +func NewConnectedEnvironmentID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string) ConnectedEnvironmentId { + return ConnectedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + } +} + +// ParseConnectedEnvironmentID parses 'input' into a ConnectedEnvironmentId +func ParseConnectedEnvironmentID(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentIDInsensitively(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentID checks that 'input' can be parsed as a Connected Environment ID +func ValidateConnectedEnvironmentID(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 := ParseConnectedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment ID +func (id ConnectedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment ID +func (id ConnectedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Connected Environment ID +func (id ConnectedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + } + return fmt.Sprintf("Connected Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment_test.go b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment_test.go new file mode 100644 index 00000000000..e60550e8d60 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironment_test.go @@ -0,0 +1,282 @@ +package certificates + +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 = &ConnectedEnvironmentId{} + +func TestNewConnectedEnvironmentID(t *testing.T) { + id := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } +} + +func TestFormatConnectedEnvironmentID(t *testing.T) { + actual := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestParseConnectedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentId(t *testing.T) { + segments := ConnectedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentId 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/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate.go b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate.go new file mode 100644 index 00000000000..d066a1f6d08 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate.go @@ -0,0 +1,139 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentCertificateId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentCertificateId{} + +// ConnectedEnvironmentCertificateId is a struct representing the Resource ID for a Connected Environment Certificate +type ConnectedEnvironmentCertificateId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string + CertificateName string +} + +// NewConnectedEnvironmentCertificateID returns a new ConnectedEnvironmentCertificateId struct +func NewConnectedEnvironmentCertificateID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string, certificateName string) ConnectedEnvironmentCertificateId { + return ConnectedEnvironmentCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + CertificateName: certificateName, + } +} + +// ParseConnectedEnvironmentCertificateID parses 'input' into a ConnectedEnvironmentCertificateId +func ParseConnectedEnvironmentCertificateID(input string) (*ConnectedEnvironmentCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentCertificateIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentCertificateId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentCertificateIDInsensitively(input string) (*ConnectedEnvironmentCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentCertificateId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentCertificateID checks that 'input' can be parsed as a Connected Environment Certificate ID +func ValidateConnectedEnvironmentCertificateID(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 := ParseConnectedEnvironmentCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment Certificate ID +func (id ConnectedEnvironmentCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment Certificate ID +func (id ConnectedEnvironmentCertificateId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// String returns a human-readable description of this Connected Environment Certificate ID +func (id ConnectedEnvironmentCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Connected Environment Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate_test.go b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate_test.go new file mode 100644 index 00000000000..5d3f022785b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_connectedenvironmentcertificate_test.go @@ -0,0 +1,327 @@ +package certificates + +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 = &ConnectedEnvironmentCertificateId{} + +func TestNewConnectedEnvironmentCertificateID(t *testing.T) { + id := NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } + + if id.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatConnectedEnvironmentCertificateID(t *testing.T) { + actual := NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue", + Expected: &ConnectedEnvironmentCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseConnectedEnvironmentCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue", + Expected: &ConnectedEnvironmentCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &ConnectedEnvironmentCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentCertificateId(t *testing.T) { + segments := ConnectedEnvironmentCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentCertificateId 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/containerapps/2024-03-01/certificates/id_managedenvironment.go b/resource-manager/containerapps/2024-03-01/certificates/id_managedenvironment.go new file mode 100644 index 00000000000..5f5f0986d2a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_managedenvironment.go @@ -0,0 +1,130 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentId{} + +// ManagedEnvironmentId is a struct representing the Resource ID for a Managed Environment +type ManagedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string +} + +// NewManagedEnvironmentID returns a new ManagedEnvironmentId struct +func NewManagedEnvironmentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string) ManagedEnvironmentId { + return ManagedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + } +} + +// ParseManagedEnvironmentID parses 'input' into a ManagedEnvironmentId +func ParseManagedEnvironmentID(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentIDInsensitively(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + return nil +} + +// ValidateManagedEnvironmentID checks that 'input' can be parsed as a Managed Environment ID +func ValidateManagedEnvironmentID(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 := ParseManagedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment ID +func (id ManagedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment ID +func (id ManagedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Managed Environment ID +func (id ManagedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + } + return fmt.Sprintf("Managed Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/id_managedenvironment_test.go b/resource-manager/containerapps/2024-03-01/certificates/id_managedenvironment_test.go new file mode 100644 index 00000000000..8f39c6cc790 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/id_managedenvironment_test.go @@ -0,0 +1,282 @@ +package certificates + +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 = &ManagedEnvironmentId{} + +func TestNewManagedEnvironmentID(t *testing.T) { + id := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } +} + +func TestFormatManagedEnvironmentID(t *testing.T) { + actual := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestParseManagedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestSegmentsForManagedEnvironmentId(t *testing.T) { + segments := ManagedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentId 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/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatescreateorupdate.go b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatescreateorupdate.go new file mode 100644 index 00000000000..08223ec1f7e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatescreateorupdate.go @@ -0,0 +1,58 @@ +package certificates + +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 ConnectedEnvironmentsCertificatesCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// ConnectedEnvironmentsCertificatesCreateOrUpdate ... +func (c CertificatesClient) ConnectedEnvironmentsCertificatesCreateOrUpdate(ctx context.Context, id ConnectedEnvironmentCertificateId, input Certificate) (result ConnectedEnvironmentsCertificatesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesdelete.go b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesdelete.go new file mode 100644 index 00000000000..7dae77f3c1f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesdelete.go @@ -0,0 +1,47 @@ +package certificates + +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 ConnectedEnvironmentsCertificatesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ConnectedEnvironmentsCertificatesDelete ... +func (c CertificatesClient) ConnectedEnvironmentsCertificatesDelete(ctx context.Context, id ConnectedEnvironmentCertificateId) (result ConnectedEnvironmentsCertificatesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesget.go b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesget.go new file mode 100644 index 00000000000..46ad518db87 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesget.go @@ -0,0 +1,54 @@ +package certificates + +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 ConnectedEnvironmentsCertificatesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// ConnectedEnvironmentsCertificatesGet ... +func (c CertificatesClient) ConnectedEnvironmentsCertificatesGet(ctx context.Context, id ConnectedEnvironmentCertificateId) (result ConnectedEnvironmentsCertificatesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificateslist.go b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificateslist.go new file mode 100644 index 00000000000..e2b32df155d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificateslist.go @@ -0,0 +1,91 @@ +package certificates + +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 ConnectedEnvironmentsCertificatesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ConnectedEnvironmentsCertificatesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +// ConnectedEnvironmentsCertificatesList ... +func (c CertificatesClient) ConnectedEnvironmentsCertificatesList(ctx context.Context, id ConnectedEnvironmentId) (result ConnectedEnvironmentsCertificatesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", 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 *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ConnectedEnvironmentsCertificatesListComplete retrieves all the results into a single object +func (c CertificatesClient) ConnectedEnvironmentsCertificatesListComplete(ctx context.Context, id ConnectedEnvironmentId) (ConnectedEnvironmentsCertificatesListCompleteResult, error) { + return c.ConnectedEnvironmentsCertificatesListCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ConnectedEnvironmentsCertificatesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ConnectedEnvironmentsCertificatesListCompleteMatchingPredicate(ctx context.Context, id ConnectedEnvironmentId, predicate CertificateOperationPredicate) (result ConnectedEnvironmentsCertificatesListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ConnectedEnvironmentsCertificatesList(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 = ConnectedEnvironmentsCertificatesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesupdate.go b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesupdate.go new file mode 100644 index 00000000000..65a14b672c3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_connectedenvironmentscertificatesupdate.go @@ -0,0 +1,58 @@ +package certificates + +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 ConnectedEnvironmentsCertificatesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// ConnectedEnvironmentsCertificatesUpdate ... +func (c CertificatesClient) ConnectedEnvironmentsCertificatesUpdate(ctx context.Context, id ConnectedEnvironmentCertificateId, input CertificatePatch) (result ConnectedEnvironmentsCertificatesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/certificates/method_createorupdate.go new file mode 100644 index 00000000000..dd5b06bc250 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_createorupdate.go @@ -0,0 +1,58 @@ +package certificates + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CreateOrUpdate ... +func (c CertificatesClient) CreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_delete.go b/resource-manager/containerapps/2024-03-01/certificates/method_delete.go new file mode 100644 index 00000000000..6f676ff9031 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_delete.go @@ -0,0 +1,47 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CertificatesClient) Delete(ctx context.Context, id CertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_get.go b/resource-manager/containerapps/2024-03-01/certificates/method_get.go new file mode 100644 index 00000000000..339126ffd6a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_get.go @@ -0,0 +1,54 @@ +package certificates + +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 *Certificate +} + +// Get ... +func (c CertificatesClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/method_list.go b/resource-manager/containerapps/2024-03-01/certificates/method_list.go new file mode 100644 index 00000000000..26110f8909e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_list.go @@ -0,0 +1,91 @@ +package certificates + +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 *[]Certificate +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +// List ... +func (c CertificatesClient) List(ctx context.Context, id ManagedEnvironmentId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", 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 *[]Certificate `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 CertificatesClient) ListComplete(ctx context.Context, id ManagedEnvironmentId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate CertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Certificate, 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/containerapps/2024-03-01/certificates/method_update.go b/resource-manager/containerapps/2024-03-01/certificates/method_update.go new file mode 100644 index 00000000000..fa22e1ab8ac --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/method_update.go @@ -0,0 +1,58 @@ +package certificates + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Update ... +func (c CertificatesClient) Update(ctx context.Context, id CertificateId, input CertificatePatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/model_certificate.go b/resource-manager/containerapps/2024-03-01/certificates/model_certificate.go new file mode 100644 index 00000000000..9d2ab626ff9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/model_certificate.go @@ -0,0 +1,18 @@ +package certificates + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/model_certificatepatch.go b/resource-manager/containerapps/2024-03-01/certificates/model_certificatepatch.go new file mode 100644 index 00000000000..8fb7a984a1b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/model_certificatepatch.go @@ -0,0 +1,8 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatch struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/model_certificateproperties.go b/resource-manager/containerapps/2024-03-01/certificates/model_certificateproperties.go new file mode 100644 index 00000000000..b37db70c194 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/model_certificateproperties.go @@ -0,0 +1,48 @@ +package certificates + +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 CertificateProperties struct { + ExpirationDate *string `json:"expirationDate,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + Password *string `json:"password,omitempty"` + ProvisioningState *CertificateProvisioningState `json:"provisioningState,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SubjectAlternativeNames *[]string `json:"subjectAlternativeNames,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` + Value *string `json:"value,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/predicates.go b/resource-manager/containerapps/2024-03-01/certificates/predicates.go new file mode 100644 index 00000000000..2264c7e5419 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/predicates.go @@ -0,0 +1,32 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerapps/2024-03-01/certificates/version.go b/resource-manager/containerapps/2024-03-01/certificates/version.go new file mode 100644 index 00000000000..6fe14565ca6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/certificates/version.go @@ -0,0 +1,12 @@ +package certificates + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/certificates/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/client.go b/resource-manager/containerapps/2024-03-01/client.go new file mode 100644 index 00000000000..e5c9e6d061f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/client.go @@ -0,0 +1,181 @@ +package v2024_03_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/containerapps/2024-03-01/availableworkloadprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/billingmeters" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/connectedenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappsauthconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappsrevisions" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappssourcecontrols" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/daprcomponents" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/diagnostics" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/jobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/managedcertificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/managedenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/subscriptions" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/usages" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AvailableWorkloadProfiles *availableworkloadprofiles.AvailableWorkloadProfilesClient + BillingMeters *billingmeters.BillingMetersClient + Certificates *certificates.CertificatesClient + ConnectedEnvironments *connectedenvironments.ConnectedEnvironmentsClient + ConnectedEnvironmentsStorages *connectedenvironmentsstorages.ConnectedEnvironmentsStoragesClient + ContainerApps *containerapps.ContainerAppsClient + ContainerAppsAuthConfigs *containerappsauthconfigs.ContainerAppsAuthConfigsClient + ContainerAppsRevisionReplicas *containerappsrevisionreplicas.ContainerAppsRevisionReplicasClient + ContainerAppsRevisions *containerappsrevisions.ContainerAppsRevisionsClient + ContainerAppsSourceControls *containerappssourcecontrols.ContainerAppsSourceControlsClient + DaprComponents *daprcomponents.DaprComponentsClient + Diagnostics *diagnostics.DiagnosticsClient + Jobs *jobs.JobsClient + ManagedCertificates *managedcertificates.ManagedCertificatesClient + ManagedEnvironments *managedenvironments.ManagedEnvironmentsClient + ManagedEnvironmentsStorages *managedenvironmentsstorages.ManagedEnvironmentsStoragesClient + Subscriptions *subscriptions.SubscriptionsClient + Usages *usages.UsagesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + availableWorkloadProfilesClient, err := availableworkloadprofiles.NewAvailableWorkloadProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AvailableWorkloadProfiles client: %+v", err) + } + configureFunc(availableWorkloadProfilesClient.Client) + + billingMetersClient, err := billingmeters.NewBillingMetersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BillingMeters client: %+v", err) + } + configureFunc(billingMetersClient.Client) + + certificatesClient, err := certificates.NewCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Certificates client: %+v", err) + } + configureFunc(certificatesClient.Client) + + connectedEnvironmentsClient, err := connectedenvironments.NewConnectedEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ConnectedEnvironments client: %+v", err) + } + configureFunc(connectedEnvironmentsClient.Client) + + connectedEnvironmentsStoragesClient, err := connectedenvironmentsstorages.NewConnectedEnvironmentsStoragesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ConnectedEnvironmentsStorages client: %+v", err) + } + configureFunc(connectedEnvironmentsStoragesClient.Client) + + containerAppsAuthConfigsClient, err := containerappsauthconfigs.NewContainerAppsAuthConfigsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerAppsAuthConfigs client: %+v", err) + } + configureFunc(containerAppsAuthConfigsClient.Client) + + containerAppsClient, err := containerapps.NewContainerAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerApps client: %+v", err) + } + configureFunc(containerAppsClient.Client) + + containerAppsRevisionReplicasClient, err := containerappsrevisionreplicas.NewContainerAppsRevisionReplicasClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerAppsRevisionReplicas client: %+v", err) + } + configureFunc(containerAppsRevisionReplicasClient.Client) + + containerAppsRevisionsClient, err := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerAppsRevisions client: %+v", err) + } + configureFunc(containerAppsRevisionsClient.Client) + + containerAppsSourceControlsClient, err := containerappssourcecontrols.NewContainerAppsSourceControlsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerAppsSourceControls client: %+v", err) + } + configureFunc(containerAppsSourceControlsClient.Client) + + daprComponentsClient, err := daprcomponents.NewDaprComponentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DaprComponents client: %+v", err) + } + configureFunc(daprComponentsClient.Client) + + diagnosticsClient, err := diagnostics.NewDiagnosticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Diagnostics client: %+v", err) + } + configureFunc(diagnosticsClient.Client) + + jobsClient, err := jobs.NewJobsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Jobs client: %+v", err) + } + configureFunc(jobsClient.Client) + + managedCertificatesClient, err := managedcertificates.NewManagedCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedCertificates client: %+v", err) + } + configureFunc(managedCertificatesClient.Client) + + managedEnvironmentsClient, err := managedenvironments.NewManagedEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedEnvironments client: %+v", err) + } + configureFunc(managedEnvironmentsClient.Client) + + managedEnvironmentsStoragesClient, err := managedenvironmentsstorages.NewManagedEnvironmentsStoragesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedEnvironmentsStorages client: %+v", err) + } + configureFunc(managedEnvironmentsStoragesClient.Client) + + subscriptionsClient, err := subscriptions.NewSubscriptionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Subscriptions client: %+v", err) + } + configureFunc(subscriptionsClient.Client) + + usagesClient, err := usages.NewUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Usages client: %+v", err) + } + configureFunc(usagesClient.Client) + + return &Client{ + AvailableWorkloadProfiles: availableWorkloadProfilesClient, + BillingMeters: billingMetersClient, + Certificates: certificatesClient, + ConnectedEnvironments: connectedEnvironmentsClient, + ConnectedEnvironmentsStorages: connectedEnvironmentsStoragesClient, + ContainerApps: containerAppsClient, + ContainerAppsAuthConfigs: containerAppsAuthConfigsClient, + ContainerAppsRevisionReplicas: containerAppsRevisionReplicasClient, + ContainerAppsRevisions: containerAppsRevisionsClient, + ContainerAppsSourceControls: containerAppsSourceControlsClient, + DaprComponents: daprComponentsClient, + Diagnostics: diagnosticsClient, + Jobs: jobsClient, + ManagedCertificates: managedCertificatesClient, + ManagedEnvironments: managedEnvironmentsClient, + ManagedEnvironmentsStorages: managedEnvironmentsStoragesClient, + Subscriptions: subscriptionsClient, + Usages: usagesClient, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/README.md b/resource-manager/containerapps/2024-03-01/connectedenvironments/README.md new file mode 100644 index 00000000000..7d653f2a22d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/README.md @@ -0,0 +1,228 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/connectedenvironments` Documentation + +The `connectedenvironments` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/connectedenvironments" +``` + + +### Client Initialization + +```go +client := connectedenvironments.NewConnectedEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ConnectedEnvironmentsClient.CertificatesCreateOrUpdate` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +payload := connectedenvironments.Certificate{ + // ... +} + + +read, err := client.CertificatesCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.CertificatesDelete` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +read, err := client.CertificatesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.CertificatesGet` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +read, err := client.CertificatesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.CertificatesList` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +// alternatively `client.CertificatesList(ctx, id)` can be used to do batched pagination +items, err := client.CertificatesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.CertificatesUpdate` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + +payload := connectedenvironments.CertificatePatch{ + // ... +} + + +read, err := client.CertificatesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +payload := connectedenvironments.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +payload := connectedenvironments.ConnectedEnvironment{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +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: `ConnectedEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ConnectedEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := connectedenvironments.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +read, err := client.Update(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/containerapps/2024-03-01/connectedenvironments/client.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/client.go new file mode 100644 index 00000000000..05cf79bdaad --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/client.go @@ -0,0 +1,26 @@ +package connectedenvironments + +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 ConnectedEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewConnectedEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ConnectedEnvironmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "connectedenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConnectedEnvironmentsClient: %+v", err) + } + + return &ConnectedEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/constants.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/constants.go new file mode 100644 index 00000000000..651bf31cb00 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/constants.go @@ -0,0 +1,198 @@ +package connectedenvironments + +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 CertificateProvisioningState string + +const ( + CertificateProvisioningStateCanceled CertificateProvisioningState = "Canceled" + CertificateProvisioningStateDeleteFailed CertificateProvisioningState = "DeleteFailed" + CertificateProvisioningStateFailed CertificateProvisioningState = "Failed" + CertificateProvisioningStatePending CertificateProvisioningState = "Pending" + CertificateProvisioningStateSucceeded CertificateProvisioningState = "Succeeded" +) + +func PossibleValuesForCertificateProvisioningState() []string { + return []string{ + string(CertificateProvisioningStateCanceled), + string(CertificateProvisioningStateDeleteFailed), + string(CertificateProvisioningStateFailed), + string(CertificateProvisioningStatePending), + string(CertificateProvisioningStateSucceeded), + } +} + +func (s *CertificateProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProvisioningState(input string) (*CertificateProvisioningState, error) { + vals := map[string]CertificateProvisioningState{ + "canceled": CertificateProvisioningStateCanceled, + "deletefailed": CertificateProvisioningStateDeleteFailed, + "failed": CertificateProvisioningStateFailed, + "pending": CertificateProvisioningStatePending, + "succeeded": CertificateProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProvisioningState(input) + return &out, nil +} + +type CheckNameAvailabilityReason string + +const ( + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +func PossibleValuesForCheckNameAvailabilityReason() []string { + return []string{ + string(CheckNameAvailabilityReasonAlreadyExists), + string(CheckNameAvailabilityReasonInvalid), + } +} + +func (s *CheckNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameAvailabilityReason(input string) (*CheckNameAvailabilityReason, error) { + vals := map[string]CheckNameAvailabilityReason{ + "alreadyexists": CheckNameAvailabilityReasonAlreadyExists, + "invalid": CheckNameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameAvailabilityReason(input) + return &out, nil +} + +type ConnectedEnvironmentProvisioningState string + +const ( + ConnectedEnvironmentProvisioningStateCanceled ConnectedEnvironmentProvisioningState = "Canceled" + ConnectedEnvironmentProvisioningStateFailed ConnectedEnvironmentProvisioningState = "Failed" + ConnectedEnvironmentProvisioningStateInfrastructureSetupComplete ConnectedEnvironmentProvisioningState = "InfrastructureSetupComplete" + ConnectedEnvironmentProvisioningStateInfrastructureSetupInProgress ConnectedEnvironmentProvisioningState = "InfrastructureSetupInProgress" + ConnectedEnvironmentProvisioningStateInitializationInProgress ConnectedEnvironmentProvisioningState = "InitializationInProgress" + ConnectedEnvironmentProvisioningStateScheduledForDelete ConnectedEnvironmentProvisioningState = "ScheduledForDelete" + ConnectedEnvironmentProvisioningStateSucceeded ConnectedEnvironmentProvisioningState = "Succeeded" + ConnectedEnvironmentProvisioningStateWaiting ConnectedEnvironmentProvisioningState = "Waiting" +) + +func PossibleValuesForConnectedEnvironmentProvisioningState() []string { + return []string{ + string(ConnectedEnvironmentProvisioningStateCanceled), + string(ConnectedEnvironmentProvisioningStateFailed), + string(ConnectedEnvironmentProvisioningStateInfrastructureSetupComplete), + string(ConnectedEnvironmentProvisioningStateInfrastructureSetupInProgress), + string(ConnectedEnvironmentProvisioningStateInitializationInProgress), + string(ConnectedEnvironmentProvisioningStateScheduledForDelete), + string(ConnectedEnvironmentProvisioningStateSucceeded), + string(ConnectedEnvironmentProvisioningStateWaiting), + } +} + +func (s *ConnectedEnvironmentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedEnvironmentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedEnvironmentProvisioningState(input string) (*ConnectedEnvironmentProvisioningState, error) { + vals := map[string]ConnectedEnvironmentProvisioningState{ + "canceled": ConnectedEnvironmentProvisioningStateCanceled, + "failed": ConnectedEnvironmentProvisioningStateFailed, + "infrastructuresetupcomplete": ConnectedEnvironmentProvisioningStateInfrastructureSetupComplete, + "infrastructuresetupinprogress": ConnectedEnvironmentProvisioningStateInfrastructureSetupInProgress, + "initializationinprogress": ConnectedEnvironmentProvisioningStateInitializationInProgress, + "scheduledfordelete": ConnectedEnvironmentProvisioningStateScheduledForDelete, + "succeeded": ConnectedEnvironmentProvisioningStateSucceeded, + "waiting": ConnectedEnvironmentProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedEnvironmentProvisioningState(input) + return &out, nil +} + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment.go new file mode 100644 index 00000000000..b477bcb1616 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment.go @@ -0,0 +1,130 @@ +package connectedenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentId{} + +// ConnectedEnvironmentId is a struct representing the Resource ID for a Connected Environment +type ConnectedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string +} + +// NewConnectedEnvironmentID returns a new ConnectedEnvironmentId struct +func NewConnectedEnvironmentID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string) ConnectedEnvironmentId { + return ConnectedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + } +} + +// ParseConnectedEnvironmentID parses 'input' into a ConnectedEnvironmentId +func ParseConnectedEnvironmentID(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentIDInsensitively(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentID checks that 'input' can be parsed as a Connected Environment ID +func ValidateConnectedEnvironmentID(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 := ParseConnectedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment ID +func (id ConnectedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment ID +func (id ConnectedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Connected Environment ID +func (id ConnectedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + } + return fmt.Sprintf("Connected Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment_test.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment_test.go new file mode 100644 index 00000000000..f8faa79d4d0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironment_test.go @@ -0,0 +1,282 @@ +package connectedenvironments + +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 = &ConnectedEnvironmentId{} + +func TestNewConnectedEnvironmentID(t *testing.T) { + id := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } +} + +func TestFormatConnectedEnvironmentID(t *testing.T) { + actual := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestParseConnectedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentId(t *testing.T) { + segments := ConnectedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentId 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/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate.go new file mode 100644 index 00000000000..51e7eae4c8d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate.go @@ -0,0 +1,139 @@ +package connectedenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentCertificateId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentCertificateId{} + +// ConnectedEnvironmentCertificateId is a struct representing the Resource ID for a Connected Environment Certificate +type ConnectedEnvironmentCertificateId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string + CertificateName string +} + +// NewConnectedEnvironmentCertificateID returns a new ConnectedEnvironmentCertificateId struct +func NewConnectedEnvironmentCertificateID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string, certificateName string) ConnectedEnvironmentCertificateId { + return ConnectedEnvironmentCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + CertificateName: certificateName, + } +} + +// ParseConnectedEnvironmentCertificateID parses 'input' into a ConnectedEnvironmentCertificateId +func ParseConnectedEnvironmentCertificateID(input string) (*ConnectedEnvironmentCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentCertificateIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentCertificateId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentCertificateIDInsensitively(input string) (*ConnectedEnvironmentCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentCertificateId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentCertificateID checks that 'input' can be parsed as a Connected Environment Certificate ID +func ValidateConnectedEnvironmentCertificateID(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 := ParseConnectedEnvironmentCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment Certificate ID +func (id ConnectedEnvironmentCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment Certificate ID +func (id ConnectedEnvironmentCertificateId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// String returns a human-readable description of this Connected Environment Certificate ID +func (id ConnectedEnvironmentCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Connected Environment Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate_test.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate_test.go new file mode 100644 index 00000000000..bb596d76a57 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/id_connectedenvironmentcertificate_test.go @@ -0,0 +1,327 @@ +package connectedenvironments + +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 = &ConnectedEnvironmentCertificateId{} + +func TestNewConnectedEnvironmentCertificateID(t *testing.T) { + id := NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } + + if id.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatConnectedEnvironmentCertificateID(t *testing.T) { + actual := NewConnectedEnvironmentCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue", + Expected: &ConnectedEnvironmentCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseConnectedEnvironmentCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue", + Expected: &ConnectedEnvironmentCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &ConnectedEnvironmentCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentCertificateId(t *testing.T) { + segments := ConnectedEnvironmentCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentCertificateId 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/containerapps/2024-03-01/connectedenvironments/method_certificatescreateorupdate.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatescreateorupdate.go new file mode 100644 index 00000000000..07244dc5d7a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatescreateorupdate.go @@ -0,0 +1,58 @@ +package connectedenvironments + +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 CertificatesCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CertificatesCreateOrUpdate ... +func (c ConnectedEnvironmentsClient) CertificatesCreateOrUpdate(ctx context.Context, id ConnectedEnvironmentCertificateId, input Certificate) (result CertificatesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesdelete.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesdelete.go new file mode 100644 index 00000000000..09af06779f6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesdelete.go @@ -0,0 +1,47 @@ +package connectedenvironments + +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 CertificatesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CertificatesDelete ... +func (c ConnectedEnvironmentsClient) CertificatesDelete(ctx context.Context, id ConnectedEnvironmentCertificateId) (result CertificatesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesget.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesget.go new file mode 100644 index 00000000000..655d77efb6f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesget.go @@ -0,0 +1,54 @@ +package connectedenvironments + +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 CertificatesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CertificatesGet ... +func (c ConnectedEnvironmentsClient) CertificatesGet(ctx context.Context, id ConnectedEnvironmentCertificateId) (result CertificatesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificateslist.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificateslist.go new file mode 100644 index 00000000000..d6db1529252 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificateslist.go @@ -0,0 +1,91 @@ +package connectedenvironments + +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 CertificatesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type CertificatesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +// CertificatesList ... +func (c ConnectedEnvironmentsClient) CertificatesList(ctx context.Context, id ConnectedEnvironmentId) (result CertificatesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", 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 *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CertificatesListComplete retrieves all the results into a single object +func (c ConnectedEnvironmentsClient) CertificatesListComplete(ctx context.Context, id ConnectedEnvironmentId) (CertificatesListCompleteResult, error) { + return c.CertificatesListCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// CertificatesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConnectedEnvironmentsClient) CertificatesListCompleteMatchingPredicate(ctx context.Context, id ConnectedEnvironmentId, predicate CertificateOperationPredicate) (result CertificatesListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.CertificatesList(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 = CertificatesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesupdate.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesupdate.go new file mode 100644 index 00000000000..8685e29f2bd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_certificatesupdate.go @@ -0,0 +1,58 @@ +package connectedenvironments + +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 CertificatesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CertificatesUpdate ... +func (c ConnectedEnvironmentsClient) CertificatesUpdate(ctx context.Context, id ConnectedEnvironmentCertificateId, input CertificatePatch) (result CertificatesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_checknameavailability.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_checknameavailability.go new file mode 100644 index 00000000000..9d99735268b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_checknameavailability.go @@ -0,0 +1,59 @@ +package connectedenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResponse +} + +// CheckNameAvailability ... +func (c ConnectedEnvironmentsClient) CheckNameAvailability(ctx context.Context, id ConnectedEnvironmentId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_createorupdate.go new file mode 100644 index 00000000000..1653c1913bc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_createorupdate.go @@ -0,0 +1,75 @@ +package connectedenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ConnectedEnvironment +} + +// CreateOrUpdate ... +func (c ConnectedEnvironmentsClient) CreateOrUpdate(ctx context.Context, id ConnectedEnvironmentId, input ConnectedEnvironment) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ConnectedEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id ConnectedEnvironmentId, input ConnectedEnvironment) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_delete.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_delete.go new file mode 100644 index 00000000000..394b82bf66c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_delete.go @@ -0,0 +1,71 @@ +package connectedenvironments + +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 ConnectedEnvironmentsClient) Delete(ctx context.Context, id ConnectedEnvironmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ConnectedEnvironmentsClient) DeleteThenPoll(ctx context.Context, id ConnectedEnvironmentId) 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/containerapps/2024-03-01/connectedenvironments/method_get.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_get.go new file mode 100644 index 00000000000..16e0c9915d3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_get.go @@ -0,0 +1,54 @@ +package connectedenvironments + +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 *ConnectedEnvironment +} + +// Get ... +func (c ConnectedEnvironmentsClient) Get(ctx context.Context, id ConnectedEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectedEnvironment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbyresourcegroup.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..07302d27054 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package connectedenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ConnectedEnvironment +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ConnectedEnvironment +} + +// ListByResourceGroup ... +func (c ConnectedEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/connectedEnvironments", 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 *[]ConnectedEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ConnectedEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ConnectedEnvironmentOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConnectedEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ConnectedEnvironmentOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ConnectedEnvironment, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbysubscription.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbysubscription.go new file mode 100644 index 00000000000..ba8c18c7ab9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_listbysubscription.go @@ -0,0 +1,92 @@ +package connectedenvironments + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ConnectedEnvironment +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ConnectedEnvironment +} + +// ListBySubscription ... +func (c ConnectedEnvironmentsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/connectedEnvironments", 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 *[]ConnectedEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ConnectedEnvironmentsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ConnectedEnvironmentOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConnectedEnvironmentsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ConnectedEnvironmentOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ConnectedEnvironment, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/method_update.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_update.go new file mode 100644 index 00000000000..9c2f5c993a9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/method_update.go @@ -0,0 +1,54 @@ +package connectedenvironments + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectedEnvironment +} + +// Update ... +func (c ConnectedEnvironmentsClient) Update(ctx context.Context, id ConnectedEnvironmentId) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectedEnvironment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificate.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificate.go new file mode 100644 index 00000000000..e669656d0d5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificate.go @@ -0,0 +1,18 @@ +package connectedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificatepatch.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificatepatch.go new file mode 100644 index 00000000000..bde3c7a1618 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificatepatch.go @@ -0,0 +1,8 @@ +package connectedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatch struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificateproperties.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificateproperties.go new file mode 100644 index 00000000000..235153fac82 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_certificateproperties.go @@ -0,0 +1,48 @@ +package connectedenvironments + +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 CertificateProperties struct { + ExpirationDate *string `json:"expirationDate,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + Password *string `json:"password,omitempty"` + ProvisioningState *CertificateProvisioningState `json:"provisioningState,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SubjectAlternativeNames *[]string `json:"subjectAlternativeNames,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` + Value *string `json:"value,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityrequest.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityrequest.go new file mode 100644 index 00000000000..909f61a23c8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityrequest.go @@ -0,0 +1,9 @@ +package connectedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityresponse.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityresponse.go new file mode 100644 index 00000000000..93c8f443a29 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_checknameavailabilityresponse.go @@ -0,0 +1,10 @@ +package connectedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResponse struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *CheckNameAvailabilityReason `json:"reason,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironment.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironment.go new file mode 100644 index 00000000000..fb933c13075 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironment.go @@ -0,0 +1,19 @@ +package connectedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedEnvironment struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ConnectedEnvironmentProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironmentproperties.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironmentproperties.go new file mode 100644 index 00000000000..0804343a48a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_connectedenvironmentproperties.go @@ -0,0 +1,13 @@ +package connectedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedEnvironmentProperties struct { + CustomDomainConfiguration *CustomDomainConfiguration `json:"customDomainConfiguration,omitempty"` + DaprAIConnectionString *string `json:"daprAIConnectionString,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + ProvisioningState *ConnectedEnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_customdomainconfiguration.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_customdomainconfiguration.go new file mode 100644 index 00000000000..bd7ea9f039e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_customdomainconfiguration.go @@ -0,0 +1,32 @@ +package connectedenvironments + +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 CustomDomainConfiguration struct { + CertificatePassword *string `json:"certificatePassword,omitempty"` + CertificateValue *string `json:"certificateValue,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} + +func (o *CustomDomainConfiguration) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CustomDomainConfiguration) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/model_extendedlocation.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_extendedlocation.go new file mode 100644 index 00000000000..afe4338077a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/model_extendedlocation.go @@ -0,0 +1,9 @@ +package connectedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/predicates.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/predicates.go new file mode 100644 index 00000000000..56ab893afdf --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/predicates.go @@ -0,0 +1,60 @@ +package connectedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ConnectedEnvironmentOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ConnectedEnvironmentOperationPredicate) Matches(input ConnectedEnvironment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironments/version.go b/resource-manager/containerapps/2024-03-01/connectedenvironments/version.go new file mode 100644 index 00000000000..6c212398f63 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironments/version.go @@ -0,0 +1,12 @@ +package connectedenvironments + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/connectedenvironments/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/README.md b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/README.md new file mode 100644 index 00000000000..8356c5db965 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages` Documentation + +The `connectedenvironmentsstorages` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/connectedenvironmentsstorages" +``` + + +### Client Initialization + +```go +client := connectedenvironmentsstorages.NewConnectedEnvironmentsStoragesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ConnectedEnvironmentsStoragesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := connectedenvironmentsstorages.NewConnectedEnvironmentStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "storageValue") + +payload := connectedenvironmentsstorages.ConnectedEnvironmentStorage{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedEnvironmentsStoragesClient.Delete` + +```go +ctx := context.TODO() +id := connectedenvironmentsstorages.NewConnectedEnvironmentStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "storageValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedEnvironmentsStoragesClient.Get` + +```go +ctx := context.TODO() +id := connectedenvironmentsstorages.NewConnectedEnvironmentStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "storageValue") + +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: `ConnectedEnvironmentsStoragesClient.List` + +```go +ctx := context.TODO() +id := connectedenvironmentsstorages.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +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/containerapps/2024-03-01/connectedenvironmentsstorages/client.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/client.go new file mode 100644 index 00000000000..a216f239cfc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/client.go @@ -0,0 +1,26 @@ +package connectedenvironmentsstorages + +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 ConnectedEnvironmentsStoragesClient struct { + Client *resourcemanager.Client +} + +func NewConnectedEnvironmentsStoragesClientWithBaseURI(sdkApi sdkEnv.Api) (*ConnectedEnvironmentsStoragesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "connectedenvironmentsstorages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConnectedEnvironmentsStoragesClient: %+v", err) + } + + return &ConnectedEnvironmentsStoragesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/constants.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/constants.go new file mode 100644 index 00000000000..fd1b71dbed2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/constants.go @@ -0,0 +1,51 @@ +package connectedenvironmentsstorages + +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 AccessMode string + +const ( + AccessModeReadOnly AccessMode = "ReadOnly" + AccessModeReadWrite AccessMode = "ReadWrite" +) + +func PossibleValuesForAccessMode() []string { + return []string{ + string(AccessModeReadOnly), + string(AccessModeReadWrite), + } +} + +func (s *AccessMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccessMode(input string) (*AccessMode, error) { + vals := map[string]AccessMode{ + "readonly": AccessModeReadOnly, + "readwrite": AccessModeReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessMode(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment.go new file mode 100644 index 00000000000..8896dd215dd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment.go @@ -0,0 +1,130 @@ +package connectedenvironmentsstorages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentId{} + +// ConnectedEnvironmentId is a struct representing the Resource ID for a Connected Environment +type ConnectedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string +} + +// NewConnectedEnvironmentID returns a new ConnectedEnvironmentId struct +func NewConnectedEnvironmentID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string) ConnectedEnvironmentId { + return ConnectedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + } +} + +// ParseConnectedEnvironmentID parses 'input' into a ConnectedEnvironmentId +func ParseConnectedEnvironmentID(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentIDInsensitively(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentID checks that 'input' can be parsed as a Connected Environment ID +func ValidateConnectedEnvironmentID(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 := ParseConnectedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment ID +func (id ConnectedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment ID +func (id ConnectedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Connected Environment ID +func (id ConnectedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + } + return fmt.Sprintf("Connected Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment_test.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment_test.go new file mode 100644 index 00000000000..17276b39f25 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironment_test.go @@ -0,0 +1,282 @@ +package connectedenvironmentsstorages + +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 = &ConnectedEnvironmentId{} + +func TestNewConnectedEnvironmentID(t *testing.T) { + id := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } +} + +func TestFormatConnectedEnvironmentID(t *testing.T) { + actual := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestParseConnectedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentId(t *testing.T) { + segments := ConnectedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentId 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/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage.go new file mode 100644 index 00000000000..bcdb639d7ac --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage.go @@ -0,0 +1,139 @@ +package connectedenvironmentsstorages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentStorageId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentStorageId{} + +// ConnectedEnvironmentStorageId is a struct representing the Resource ID for a Connected Environment Storage +type ConnectedEnvironmentStorageId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string + StorageName string +} + +// NewConnectedEnvironmentStorageID returns a new ConnectedEnvironmentStorageId struct +func NewConnectedEnvironmentStorageID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string, storageName string) ConnectedEnvironmentStorageId { + return ConnectedEnvironmentStorageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + StorageName: storageName, + } +} + +// ParseConnectedEnvironmentStorageID parses 'input' into a ConnectedEnvironmentStorageId +func ParseConnectedEnvironmentStorageID(input string) (*ConnectedEnvironmentStorageId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentStorageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentStorageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentStorageIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentStorageId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentStorageIDInsensitively(input string) (*ConnectedEnvironmentStorageId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentStorageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentStorageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentStorageId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + if id.StorageName, ok = input.Parsed["storageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storageName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentStorageID checks that 'input' can be parsed as a Connected Environment Storage ID +func ValidateConnectedEnvironmentStorageID(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 := ParseConnectedEnvironmentStorageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment Storage ID +func (id ConnectedEnvironmentStorageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s/storages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName, id.StorageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment Storage ID +func (id ConnectedEnvironmentStorageId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + resourceids.StaticSegment("staticStorages", "storages", "storages"), + resourceids.UserSpecifiedSegment("storageName", "storageValue"), + } +} + +// String returns a human-readable description of this Connected Environment Storage ID +func (id ConnectedEnvironmentStorageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + fmt.Sprintf("Storage Name: %q", id.StorageName), + } + return fmt.Sprintf("Connected Environment Storage (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage_test.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage_test.go new file mode 100644 index 00000000000..e0cb36418c9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/id_connectedenvironmentstorage_test.go @@ -0,0 +1,327 @@ +package connectedenvironmentsstorages + +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 = &ConnectedEnvironmentStorageId{} + +func TestNewConnectedEnvironmentStorageID(t *testing.T) { + id := NewConnectedEnvironmentStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "storageValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } + + if id.StorageName != "storageValue" { + t.Fatalf("Expected %q but got %q for Segment 'StorageName'", id.StorageName, "storageValue") + } +} + +func TestFormatConnectedEnvironmentStorageID(t *testing.T) { + actual := NewConnectedEnvironmentStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "storageValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/storages/storageValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentStorageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentStorageId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/storages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/storages/storageValue", + Expected: &ConnectedEnvironmentStorageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + StorageName: "storageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/storages/storageValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentStorageID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.StorageName != v.Expected.StorageName { + t.Fatalf("Expected %q but got %q for StorageName", v.Expected.StorageName, actual.StorageName) + } + + } +} + +func TestParseConnectedEnvironmentStorageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentStorageId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/storages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/sToRaGeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/storages/storageValue", + Expected: &ConnectedEnvironmentStorageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + StorageName: "storageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/storages/storageValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/sToRaGeS/sToRaGeVaLuE", + Expected: &ConnectedEnvironmentStorageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + StorageName: "sToRaGeVaLuE", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/sToRaGeS/sToRaGeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentStorageIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.StorageName != v.Expected.StorageName { + t.Fatalf("Expected %q but got %q for StorageName", v.Expected.StorageName, actual.StorageName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentStorageId(t *testing.T) { + segments := ConnectedEnvironmentStorageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentStorageId 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/containerapps/2024-03-01/connectedenvironmentsstorages/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_createorupdate.go new file mode 100644 index 00000000000..66a61f10f69 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_createorupdate.go @@ -0,0 +1,58 @@ +package connectedenvironmentsstorages + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectedEnvironmentStorage +} + +// CreateOrUpdate ... +func (c ConnectedEnvironmentsStoragesClient) CreateOrUpdate(ctx context.Context, id ConnectedEnvironmentStorageId, input ConnectedEnvironmentStorage) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectedEnvironmentStorage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_delete.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_delete.go new file mode 100644 index 00000000000..f3ac6d8b309 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_delete.go @@ -0,0 +1,47 @@ +package connectedenvironmentsstorages + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ConnectedEnvironmentsStoragesClient) Delete(ctx context.Context, id ConnectedEnvironmentStorageId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_get.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_get.go new file mode 100644 index 00000000000..bb888e00447 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_get.go @@ -0,0 +1,54 @@ +package connectedenvironmentsstorages + +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 *ConnectedEnvironmentStorage +} + +// Get ... +func (c ConnectedEnvironmentsStoragesClient) Get(ctx context.Context, id ConnectedEnvironmentStorageId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectedEnvironmentStorage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_list.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_list.go new file mode 100644 index 00000000000..6faefbeb2db --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/method_list.go @@ -0,0 +1,55 @@ +package connectedenvironmentsstorages + +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 *ConnectedEnvironmentStoragesCollection +} + +// List ... +func (c ConnectedEnvironmentsStoragesClient) List(ctx context.Context, id ConnectedEnvironmentId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/storages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectedEnvironmentStoragesCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_azurefileproperties.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_azurefileproperties.go new file mode 100644 index 00000000000..1aafd335320 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_azurefileproperties.go @@ -0,0 +1,11 @@ +package connectedenvironmentsstorages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileProperties struct { + AccessMode *AccessMode `json:"accessMode,omitempty"` + AccountKey *string `json:"accountKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + ShareName *string `json:"shareName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorage.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorage.go new file mode 100644 index 00000000000..35a00599e24 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorage.go @@ -0,0 +1,16 @@ +package connectedenvironmentsstorages + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedEnvironmentStorage struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ConnectedEnvironmentStorageProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorageproperties.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorageproperties.go new file mode 100644 index 00000000000..e9150596c08 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstorageproperties.go @@ -0,0 +1,8 @@ +package connectedenvironmentsstorages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedEnvironmentStorageProperties struct { + AzureFile *AzureFileProperties `json:"azureFile,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstoragescollection.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstoragescollection.go new file mode 100644 index 00000000000..a17921d81b7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/model_connectedenvironmentstoragescollection.go @@ -0,0 +1,8 @@ +package connectedenvironmentsstorages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedEnvironmentStoragesCollection struct { + Value []ConnectedEnvironmentStorage `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/version.go b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/version.go new file mode 100644 index 00000000000..b4886280260 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/connectedenvironmentsstorages/version.go @@ -0,0 +1,12 @@ +package connectedenvironmentsstorages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/connectedenvironmentsstorages/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/README.md b/resource-manager/containerapps/2024-03-01/containerapps/README.md new file mode 100644 index 00000000000..32625e67164 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/README.md @@ -0,0 +1,271 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerapps` Documentation + +The `containerapps` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/containerapps" +``` + + +### Client Initialization + +```go +client := containerapps.NewContainerAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +payload := containerapps.ContainerApp{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.Delete` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.DiagnosticsGetDetector` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "detectorValue") + +read, err := client.DiagnosticsGetDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsClient.DiagnosticsGetRevision` + +```go +ctx := context.TODO() +id := containerapps.NewRevisionsApiRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.DiagnosticsGetRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsClient.DiagnosticsGetRoot` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +read, err := client.DiagnosticsGetRoot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsClient.DiagnosticsListDetectors` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.DiagnosticsListDetectors(ctx, id)` can be used to do batched pagination +items, err := client.DiagnosticsListDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.DiagnosticsListRevisions` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.DiagnosticsListRevisions(ctx, id, containerapps.DefaultDiagnosticsListRevisionsOperationOptions())` can be used to do batched pagination +items, err := client.DiagnosticsListRevisionsComplete(ctx, id, containerapps.DefaultDiagnosticsListRevisionsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.Get` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +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: `ContainerAppsClient.GetAuthToken` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +read, err := client.GetAuthToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.ListCustomHostNameAnalysis` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +read, err := client.ListCustomHostNameAnalysis(ctx, id, containerapps.DefaultListCustomHostNameAnalysisOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsClient.ListSecrets` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +read, err := client.ListSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsClient.Start` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.Stop` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.Update` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +payload := containerapps.ContainerApp{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/containerapps/2024-03-01/containerapps/client.go b/resource-manager/containerapps/2024-03-01/containerapps/client.go new file mode 100644 index 00000000000..65599ae354f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/client.go @@ -0,0 +1,26 @@ +package containerapps + +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 ContainerAppsClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsClient: %+v", err) + } + + return &ContainerAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/constants.go b/resource-manager/containerapps/2024-03-01/containerapps/constants.go new file mode 100644 index 00000000000..e3a27e14d03 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/constants.go @@ -0,0 +1,761 @@ +package containerapps + +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 Action string + +const ( + ActionAllow Action = "Allow" + ActionDeny Action = "Deny" +) + +func PossibleValuesForAction() []string { + return []string{ + string(ActionAllow), + string(ActionDeny), + } +} + +func (s *Action) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAction(input string) (*Action, error) { + vals := map[string]Action{ + "allow": ActionAllow, + "deny": ActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Action(input) + return &out, nil +} + +type ActiveRevisionsMode string + +const ( + ActiveRevisionsModeMultiple ActiveRevisionsMode = "Multiple" + ActiveRevisionsModeSingle ActiveRevisionsMode = "Single" +) + +func PossibleValuesForActiveRevisionsMode() []string { + return []string{ + string(ActiveRevisionsModeMultiple), + string(ActiveRevisionsModeSingle), + } +} + +func (s *ActiveRevisionsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveRevisionsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActiveRevisionsMode(input string) (*ActiveRevisionsMode, error) { + vals := map[string]ActiveRevisionsMode{ + "multiple": ActiveRevisionsModeMultiple, + "single": ActiveRevisionsModeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActiveRevisionsMode(input) + return &out, nil +} + +type Affinity string + +const ( + AffinityNone Affinity = "none" + AffinitySticky Affinity = "sticky" +) + +func PossibleValuesForAffinity() []string { + return []string{ + string(AffinityNone), + string(AffinitySticky), + } +} + +func (s *Affinity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAffinity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAffinity(input string) (*Affinity, error) { + vals := map[string]Affinity{ + "none": AffinityNone, + "sticky": AffinitySticky, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Affinity(input) + return &out, nil +} + +type AppProtocol string + +const ( + AppProtocolGrpc AppProtocol = "grpc" + AppProtocolHTTP AppProtocol = "http" +) + +func PossibleValuesForAppProtocol() []string { + return []string{ + string(AppProtocolGrpc), + string(AppProtocolHTTP), + } +} + +func (s *AppProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAppProtocol(input string) (*AppProtocol, error) { + vals := map[string]AppProtocol{ + "grpc": AppProtocolGrpc, + "http": AppProtocolHTTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AppProtocol(input) + return &out, nil +} + +type BindingType string + +const ( + BindingTypeDisabled BindingType = "Disabled" + BindingTypeSniEnabled BindingType = "SniEnabled" +) + +func PossibleValuesForBindingType() []string { + return []string{ + string(BindingTypeDisabled), + string(BindingTypeSniEnabled), + } +} + +func (s *BindingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBindingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBindingType(input string) (*BindingType, error) { + vals := map[string]BindingType{ + "disabled": BindingTypeDisabled, + "snienabled": BindingTypeSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BindingType(input) + return &out, nil +} + +type ContainerAppProvisioningState string + +const ( + ContainerAppProvisioningStateCanceled ContainerAppProvisioningState = "Canceled" + ContainerAppProvisioningStateDeleting ContainerAppProvisioningState = "Deleting" + ContainerAppProvisioningStateFailed ContainerAppProvisioningState = "Failed" + ContainerAppProvisioningStateInProgress ContainerAppProvisioningState = "InProgress" + ContainerAppProvisioningStateSucceeded ContainerAppProvisioningState = "Succeeded" +) + +func PossibleValuesForContainerAppProvisioningState() []string { + return []string{ + string(ContainerAppProvisioningStateCanceled), + string(ContainerAppProvisioningStateDeleting), + string(ContainerAppProvisioningStateFailed), + string(ContainerAppProvisioningStateInProgress), + string(ContainerAppProvisioningStateSucceeded), + } +} + +func (s *ContainerAppProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerAppProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerAppProvisioningState(input string) (*ContainerAppProvisioningState, error) { + vals := map[string]ContainerAppProvisioningState{ + "canceled": ContainerAppProvisioningStateCanceled, + "deleting": ContainerAppProvisioningStateDeleting, + "failed": ContainerAppProvisioningStateFailed, + "inprogress": ContainerAppProvisioningStateInProgress, + "succeeded": ContainerAppProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerAppProvisioningState(input) + return &out, nil +} + +type DnsVerificationTestResult string + +const ( + DnsVerificationTestResultFailed DnsVerificationTestResult = "Failed" + DnsVerificationTestResultPassed DnsVerificationTestResult = "Passed" + DnsVerificationTestResultSkipped DnsVerificationTestResult = "Skipped" +) + +func PossibleValuesForDnsVerificationTestResult() []string { + return []string{ + string(DnsVerificationTestResultFailed), + string(DnsVerificationTestResultPassed), + string(DnsVerificationTestResultSkipped), + } +} + +func (s *DnsVerificationTestResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsVerificationTestResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsVerificationTestResult(input string) (*DnsVerificationTestResult, error) { + vals := map[string]DnsVerificationTestResult{ + "failed": DnsVerificationTestResultFailed, + "passed": DnsVerificationTestResultPassed, + "skipped": DnsVerificationTestResultSkipped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsVerificationTestResult(input) + return &out, nil +} + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type IngressClientCertificateMode string + +const ( + IngressClientCertificateModeAccept IngressClientCertificateMode = "accept" + IngressClientCertificateModeIgnore IngressClientCertificateMode = "ignore" + IngressClientCertificateModeRequire IngressClientCertificateMode = "require" +) + +func PossibleValuesForIngressClientCertificateMode() []string { + return []string{ + string(IngressClientCertificateModeAccept), + string(IngressClientCertificateModeIgnore), + string(IngressClientCertificateModeRequire), + } +} + +func (s *IngressClientCertificateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIngressClientCertificateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIngressClientCertificateMode(input string) (*IngressClientCertificateMode, error) { + vals := map[string]IngressClientCertificateMode{ + "accept": IngressClientCertificateModeAccept, + "ignore": IngressClientCertificateModeIgnore, + "require": IngressClientCertificateModeRequire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IngressClientCertificateMode(input) + return &out, nil +} + +type IngressTransportMethod string + +const ( + IngressTransportMethodAuto IngressTransportMethod = "auto" + IngressTransportMethodHTTP IngressTransportMethod = "http" + IngressTransportMethodHTTPTwo IngressTransportMethod = "http2" + IngressTransportMethodTcp IngressTransportMethod = "tcp" +) + +func PossibleValuesForIngressTransportMethod() []string { + return []string{ + string(IngressTransportMethodAuto), + string(IngressTransportMethodHTTP), + string(IngressTransportMethodHTTPTwo), + string(IngressTransportMethodTcp), + } +} + +func (s *IngressTransportMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIngressTransportMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIngressTransportMethod(input string) (*IngressTransportMethod, error) { + vals := map[string]IngressTransportMethod{ + "auto": IngressTransportMethodAuto, + "http": IngressTransportMethodHTTP, + "http2": IngressTransportMethodHTTPTwo, + "tcp": IngressTransportMethodTcp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IngressTransportMethod(input) + return &out, nil +} + +type LogLevel string + +const ( + LogLevelDebug LogLevel = "debug" + LogLevelError LogLevel = "error" + LogLevelInfo LogLevel = "info" + LogLevelWarn LogLevel = "warn" +) + +func PossibleValuesForLogLevel() []string { + return []string{ + string(LogLevelDebug), + string(LogLevelError), + string(LogLevelInfo), + string(LogLevelWarn), + } +} + +func (s *LogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogLevel(input string) (*LogLevel, error) { + vals := map[string]LogLevel{ + "debug": LogLevelDebug, + "error": LogLevelError, + "info": LogLevelInfo, + "warn": LogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogLevel(input) + return &out, nil +} + +type RevisionHealthState string + +const ( + RevisionHealthStateHealthy RevisionHealthState = "Healthy" + RevisionHealthStateNone RevisionHealthState = "None" + RevisionHealthStateUnhealthy RevisionHealthState = "Unhealthy" +) + +func PossibleValuesForRevisionHealthState() []string { + return []string{ + string(RevisionHealthStateHealthy), + string(RevisionHealthStateNone), + string(RevisionHealthStateUnhealthy), + } +} + +func (s *RevisionHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionHealthState(input string) (*RevisionHealthState, error) { + vals := map[string]RevisionHealthState{ + "healthy": RevisionHealthStateHealthy, + "none": RevisionHealthStateNone, + "unhealthy": RevisionHealthStateUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionHealthState(input) + return &out, nil +} + +type RevisionProvisioningState string + +const ( + RevisionProvisioningStateDeprovisioned RevisionProvisioningState = "Deprovisioned" + RevisionProvisioningStateDeprovisioning RevisionProvisioningState = "Deprovisioning" + RevisionProvisioningStateFailed RevisionProvisioningState = "Failed" + RevisionProvisioningStateProvisioned RevisionProvisioningState = "Provisioned" + RevisionProvisioningStateProvisioning RevisionProvisioningState = "Provisioning" +) + +func PossibleValuesForRevisionProvisioningState() []string { + return []string{ + string(RevisionProvisioningStateDeprovisioned), + string(RevisionProvisioningStateDeprovisioning), + string(RevisionProvisioningStateFailed), + string(RevisionProvisioningStateProvisioned), + string(RevisionProvisioningStateProvisioning), + } +} + +func (s *RevisionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionProvisioningState(input string) (*RevisionProvisioningState, error) { + vals := map[string]RevisionProvisioningState{ + "deprovisioned": RevisionProvisioningStateDeprovisioned, + "deprovisioning": RevisionProvisioningStateDeprovisioning, + "failed": RevisionProvisioningStateFailed, + "provisioned": RevisionProvisioningStateProvisioned, + "provisioning": RevisionProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionProvisioningState(input) + return &out, nil +} + +type RevisionRunningState string + +const ( + RevisionRunningStateDegraded RevisionRunningState = "Degraded" + RevisionRunningStateFailed RevisionRunningState = "Failed" + RevisionRunningStateProcessing RevisionRunningState = "Processing" + RevisionRunningStateRunning RevisionRunningState = "Running" + RevisionRunningStateStopped RevisionRunningState = "Stopped" + RevisionRunningStateUnknown RevisionRunningState = "Unknown" +) + +func PossibleValuesForRevisionRunningState() []string { + return []string{ + string(RevisionRunningStateDegraded), + string(RevisionRunningStateFailed), + string(RevisionRunningStateProcessing), + string(RevisionRunningStateRunning), + string(RevisionRunningStateStopped), + string(RevisionRunningStateUnknown), + } +} + +func (s *RevisionRunningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionRunningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionRunningState(input string) (*RevisionRunningState, error) { + vals := map[string]RevisionRunningState{ + "degraded": RevisionRunningStateDegraded, + "failed": RevisionRunningStateFailed, + "processing": RevisionRunningStateProcessing, + "running": RevisionRunningStateRunning, + "stopped": RevisionRunningStateStopped, + "unknown": RevisionRunningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionRunningState(input) + return &out, nil +} + +type Scheme string + +const ( + SchemeHTTP Scheme = "HTTP" + SchemeHTTPS Scheme = "HTTPS" +) + +func PossibleValuesForScheme() []string { + return []string{ + string(SchemeHTTP), + string(SchemeHTTPS), + } +} + +func (s *Scheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheme(input string) (*Scheme, error) { + vals := map[string]Scheme{ + "http": SchemeHTTP, + "https": SchemeHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Scheme(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeAzureFile StorageType = "AzureFile" + StorageTypeEmptyDir StorageType = "EmptyDir" + StorageTypeSecret StorageType = "Secret" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeAzureFile), + string(StorageTypeEmptyDir), + string(StorageTypeSecret), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "azurefile": StorageTypeAzureFile, + "emptydir": StorageTypeEmptyDir, + "secret": StorageTypeSecret, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type Type string + +const ( + TypeLiveness Type = "Liveness" + TypeReadiness Type = "Readiness" + TypeStartup Type = "Startup" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeLiveness), + string(TypeReadiness), + string(TypeStartup), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "liveness": TypeLiveness, + "readiness": TypeReadiness, + "startup": TypeStartup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/id_containerapp.go b/resource-manager/containerapps/2024-03-01/containerapps/id_containerapp.go new file mode 100644 index 00000000000..bfd98ec0555 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/id_containerapp.go @@ -0,0 +1,130 @@ +package containerapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppId{}) +} + +var _ resourceids.ResourceId = &ContainerAppId{} + +// ContainerAppId is a struct representing the Resource ID for a Container App +type ContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewContainerAppID returns a new ContainerAppId struct +func NewContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ContainerAppId { + return ContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseContainerAppID parses 'input' into a ContainerAppId +func ParseContainerAppID(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppIDInsensitively parses 'input' case-insensitively into a ContainerAppId +// note: this method should only be used for API response data and not user input +func ParseContainerAppIDInsensitively(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateContainerAppID checks that 'input' can be parsed as a Container App ID +func ValidateContainerAppID(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 := ParseContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App ID +func (id ContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App ID +func (id ContainerAppId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Container App ID +func (id ContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/id_containerapp_test.go b/resource-manager/containerapps/2024-03-01/containerapps/id_containerapp_test.go new file mode 100644 index 00000000000..c5b469a43cf --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/id_containerapp_test.go @@ -0,0 +1,282 @@ +package containerapps + +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 = &ContainerAppId{} + +func TestNewContainerAppID(t *testing.T) { + id := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatContainerAppID(t *testing.T) { + actual := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForContainerAppId(t *testing.T) { + segments := ContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppId 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/containerapps/2024-03-01/containerapps/id_containerappdetector.go b/resource-manager/containerapps/2024-03-01/containerapps/id_containerappdetector.go new file mode 100644 index 00000000000..cb4cc8c877c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/id_containerappdetector.go @@ -0,0 +1,139 @@ +package containerapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppDetectorId{}) +} + +var _ resourceids.ResourceId = &ContainerAppDetectorId{} + +// ContainerAppDetectorId is a struct representing the Resource ID for a Container App Detector +type ContainerAppDetectorId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + DetectorName string +} + +// NewContainerAppDetectorID returns a new ContainerAppDetectorId struct +func NewContainerAppDetectorID(subscriptionId string, resourceGroupName string, containerAppName string, detectorName string) ContainerAppDetectorId { + return ContainerAppDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + DetectorName: detectorName, + } +} + +// ParseContainerAppDetectorID parses 'input' into a ContainerAppDetectorId +func ParseContainerAppDetectorID(input string) (*ContainerAppDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppDetectorIDInsensitively parses 'input' case-insensitively into a ContainerAppDetectorId +// note: this method should only be used for API response data and not user input +func ParseContainerAppDetectorIDInsensitively(input string) (*ContainerAppDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppDetectorId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateContainerAppDetectorID checks that 'input' can be parsed as a Container App Detector ID +func ValidateContainerAppDetectorID(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 := ParseContainerAppDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App Detector ID +func (id ContainerAppDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App Detector ID +func (id ContainerAppDetectorId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Container App Detector ID +func (id ContainerAppDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Container App Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/id_containerappdetector_test.go b/resource-manager/containerapps/2024-03-01/containerapps/id_containerappdetector_test.go new file mode 100644 index 00000000000..d7e4f8692ae --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/id_containerappdetector_test.go @@ -0,0 +1,327 @@ +package containerapps + +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 = &ContainerAppDetectorId{} + +func TestNewContainerAppDetectorID(t *testing.T) { + id := NewContainerAppDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "detectorValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatContainerAppDetectorID(t *testing.T) { + actual := NewContainerAppDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue", + Expected: &ContainerAppDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseContainerAppDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue", + Expected: &ContainerAppDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &ContainerAppDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForContainerAppDetectorId(t *testing.T) { + segments := ContainerAppDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppDetectorId 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/containerapps/2024-03-01/containerapps/id_revisionsapirevision.go b/resource-manager/containerapps/2024-03-01/containerapps/id_revisionsapirevision.go new file mode 100644 index 00000000000..cf7fcd3b4e9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/id_revisionsapirevision.go @@ -0,0 +1,141 @@ +package containerapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RevisionsApiRevisionId{}) +} + +var _ resourceids.ResourceId = &RevisionsApiRevisionId{} + +// RevisionsApiRevisionId is a struct representing the Resource ID for a Revisions Api Revision +type RevisionsApiRevisionId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + RevisionName string +} + +// NewRevisionsApiRevisionID returns a new RevisionsApiRevisionId struct +func NewRevisionsApiRevisionID(subscriptionId string, resourceGroupName string, containerAppName string, revisionName string) RevisionsApiRevisionId { + return RevisionsApiRevisionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + RevisionName: revisionName, + } +} + +// ParseRevisionsApiRevisionID parses 'input' into a RevisionsApiRevisionId +func ParseRevisionsApiRevisionID(input string) (*RevisionsApiRevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionsApiRevisionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionsApiRevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRevisionsApiRevisionIDInsensitively parses 'input' case-insensitively into a RevisionsApiRevisionId +// note: this method should only be used for API response data and not user input +func ParseRevisionsApiRevisionIDInsensitively(input string) (*RevisionsApiRevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionsApiRevisionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionsApiRevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RevisionsApiRevisionId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.RevisionName, ok = input.Parsed["revisionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "revisionName", input) + } + + return nil +} + +// ValidateRevisionsApiRevisionID checks that 'input' can be parsed as a Revisions Api Revision ID +func ValidateRevisionsApiRevisionID(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 := ParseRevisionsApiRevisionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Revisions Api Revision ID +func (id RevisionsApiRevisionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/detectorProperties/revisionsApi/revisions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.RevisionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Revisions Api Revision ID +func (id RevisionsApiRevisionId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticDetectorProperties", "detectorProperties", "detectorProperties"), + resourceids.StaticSegment("staticRevisionsApi", "revisionsApi", "revisionsApi"), + resourceids.StaticSegment("staticRevisions", "revisions", "revisions"), + resourceids.UserSpecifiedSegment("revisionName", "revisionValue"), + } +} + +// String returns a human-readable description of this Revisions Api Revision ID +func (id RevisionsApiRevisionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Revision Name: %q", id.RevisionName), + } + return fmt.Sprintf("Revisions Api Revision (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/id_revisionsapirevision_test.go b/resource-manager/containerapps/2024-03-01/containerapps/id_revisionsapirevision_test.go new file mode 100644 index 00000000000..6a79ea20bfd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/id_revisionsapirevision_test.go @@ -0,0 +1,357 @@ +package containerapps + +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 = &RevisionsApiRevisionId{} + +func TestNewRevisionsApiRevisionID(t *testing.T) { + id := NewRevisionsApiRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.RevisionName != "revisionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RevisionName'", id.RevisionName, "revisionValue") + } +} + +func TestFormatRevisionsApiRevisionID(t *testing.T) { + actual := NewRevisionsApiRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRevisionsApiRevisionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionsApiRevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue", + Expected: &RevisionsApiRevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionsApiRevisionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestParseRevisionsApiRevisionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionsApiRevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI/rEvIsIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue", + Expected: &RevisionsApiRevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI/rEvIsIoNs/rEvIsIoNvAlUe", + Expected: &RevisionsApiRevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + RevisionName: "rEvIsIoNvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI/rEvIsIoNs/rEvIsIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionsApiRevisionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestSegmentsForRevisionsApiRevisionId(t *testing.T) { + segments := RevisionsApiRevisionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RevisionsApiRevisionId 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/containerapps/2024-03-01/containerapps/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/containerapps/method_createorupdate.go new file mode 100644 index 00000000000..5db04646129 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_createorupdate.go @@ -0,0 +1,75 @@ +package containerapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ContainerApp +} + +// CreateOrUpdate ... +func (c ContainerAppsClient) CreateOrUpdate(ctx context.Context, id ContainerAppId, input ContainerApp) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ContainerAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id ContainerAppId, input ContainerApp) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_delete.go b/resource-manager/containerapps/2024-03-01/containerapps/method_delete.go new file mode 100644 index 00000000000..049bcddb705 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_delete.go @@ -0,0 +1,71 @@ +package containerapps + +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 ContainerAppsClient) Delete(ctx context.Context, id ContainerAppId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ContainerAppsClient) DeleteThenPoll(ctx context.Context, id ContainerAppId) 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/containerapps/2024-03-01/containerapps/method_diagnosticsgetdetector.go b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetdetector.go new file mode 100644 index 00000000000..2cb3d1d5723 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetdetector.go @@ -0,0 +1,54 @@ +package containerapps + +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 DiagnosticsGetDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Diagnostics +} + +// DiagnosticsGetDetector ... +func (c ContainerAppsClient) DiagnosticsGetDetector(ctx context.Context, id ContainerAppDetectorId) (result DiagnosticsGetDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Diagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetrevision.go b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetrevision.go new file mode 100644 index 00000000000..376c7031e06 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetrevision.go @@ -0,0 +1,54 @@ +package containerapps + +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 DiagnosticsGetRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Revision +} + +// DiagnosticsGetRevision ... +func (c ContainerAppsClient) DiagnosticsGetRevision(ctx context.Context, id RevisionsApiRevisionId) (result DiagnosticsGetRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Revision + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetroot.go b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetroot.go new file mode 100644 index 00000000000..f21a7434252 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticsgetroot.go @@ -0,0 +1,55 @@ +package containerapps + +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 DiagnosticsGetRootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContainerApp +} + +// DiagnosticsGetRoot ... +func (c ContainerAppsClient) DiagnosticsGetRoot(ctx context.Context, id ContainerAppId) (result DiagnosticsGetRootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectorProperties/rootApi", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContainerApp + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistdetectors.go b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistdetectors.go new file mode 100644 index 00000000000..029f93db2cc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistdetectors.go @@ -0,0 +1,91 @@ +package containerapps + +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 DiagnosticsListDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Diagnostics +} + +type DiagnosticsListDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Diagnostics +} + +// DiagnosticsListDetectors ... +func (c ContainerAppsClient) DiagnosticsListDetectors(ctx context.Context, id ContainerAppId) (result DiagnosticsListDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]Diagnostics `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DiagnosticsListDetectorsComplete retrieves all the results into a single object +func (c ContainerAppsClient) DiagnosticsListDetectorsComplete(ctx context.Context, id ContainerAppId) (DiagnosticsListDetectorsCompleteResult, error) { + return c.DiagnosticsListDetectorsCompleteMatchingPredicate(ctx, id, DiagnosticsOperationPredicate{}) +} + +// DiagnosticsListDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) DiagnosticsListDetectorsCompleteMatchingPredicate(ctx context.Context, id ContainerAppId, predicate DiagnosticsOperationPredicate) (result DiagnosticsListDetectorsCompleteResult, err error) { + items := make([]Diagnostics, 0) + + resp, err := c.DiagnosticsListDetectors(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 = DiagnosticsListDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistrevisions.go b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistrevisions.go new file mode 100644 index 00000000000..d997c92fab8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_diagnosticslistrevisions.go @@ -0,0 +1,119 @@ +package containerapps + +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 DiagnosticsListRevisionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Revision +} + +type DiagnosticsListRevisionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Revision +} + +type DiagnosticsListRevisionsOperationOptions struct { + Filter *string +} + +func DefaultDiagnosticsListRevisionsOperationOptions() DiagnosticsListRevisionsOperationOptions { + return DiagnosticsListRevisionsOperationOptions{} +} + +func (o DiagnosticsListRevisionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DiagnosticsListRevisionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DiagnosticsListRevisionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// DiagnosticsListRevisions ... +func (c ContainerAppsClient) DiagnosticsListRevisions(ctx context.Context, id ContainerAppId, options DiagnosticsListRevisionsOperationOptions) (result DiagnosticsListRevisionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectorProperties/revisionsApi/revisions", 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 *[]Revision `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DiagnosticsListRevisionsComplete retrieves all the results into a single object +func (c ContainerAppsClient) DiagnosticsListRevisionsComplete(ctx context.Context, id ContainerAppId, options DiagnosticsListRevisionsOperationOptions) (DiagnosticsListRevisionsCompleteResult, error) { + return c.DiagnosticsListRevisionsCompleteMatchingPredicate(ctx, id, options, RevisionOperationPredicate{}) +} + +// DiagnosticsListRevisionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) DiagnosticsListRevisionsCompleteMatchingPredicate(ctx context.Context, id ContainerAppId, options DiagnosticsListRevisionsOperationOptions, predicate RevisionOperationPredicate) (result DiagnosticsListRevisionsCompleteResult, err error) { + items := make([]Revision, 0) + + resp, err := c.DiagnosticsListRevisions(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 = DiagnosticsListRevisionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_get.go b/resource-manager/containerapps/2024-03-01/containerapps/method_get.go new file mode 100644 index 00000000000..1cf49840634 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_get.go @@ -0,0 +1,54 @@ +package containerapps + +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 *ContainerApp +} + +// Get ... +func (c ContainerAppsClient) Get(ctx context.Context, id ContainerAppId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContainerApp + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_getauthtoken.go b/resource-manager/containerapps/2024-03-01/containerapps/method_getauthtoken.go new file mode 100644 index 00000000000..33667cea14c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_getauthtoken.go @@ -0,0 +1,55 @@ +package containerapps + +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 GetAuthTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContainerAppAuthToken +} + +// GetAuthToken ... +func (c ContainerAppsClient) GetAuthToken(ctx context.Context, id ContainerAppId) (result GetAuthTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getAuthtoken", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContainerAppAuthToken + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_listbyresourcegroup.go b/resource-manager/containerapps/2024-03-01/containerapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..81c64a01fc9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package containerapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContainerApp +} + +// ListByResourceGroup ... +func (c ContainerAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/containerApps", 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 *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ContainerAppOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_listbysubscription.go b/resource-manager/containerapps/2024-03-01/containerapps/method_listbysubscription.go new file mode 100644 index 00000000000..b8bd2fb6a1f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_listbysubscription.go @@ -0,0 +1,92 @@ +package containerapps + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContainerApp +} + +// ListBySubscription ... +func (c ContainerAppsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/containerApps", 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 *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ContainerAppOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_listcustomhostnameanalysis.go b/resource-manager/containerapps/2024-03-01/containerapps/method_listcustomhostnameanalysis.go new file mode 100644 index 00000000000..396d1751905 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_listcustomhostnameanalysis.go @@ -0,0 +1,83 @@ +package containerapps + +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 ListCustomHostNameAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type ListCustomHostNameAnalysisOperationOptions struct { + CustomHostname *string +} + +func DefaultListCustomHostNameAnalysisOperationOptions() ListCustomHostNameAnalysisOperationOptions { + return ListCustomHostNameAnalysisOperationOptions{} +} + +func (o ListCustomHostNameAnalysisOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListCustomHostNameAnalysisOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListCustomHostNameAnalysisOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.CustomHostname != nil { + out.Append("customHostname", fmt.Sprintf("%v", *o.CustomHostname)) + } + return &out +} + +// ListCustomHostNameAnalysis ... +func (c ContainerAppsClient) ListCustomHostNameAnalysis(ctx context.Context, id ContainerAppId, options ListCustomHostNameAnalysisOperationOptions) (result ListCustomHostNameAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listCustomHostNameAnalysis", 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 + } + + var model CustomHostnameAnalysisResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_listsecrets.go b/resource-manager/containerapps/2024-03-01/containerapps/method_listsecrets.go new file mode 100644 index 00000000000..2981767594f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_listsecrets.go @@ -0,0 +1,55 @@ +package containerapps + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecretsCollection +} + +// ListSecrets ... +func (c ContainerAppsClient) ListSecrets(ctx context.Context, id ContainerAppId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecretsCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_start.go b/resource-manager/containerapps/2024-03-01/containerapps/method_start.go new file mode 100644 index 00000000000..5e3e3cd7b7e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_start.go @@ -0,0 +1,71 @@ +package containerapps + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ContainerApp +} + +// Start ... +func (c ContainerAppsClient) Start(ctx context.Context, id ContainerAppId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c ContainerAppsClient) StartThenPoll(ctx context.Context, id ContainerAppId) error { + result, err := c.Start(ctx, id) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_stop.go b/resource-manager/containerapps/2024-03-01/containerapps/method_stop.go new file mode 100644 index 00000000000..7b29fa28f8e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_stop.go @@ -0,0 +1,71 @@ +package containerapps + +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 StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ContainerApp +} + +// Stop ... +func (c ContainerAppsClient) Stop(ctx context.Context, id ContainerAppId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 +} + +// StopThenPoll performs Stop then polls until it's completed +func (c ContainerAppsClient) StopThenPoll(ctx context.Context, id ContainerAppId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/method_update.go b/resource-manager/containerapps/2024-03-01/containerapps/method_update.go new file mode 100644 index 00000000000..4b197837332 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/method_update.go @@ -0,0 +1,75 @@ +package containerapps + +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 *ContainerApp +} + +// Update ... +func (c ContainerAppsClient) Update(ctx context.Context, id ContainerAppId, input ContainerApp) (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 ContainerAppsClient) UpdateThenPoll(ctx context.Context, id ContainerAppId, input ContainerApp) 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/containerapps/2024-03-01/containerapps/model_basecontainer.go b/resource-manager/containerapps/2024-03-01/containerapps/model_basecontainer.go new file mode 100644 index 00000000000..3190b1630ca --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_basecontainer.go @@ -0,0 +1,14 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseContainer struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_configuration.go b/resource-manager/containerapps/2024-03-01/containerapps/model_configuration.go new file mode 100644 index 00000000000..199878bdae1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_configuration.go @@ -0,0 +1,14 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Configuration struct { + ActiveRevisionsMode *ActiveRevisionsMode `json:"activeRevisionsMode,omitempty"` + Dapr *Dapr `json:"dapr,omitempty"` + Ingress *Ingress `json:"ingress,omitempty"` + MaxInactiveRevisions *int64 `json:"maxInactiveRevisions,omitempty"` + Registries *[]RegistryCredentials `json:"registries,omitempty"` + Secrets *[]Secret `json:"secrets,omitempty"` + Service *Service `json:"service,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_container.go b/resource-manager/containerapps/2024-03-01/containerapps/model_container.go new file mode 100644 index 00000000000..eacb62148fd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_container.go @@ -0,0 +1,15 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Probes *[]ContainerAppProbe `json:"probes,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerapp.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerapp.go new file mode 100644 index 00000000000..0c382ed5867 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerapp.go @@ -0,0 +1,22 @@ +package containerapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerApp struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + ManagedBy *string `json:"managedBy,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContainerAppProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtoken.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtoken.go new file mode 100644 index 00000000000..89b63f9e369 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtoken.go @@ -0,0 +1,18 @@ +package containerapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppAuthToken struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ContainerAppAuthTokenProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtokenproperties.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtokenproperties.go new file mode 100644 index 00000000000..243fce5c07e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappauthtokenproperties.go @@ -0,0 +1,27 @@ +package containerapps + +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 ContainerAppAuthTokenProperties struct { + Expires *string `json:"expires,omitempty"` + Token *string `json:"token,omitempty"` +} + +func (o *ContainerAppAuthTokenProperties) GetExpiresAsTime() (*time.Time, error) { + if o.Expires == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expires, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerAppAuthTokenProperties) SetExpiresAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expires = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobe.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobe.go new file mode 100644 index 00000000000..a704b4ab897 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobe.go @@ -0,0 +1,16 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbe struct { + FailureThreshold *int64 `json:"failureThreshold,omitempty"` + HTTPGet *ContainerAppProbeHTTPGet `json:"httpGet,omitempty"` + InitialDelaySeconds *int64 `json:"initialDelaySeconds,omitempty"` + PeriodSeconds *int64 `json:"periodSeconds,omitempty"` + SuccessThreshold *int64 `json:"successThreshold,omitempty"` + TcpSocket *ContainerAppProbeTcpSocket `json:"tcpSocket,omitempty"` + TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpget.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpget.go new file mode 100644 index 00000000000..7f78b0e6271 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpget.go @@ -0,0 +1,12 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGet struct { + HTTPHeaders *[]ContainerAppProbeHTTPGetHTTPHeadersInlined `json:"httpHeaders,omitempty"` + Host *string `json:"host,omitempty"` + Path *string `json:"path,omitempty"` + Port int64 `json:"port"` + Scheme *Scheme `json:"scheme,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpgethttpheadersinlined.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpgethttpheadersinlined.go new file mode 100644 index 00000000000..d97ce91ffab --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobehttpgethttpheadersinlined.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGetHTTPHeadersInlined struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobetcpsocket.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobetcpsocket.go new file mode 100644 index 00000000000..94d442c5fdd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappprobetcpsocket.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeTcpSocket struct { + Host *string `json:"host,omitempty"` + Port int64 `json:"port"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappproperties.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappproperties.go new file mode 100644 index 00000000000..5dab8083bdc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappproperties.go @@ -0,0 +1,19 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProperties struct { + Configuration *Configuration `json:"configuration,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EventStreamEndpoint *string `json:"eventStreamEndpoint,omitempty"` + LatestReadyRevisionName *string `json:"latestReadyRevisionName,omitempty"` + LatestRevisionFqdn *string `json:"latestRevisionFqdn,omitempty"` + LatestRevisionName *string `json:"latestRevisionName,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + ProvisioningState *ContainerAppProvisioningState `json:"provisioningState,omitempty"` + Template *Template `json:"template,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerappsecret.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappsecret.go new file mode 100644 index 00000000000..5f93d41bec2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerappsecret.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppSecret struct { + Identity *string `json:"identity,omitempty"` + KeyVaultUrl *string `json:"keyVaultUrl,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_containerresources.go b/resource-manager/containerapps/2024-03-01/containerapps/model_containerresources.go new file mode 100644 index 00000000000..3d55e9ef422 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_containerresources.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + EphemeralStorage *string `json:"ephemeralStorage,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_corspolicy.go b/resource-manager/containerapps/2024-03-01/containerapps/model_corspolicy.go new file mode 100644 index 00000000000..414eae00470 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_corspolicy.go @@ -0,0 +1,13 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsPolicy struct { + AllowCredentials *bool `json:"allowCredentials,omitempty"` + AllowedHeaders *[]string `json:"allowedHeaders,omitempty"` + AllowedMethods *[]string `json:"allowedMethods,omitempty"` + AllowedOrigins []string `json:"allowedOrigins"` + ExposeHeaders *[]string `json:"exposeHeaders,omitempty"` + MaxAge *int64 `json:"maxAge,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_customdomain.go b/resource-manager/containerapps/2024-03-01/containerapps/model_customdomain.go new file mode 100644 index 00000000000..aeab69111fc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_customdomain.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomain struct { + BindingType *BindingType `json:"bindingType,omitempty"` + CertificateId *string `json:"certificateId,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresult.go b/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresult.go new file mode 100644 index 00000000000..e6108a84148 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresult.go @@ -0,0 +1,19 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResult struct { + ARecords *[]string `json:"aRecords,omitempty"` + AlternateCNameRecords *[]string `json:"alternateCNameRecords,omitempty"` + AlternateTxtRecords *[]string `json:"alternateTxtRecords,omitempty"` + CNameRecords *[]string `json:"cNameRecords,omitempty"` + ConflictWithEnvironmentCustomDomain *bool `json:"conflictWithEnvironmentCustomDomain,omitempty"` + ConflictingContainerAppResourceId *string `json:"conflictingContainerAppResourceId,omitempty"` + CustomDomainVerificationFailureInfo *CustomHostnameAnalysisResultCustomDomainVerificationFailureInfo `json:"customDomainVerificationFailureInfo,omitempty"` + CustomDomainVerificationTest *DnsVerificationTestResult `json:"customDomainVerificationTest,omitempty"` + HasConflictOnManagedEnvironment *bool `json:"hasConflictOnManagedEnvironment,omitempty"` + HostName *string `json:"hostName,omitempty"` + IsHostnameAlreadyVerified *bool `json:"isHostnameAlreadyVerified,omitempty"` + TxtRecords *[]string `json:"txtRecords,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfo.go b/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfo.go new file mode 100644 index 00000000000..490a78264ab --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfo.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResultCustomDomainVerificationFailureInfo struct { + Code *string `json:"code,omitempty"` + Details *[]CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsInlined `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go b/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go new file mode 100644 index 00000000000..1a9643ffafa --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_customhostnameanalysisresultcustomdomainverificationfailureinfodetailsinlined.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsInlined struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_customscalerule.go b/resource-manager/containerapps/2024-03-01/containerapps/model_customscalerule.go new file mode 100644 index 00000000000..6b51d48a3e2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_customscalerule.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_dapr.go b/resource-manager/containerapps/2024-03-01/containerapps/model_dapr.go new file mode 100644 index 00000000000..be3e090812b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_dapr.go @@ -0,0 +1,15 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dapr struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + AppProtocol *AppProtocol `json:"appProtocol,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *LogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadata.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadata.go new file mode 100644 index 00000000000..4f49cfc1268 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadata.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadata struct { + PropertyBag *[]DiagnosticDataProviderMetadataPropertyBagInlined `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadatapropertybaginlined.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadatapropertybaginlined.go new file mode 100644 index 00000000000..bb3c8371f29 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdataprovidermetadatapropertybaginlined.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadataPropertyBagInlined struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponsecolumn.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponsecolumn.go new file mode 100644 index 00000000000..f0da0d4af5a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponsecolumn.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponseobject.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponseobject.go new file mode 100644 index 00000000000..f5ab6cef03a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticdatatableresponseobject.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseObject struct { + Columns *[]DiagnosticDataTableResponseColumn `json:"columns,omitempty"` + Rows *[]interface{} `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticrendering.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticrendering.go new file mode 100644 index 00000000000..febf8f4bc44 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticrendering.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticRendering struct { + Description *string `json:"description,omitempty"` + IsVisible *bool `json:"isVisible,omitempty"` + Title *string `json:"title,omitempty"` + Type *int64 `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnostics.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnostics.go new file mode 100644 index 00000000000..332b9e6e8a7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnostics.go @@ -0,0 +1,16 @@ +package containerapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Diagnostics struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticsProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdataapiresponse.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdataapiresponse.go new file mode 100644 index 00000000000..8a4e162a0f1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdataapiresponse.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDataApiResponse struct { + RenderingProperties *DiagnosticRendering `json:"renderingProperties,omitempty"` + Table *DiagnosticDataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdefinition.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdefinition.go new file mode 100644 index 00000000000..01d57bd28c2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsdefinition.go @@ -0,0 +1,16 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDefinition struct { + AnalysisTypes *[]string `json:"analysisTypes,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]DiagnosticSupportTopic `json:"supportTopicList,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsproperties.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsproperties.go new file mode 100644 index 00000000000..5606b01916e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsproperties.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsProperties struct { + DataProviderMetadata *DiagnosticDataProviderMetadata `json:"dataProviderMetadata,omitempty"` + Dataset *[]DiagnosticsDataApiResponse `json:"dataset,omitempty"` + Metadata *DiagnosticsDefinition `json:"metadata,omitempty"` + Status *DiagnosticsStatus `json:"status,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsstatus.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsstatus.go new file mode 100644 index 00000000000..ff2dafc6e9e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsstatus.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsStatus struct { + Message *string `json:"message,omitempty"` + StatusId *int64 `json:"statusId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsupporttopic.go b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsupporttopic.go new file mode 100644 index 00000000000..36d9fb7fe24 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_diagnosticsupporttopic.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticSupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_environmentvar.go b/resource-manager/containerapps/2024-03-01/containerapps/model_environmentvar.go new file mode 100644 index 00000000000..e25ec6c8bc8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_environmentvar.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_extendedlocation.go b/resource-manager/containerapps/2024-03-01/containerapps/model_extendedlocation.go new file mode 100644 index 00000000000..20073b0ba29 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_extendedlocation.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_httpscalerule.go b/resource-manager/containerapps/2024-03-01/containerapps/model_httpscalerule.go new file mode 100644 index 00000000000..429b7ee2303 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_httpscalerule.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_ingress.go b/resource-manager/containerapps/2024-03-01/containerapps/model_ingress.go new file mode 100644 index 00000000000..8b20fd57cf7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_ingress.go @@ -0,0 +1,20 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ingress struct { + AdditionalPortMappings *[]IngressPortMapping `json:"additionalPortMappings,omitempty"` + AllowInsecure *bool `json:"allowInsecure,omitempty"` + ClientCertificateMode *IngressClientCertificateMode `json:"clientCertificateMode,omitempty"` + CorsPolicy *CorsPolicy `json:"corsPolicy,omitempty"` + CustomDomains *[]CustomDomain `json:"customDomains,omitempty"` + ExposedPort *int64 `json:"exposedPort,omitempty"` + External *bool `json:"external,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestrictionRule `json:"ipSecurityRestrictions,omitempty"` + StickySessions *IngressStickySessions `json:"stickySessions,omitempty"` + TargetPort *int64 `json:"targetPort,omitempty"` + Traffic *[]TrafficWeight `json:"traffic,omitempty"` + Transport *IngressTransportMethod `json:"transport,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_ingressportmapping.go b/resource-manager/containerapps/2024-03-01/containerapps/model_ingressportmapping.go new file mode 100644 index 00000000000..f7f84d45faa --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_ingressportmapping.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IngressPortMapping struct { + ExposedPort *int64 `json:"exposedPort,omitempty"` + External bool `json:"external"` + TargetPort int64 `json:"targetPort"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_ingressstickysessions.go b/resource-manager/containerapps/2024-03-01/containerapps/model_ingressstickysessions.go new file mode 100644 index 00000000000..48b18e0ee17 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_ingressstickysessions.go @@ -0,0 +1,8 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IngressStickySessions struct { + Affinity *Affinity `json:"affinity,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_ipsecurityrestrictionrule.go b/resource-manager/containerapps/2024-03-01/containerapps/model_ipsecurityrestrictionrule.go new file mode 100644 index 00000000000..959c43b6cbb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_ipsecurityrestrictionrule.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestrictionRule struct { + Action Action `json:"action"` + Description *string `json:"description,omitempty"` + IPAddressRange string `json:"ipAddressRange"` + Name string `json:"name"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_queuescalerule.go b/resource-manager/containerapps/2024-03-01/containerapps/model_queuescalerule.go new file mode 100644 index 00000000000..b8cbc96d3a0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_queuescalerule.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + QueueLength *int64 `json:"queueLength,omitempty"` + QueueName *string `json:"queueName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_registrycredentials.go b/resource-manager/containerapps/2024-03-01/containerapps/model_registrycredentials.go new file mode 100644 index 00000000000..bab9a7f8a4c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_registrycredentials.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCredentials struct { + Identity *string `json:"identity,omitempty"` + PasswordSecretRef *string `json:"passwordSecretRef,omitempty"` + Server *string `json:"server,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_revision.go b/resource-manager/containerapps/2024-03-01/containerapps/model_revision.go new file mode 100644 index 00000000000..02d41684620 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_revision.go @@ -0,0 +1,16 @@ +package containerapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Revision struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RevisionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_revisionproperties.go b/resource-manager/containerapps/2024-03-01/containerapps/model_revisionproperties.go new file mode 100644 index 00000000000..2fc409ae580 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_revisionproperties.go @@ -0,0 +1,48 @@ +package containerapps + +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 RevisionProperties struct { + Active *bool `json:"active,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + HealthState *RevisionHealthState `json:"healthState,omitempty"` + LastActiveTime *string `json:"lastActiveTime,omitempty"` + ProvisioningError *string `json:"provisioningError,omitempty"` + ProvisioningState *RevisionProvisioningState `json:"provisioningState,omitempty"` + Replicas *int64 `json:"replicas,omitempty"` + RunningState *RevisionRunningState `json:"runningState,omitempty"` + Template *Template `json:"template,omitempty"` + TrafficWeight *int64 `json:"trafficWeight,omitempty"` +} + +func (o *RevisionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *RevisionProperties) GetLastActiveTimeAsTime() (*time.Time, error) { + if o.LastActiveTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastActiveTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetLastActiveTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastActiveTime = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_scale.go b/resource-manager/containerapps/2024-03-01/containerapps/model_scale.go new file mode 100644 index 00000000000..a8f54d89b3f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_scale.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Scale struct { + MaxReplicas *int64 `json:"maxReplicas,omitempty"` + MinReplicas *int64 `json:"minReplicas,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_scalerule.go b/resource-manager/containerapps/2024-03-01/containerapps/model_scalerule.go new file mode 100644 index 00000000000..93c358a6fa7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_scalerule.go @@ -0,0 +1,12 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRule struct { + AzureQueue *QueueScaleRule `json:"azureQueue,omitempty"` + Custom *CustomScaleRule `json:"custom,omitempty"` + HTTP *HTTPScaleRule `json:"http,omitempty"` + Name *string `json:"name,omitempty"` + Tcp *TcpScaleRule `json:"tcp,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_scaleruleauth.go b/resource-manager/containerapps/2024-03-01/containerapps/model_scaleruleauth.go new file mode 100644 index 00000000000..46e5a92ad03 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_secret.go b/resource-manager/containerapps/2024-03-01/containerapps/model_secret.go new file mode 100644 index 00000000000..a1fbe4ec8f6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_secret.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Secret struct { + Identity *string `json:"identity,omitempty"` + KeyVaultUrl *string `json:"keyVaultUrl,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_secretscollection.go b/resource-manager/containerapps/2024-03-01/containerapps/model_secretscollection.go new file mode 100644 index 00000000000..5244f0aabe7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_secretscollection.go @@ -0,0 +1,8 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretsCollection struct { + Value []ContainerAppSecret `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_secretvolumeitem.go b/resource-manager/containerapps/2024-03-01/containerapps/model_secretvolumeitem.go new file mode 100644 index 00000000000..09096efbdd0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_secretvolumeitem.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretVolumeItem struct { + Path *string `json:"path,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_service.go b/resource-manager/containerapps/2024-03-01/containerapps/model_service.go new file mode 100644 index 00000000000..f66b3642bfc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_service.go @@ -0,0 +1,8 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Service struct { + Type string `json:"type"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_servicebind.go b/resource-manager/containerapps/2024-03-01/containerapps/model_servicebind.go new file mode 100644 index 00000000000..29229a27ece --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_servicebind.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceBind struct { + Name *string `json:"name,omitempty"` + ServiceId *string `json:"serviceId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_tcpscalerule.go b/resource-manager/containerapps/2024-03-01/containerapps/model_tcpscalerule.go new file mode 100644 index 00000000000..4a970c61e67 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_tcpscalerule.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TcpScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_template.go b/resource-manager/containerapps/2024-03-01/containerapps/model_template.go new file mode 100644 index 00000000000..03f13f07980 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_template.go @@ -0,0 +1,14 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Template struct { + Containers *[]Container `json:"containers,omitempty"` + InitContainers *[]BaseContainer `json:"initContainers,omitempty"` + RevisionSuffix *string `json:"revisionSuffix,omitempty"` + Scale *Scale `json:"scale,omitempty"` + ServiceBinds *[]ServiceBind `json:"serviceBinds,omitempty"` + TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + Volumes *[]Volume `json:"volumes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_trafficweight.go b/resource-manager/containerapps/2024-03-01/containerapps/model_trafficweight.go new file mode 100644 index 00000000000..63d06f5fdcb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_trafficweight.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficWeight struct { + Label *string `json:"label,omitempty"` + LatestRevision *bool `json:"latestRevision,omitempty"` + RevisionName *string `json:"revisionName,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_volume.go b/resource-manager/containerapps/2024-03-01/containerapps/model_volume.go new file mode 100644 index 00000000000..422cdf3ec3d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_volume.go @@ -0,0 +1,12 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Volume struct { + MountOptions *string `json:"mountOptions,omitempty"` + Name *string `json:"name,omitempty"` + Secrets *[]SecretVolumeItem `json:"secrets,omitempty"` + StorageName *string `json:"storageName,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/model_volumemount.go b/resource-manager/containerapps/2024-03-01/containerapps/model_volumemount.go new file mode 100644 index 00000000000..c59e9fc682d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/model_volumemount.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeMount struct { + MountPath *string `json:"mountPath,omitempty"` + SubPath *string `json:"subPath,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerapps/predicates.go b/resource-manager/containerapps/2024-03-01/containerapps/predicates.go new file mode 100644 index 00000000000..2f9822c394b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/predicates.go @@ -0,0 +1,83 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppOperationPredicate struct { + Id *string + Location *string + ManagedBy *string + Name *string + Type *string +} + +func (p ContainerAppOperationPredicate) Matches(input ContainerApp) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.ManagedBy != nil && (input.ManagedBy == nil || *p.ManagedBy != *input.ManagedBy) { + 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 +} + +type DiagnosticsOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DiagnosticsOperationPredicate) Matches(input Diagnostics) 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 +} + +type RevisionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RevisionOperationPredicate) Matches(input Revision) 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/containerapps/2024-03-01/containerapps/version.go b/resource-manager/containerapps/2024-03-01/containerapps/version.go new file mode 100644 index 00000000000..72768e64a8b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerapps/version.go @@ -0,0 +1,12 @@ +package containerapps + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/containerapps/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/README.md b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/README.md new file mode 100644 index 00000000000..5d1a23c1f86 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappsauthconfigs` Documentation + +The `containerappsauthconfigs` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/containerappsauthconfigs" +``` + + +### Client Initialization + +```go +client := containerappsauthconfigs.NewContainerAppsAuthConfigsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsAuthConfigsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := containerappsauthconfigs.NewAuthConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "authConfigValue") + +payload := containerappsauthconfigs.AuthConfig{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsAuthConfigsClient.Delete` + +```go +ctx := context.TODO() +id := containerappsauthconfigs.NewAuthConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "authConfigValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsAuthConfigsClient.Get` + +```go +ctx := context.TODO() +id := containerappsauthconfigs.NewAuthConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "authConfigValue") + +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: `ContainerAppsAuthConfigsClient.ListByContainerApp` + +```go +ctx := context.TODO() +id := containerappsauthconfigs.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.ListByContainerApp(ctx, id)` can be used to do batched pagination +items, err := client.ListByContainerAppComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/client.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/client.go similarity index 57% rename from resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/client.go rename to resource-manager/containerapps/2024-03-01/containerappsauthconfigs/client.go index 71df8e072df..f57bc2d149f 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/client.go +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/client.go @@ -1,4 +1,4 @@ -package eventhubsclustersupgrade +package containerappsauthconfigs import ( "fmt" @@ -10,17 +10,17 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type EventHubsClustersUpgradeClient struct { +type ContainerAppsAuthConfigsClient struct { Client *resourcemanager.Client } -func NewEventHubsClustersUpgradeClientWithBaseURI(sdkApi sdkEnv.Api) (*EventHubsClustersUpgradeClient, error) { - client, err := resourcemanager.NewResourceManagerClient(sdkApi, "eventhubsclustersupgrade", defaultApiVersion) +func NewContainerAppsAuthConfigsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsAuthConfigsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerappsauthconfigs", defaultApiVersion) if err != nil { - return nil, fmt.Errorf("instantiating EventHubsClustersUpgradeClient: %+v", err) + return nil, fmt.Errorf("instantiating ContainerAppsAuthConfigsClient: %+v", err) } - return &EventHubsClustersUpgradeClient{ + return &ContainerAppsAuthConfigsClient{ Client: client, }, nil } diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/constants.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/constants.go new file mode 100644 index 00000000000..ba7b5c1fe46 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/constants.go @@ -0,0 +1,180 @@ +package containerappsauthconfigs + +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 ClientCredentialMethod string + +const ( + ClientCredentialMethodClientSecretPost ClientCredentialMethod = "ClientSecretPost" +) + +func PossibleValuesForClientCredentialMethod() []string { + return []string{ + string(ClientCredentialMethodClientSecretPost), + } +} + +func (s *ClientCredentialMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCredentialMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCredentialMethod(input string) (*ClientCredentialMethod, error) { + vals := map[string]ClientCredentialMethod{ + "clientsecretpost": ClientCredentialMethodClientSecretPost, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCredentialMethod(input) + return &out, nil +} + +type CookieExpirationConvention string + +const ( + CookieExpirationConventionFixedTime CookieExpirationConvention = "FixedTime" + CookieExpirationConventionIdentityProviderDerived CookieExpirationConvention = "IdentityProviderDerived" +) + +func PossibleValuesForCookieExpirationConvention() []string { + return []string{ + string(CookieExpirationConventionFixedTime), + string(CookieExpirationConventionIdentityProviderDerived), + } +} + +func (s *CookieExpirationConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCookieExpirationConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCookieExpirationConvention(input string) (*CookieExpirationConvention, error) { + vals := map[string]CookieExpirationConvention{ + "fixedtime": CookieExpirationConventionFixedTime, + "identityproviderderived": CookieExpirationConventionIdentityProviderDerived, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CookieExpirationConvention(input) + return &out, nil +} + +type ForwardProxyConvention string + +const ( + ForwardProxyConventionCustom ForwardProxyConvention = "Custom" + ForwardProxyConventionNoProxy ForwardProxyConvention = "NoProxy" + ForwardProxyConventionStandard ForwardProxyConvention = "Standard" +) + +func PossibleValuesForForwardProxyConvention() []string { + return []string{ + string(ForwardProxyConventionCustom), + string(ForwardProxyConventionNoProxy), + string(ForwardProxyConventionStandard), + } +} + +func (s *ForwardProxyConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardProxyConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForwardProxyConvention(input string) (*ForwardProxyConvention, error) { + vals := map[string]ForwardProxyConvention{ + "custom": ForwardProxyConventionCustom, + "noproxy": ForwardProxyConventionNoProxy, + "standard": ForwardProxyConventionStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForwardProxyConvention(input) + return &out, nil +} + +type UnauthenticatedClientActionV2 string + +const ( + UnauthenticatedClientActionV2AllowAnonymous UnauthenticatedClientActionV2 = "AllowAnonymous" + UnauthenticatedClientActionV2RedirectToLoginPage UnauthenticatedClientActionV2 = "RedirectToLoginPage" + UnauthenticatedClientActionV2ReturnFourZeroOne UnauthenticatedClientActionV2 = "Return401" + UnauthenticatedClientActionV2ReturnFourZeroThree UnauthenticatedClientActionV2 = "Return403" +) + +func PossibleValuesForUnauthenticatedClientActionV2() []string { + return []string{ + string(UnauthenticatedClientActionV2AllowAnonymous), + string(UnauthenticatedClientActionV2RedirectToLoginPage), + string(UnauthenticatedClientActionV2ReturnFourZeroOne), + string(UnauthenticatedClientActionV2ReturnFourZeroThree), + } +} + +func (s *UnauthenticatedClientActionV2) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientActionV2(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnauthenticatedClientActionV2(input string) (*UnauthenticatedClientActionV2, error) { + vals := map[string]UnauthenticatedClientActionV2{ + "allowanonymous": UnauthenticatedClientActionV2AllowAnonymous, + "redirecttologinpage": UnauthenticatedClientActionV2RedirectToLoginPage, + "return401": UnauthenticatedClientActionV2ReturnFourZeroOne, + "return403": UnauthenticatedClientActionV2ReturnFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnauthenticatedClientActionV2(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig.go new file mode 100644 index 00000000000..419a1f003e8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig.go @@ -0,0 +1,139 @@ +package containerappsauthconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AuthConfigId{}) +} + +var _ resourceids.ResourceId = &AuthConfigId{} + +// AuthConfigId is a struct representing the Resource ID for a Auth Config +type AuthConfigId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + AuthConfigName string +} + +// NewAuthConfigID returns a new AuthConfigId struct +func NewAuthConfigID(subscriptionId string, resourceGroupName string, containerAppName string, authConfigName string) AuthConfigId { + return AuthConfigId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + AuthConfigName: authConfigName, + } +} + +// ParseAuthConfigID parses 'input' into a AuthConfigId +func ParseAuthConfigID(input string) (*AuthConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthConfigId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthConfigId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthConfigIDInsensitively parses 'input' case-insensitively into a AuthConfigId +// note: this method should only be used for API response data and not user input +func ParseAuthConfigIDInsensitively(input string) (*AuthConfigId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthConfigId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthConfigId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthConfigId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.AuthConfigName, ok = input.Parsed["authConfigName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authConfigName", input) + } + + return nil +} + +// ValidateAuthConfigID checks that 'input' can be parsed as a Auth Config ID +func ValidateAuthConfigID(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 := ParseAuthConfigID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Auth Config ID +func (id AuthConfigId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/authConfigs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.AuthConfigName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Auth Config ID +func (id AuthConfigId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticAuthConfigs", "authConfigs", "authConfigs"), + resourceids.UserSpecifiedSegment("authConfigName", "authConfigValue"), + } +} + +// String returns a human-readable description of this Auth Config ID +func (id AuthConfigId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Auth Config Name: %q", id.AuthConfigName), + } + return fmt.Sprintf("Auth Config (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig_test.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig_test.go new file mode 100644 index 00000000000..8980ef93a59 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_authconfig_test.go @@ -0,0 +1,327 @@ +package containerappsauthconfigs + +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 = &AuthConfigId{} + +func TestNewAuthConfigID(t *testing.T) { + id := NewAuthConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "authConfigValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.AuthConfigName != "authConfigValue" { + t.Fatalf("Expected %q but got %q for Segment 'AuthConfigName'", id.AuthConfigName, "authConfigValue") + } +} + +func TestFormatAuthConfigID(t *testing.T) { + actual := NewAuthConfigID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "authConfigValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/authConfigs/authConfigValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthConfigID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthConfigId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/authConfigs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/authConfigs/authConfigValue", + Expected: &AuthConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + AuthConfigName: "authConfigValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/authConfigs/authConfigValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthConfigID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.AuthConfigName != v.Expected.AuthConfigName { + t.Fatalf("Expected %q but got %q for AuthConfigName", v.Expected.AuthConfigName, actual.AuthConfigName) + } + + } +} + +func TestParseAuthConfigIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthConfigId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/authConfigs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/aUtHcOnFiGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/authConfigs/authConfigValue", + Expected: &AuthConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + AuthConfigName: "authConfigValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/authConfigs/authConfigValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/aUtHcOnFiGs/aUtHcOnFiGvAlUe", + Expected: &AuthConfigId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + AuthConfigName: "aUtHcOnFiGvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/aUtHcOnFiGs/aUtHcOnFiGvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthConfigIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.AuthConfigName != v.Expected.AuthConfigName { + t.Fatalf("Expected %q but got %q for AuthConfigName", v.Expected.AuthConfigName, actual.AuthConfigName) + } + + } +} + +func TestSegmentsForAuthConfigId(t *testing.T) { + segments := AuthConfigId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthConfigId 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/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp.go new file mode 100644 index 00000000000..82389da4f1b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp.go @@ -0,0 +1,130 @@ +package containerappsauthconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppId{}) +} + +var _ resourceids.ResourceId = &ContainerAppId{} + +// ContainerAppId is a struct representing the Resource ID for a Container App +type ContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewContainerAppID returns a new ContainerAppId struct +func NewContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ContainerAppId { + return ContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseContainerAppID parses 'input' into a ContainerAppId +func ParseContainerAppID(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppIDInsensitively parses 'input' case-insensitively into a ContainerAppId +// note: this method should only be used for API response data and not user input +func ParseContainerAppIDInsensitively(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateContainerAppID checks that 'input' can be parsed as a Container App ID +func ValidateContainerAppID(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 := ParseContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App ID +func (id ContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App ID +func (id ContainerAppId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Container App ID +func (id ContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp_test.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp_test.go new file mode 100644 index 00000000000..4bcf498e725 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/id_containerapp_test.go @@ -0,0 +1,282 @@ +package containerappsauthconfigs + +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 = &ContainerAppId{} + +func TestNewContainerAppID(t *testing.T) { + id := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatContainerAppID(t *testing.T) { + actual := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForContainerAppId(t *testing.T) { + segments := ContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppId 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/containerapps/2024-03-01/containerappsauthconfigs/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_createorupdate.go new file mode 100644 index 00000000000..28f50cb36f8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_createorupdate.go @@ -0,0 +1,58 @@ +package containerappsauthconfigs + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AuthConfig +} + +// CreateOrUpdate ... +func (c ContainerAppsAuthConfigsClient) CreateOrUpdate(ctx context.Context, id AuthConfigId, input AuthConfig) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AuthConfig + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_delete.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_delete.go new file mode 100644 index 00000000000..de31f707aba --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_delete.go @@ -0,0 +1,47 @@ +package containerappsauthconfigs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ContainerAppsAuthConfigsClient) Delete(ctx context.Context, id AuthConfigId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_get.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_get.go new file mode 100644 index 00000000000..96870ebd993 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_get.go @@ -0,0 +1,54 @@ +package containerappsauthconfigs + +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 *AuthConfig +} + +// Get ... +func (c ContainerAppsAuthConfigsClient) Get(ctx context.Context, id AuthConfigId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AuthConfig + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_listbycontainerapp.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_listbycontainerapp.go new file mode 100644 index 00000000000..d26dd5b2449 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/method_listbycontainerapp.go @@ -0,0 +1,91 @@ +package containerappsauthconfigs + +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 ListByContainerAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AuthConfig +} + +type ListByContainerAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []AuthConfig +} + +// ListByContainerApp ... +func (c ContainerAppsAuthConfigsClient) ListByContainerApp(ctx context.Context, id ContainerAppId) (result ListByContainerAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/authConfigs", 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 *[]AuthConfig `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByContainerAppComplete retrieves all the results into a single object +func (c ContainerAppsAuthConfigsClient) ListByContainerAppComplete(ctx context.Context, id ContainerAppId) (ListByContainerAppCompleteResult, error) { + return c.ListByContainerAppCompleteMatchingPredicate(ctx, id, AuthConfigOperationPredicate{}) +} + +// ListByContainerAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsAuthConfigsClient) ListByContainerAppCompleteMatchingPredicate(ctx context.Context, id ContainerAppId, predicate AuthConfigOperationPredicate) (result ListByContainerAppCompleteResult, err error) { + items := make([]AuthConfig, 0) + + resp, err := c.ListByContainerApp(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 = ListByContainerAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedaudiencesvalidation.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedaudiencesvalidation.go new file mode 100644 index 00000000000..594711ca638 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedaudiencesvalidation.go @@ -0,0 +1,8 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedAudiencesValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedprincipals.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedprincipals.go new file mode 100644 index 00000000000..f688f3136ef --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_allowedprincipals.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedPrincipals struct { + Groups *[]string `json:"groups,omitempty"` + Identities *[]string `json:"identities,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_apple.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_apple.go new file mode 100644 index 00000000000..342215d6cc3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_apple.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Apple struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppleRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appleregistration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appleregistration.go new file mode 100644 index 00000000000..f4313788047 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appleregistration.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppleRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appregistration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appregistration.go new file mode 100644 index 00000000000..6709a45a29c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_appregistration.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppRegistration struct { + AppId *string `json:"appId,omitempty"` + AppSecretSettingName *string `json:"appSecretSettingName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfig.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfig.go new file mode 100644 index 00000000000..de04bb26a5a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfig.go @@ -0,0 +1,16 @@ +package containerappsauthconfigs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthConfig struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AuthConfigProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfigproperties.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfigproperties.go new file mode 100644 index 00000000000..bf35c45b412 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authconfigproperties.go @@ -0,0 +1,13 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthConfigProperties struct { + EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"` + GlobalValidation *GlobalValidation `json:"globalValidation,omitempty"` + HTTPSettings *HTTPSettings `json:"httpSettings,omitempty"` + IdentityProviders *IdentityProviders `json:"identityProviders,omitempty"` + Login *Login `json:"login,omitempty"` + Platform *AuthPlatform `json:"platform,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authplatform.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authplatform.go new file mode 100644 index 00000000000..78d033cd9f3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_authplatform.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthPlatform struct { + Enabled *bool `json:"enabled,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectory.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectory.go new file mode 100644 index 00000000000..8a14182dc4a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectory.go @@ -0,0 +1,12 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectory struct { + Enabled *bool `json:"enabled,omitempty"` + IsAutoProvisioned *bool `json:"isAutoProvisioned,omitempty"` + Login *AzureActiveDirectoryLogin `json:"login,omitempty"` + Registration *AzureActiveDirectoryRegistration `json:"registration,omitempty"` + Validation *AzureActiveDirectoryValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectorylogin.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectorylogin.go new file mode 100644 index 00000000000..569680f2c2b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectorylogin.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryLogin struct { + DisableWWWAuthenticate *bool `json:"disableWWWAuthenticate,omitempty"` + LoginParameters *[]string `json:"loginParameters,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryregistration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryregistration.go new file mode 100644 index 00000000000..8e7c8c65bad --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryregistration.go @@ -0,0 +1,13 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretCertificateIssuer *string `json:"clientSecretCertificateIssuer,omitempty"` + ClientSecretCertificateSubjectAlternativeName *string `json:"clientSecretCertificateSubjectAlternativeName,omitempty"` + ClientSecretCertificateThumbprint *string `json:"clientSecretCertificateThumbprint,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + OpenIdIssuer *string `json:"openIdIssuer,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryvalidation.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryvalidation.go new file mode 100644 index 00000000000..432f84b385a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azureactivedirectoryvalidation.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` + DefaultAuthorizationPolicy *DefaultAuthorizationPolicy `json:"defaultAuthorizationPolicy,omitempty"` + JwtClaimChecks *JwtClaimChecks `json:"jwtClaimChecks,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebapps.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebapps.go new file mode 100644 index 00000000000..c59e25c28b7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebapps.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebApps struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *AzureStaticWebAppsRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebappsregistration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebappsregistration.go new file mode 100644 index 00000000000..a0b15a30098 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_azurestaticwebappsregistration.go @@ -0,0 +1,8 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebAppsRegistration struct { + ClientId *string `json:"clientId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_blobstoragetokenstore.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_blobstoragetokenstore.go new file mode 100644 index 00000000000..93510fd0017 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_blobstoragetokenstore.go @@ -0,0 +1,8 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BlobStorageTokenStore struct { + SasUrlSettingName string `json:"sasUrlSettingName"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_clientregistration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_clientregistration.go new file mode 100644 index 00000000000..cf09dea7cde --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_clientregistration.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_cookieexpiration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_cookieexpiration.go new file mode 100644 index 00000000000..7121c522a07 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_cookieexpiration.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CookieExpiration struct { + Convention *CookieExpirationConvention `json:"convention,omitempty"` + TimeToExpiration *string `json:"timeToExpiration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_customopenidconnectprovider.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_customopenidconnectprovider.go new file mode 100644 index 00000000000..f8afc83eba5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_customopenidconnectprovider.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomOpenIdConnectProvider struct { + Enabled *bool `json:"enabled,omitempty"` + Login *OpenIdConnectLogin `json:"login,omitempty"` + Registration *OpenIdConnectRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_defaultauthorizationpolicy.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_defaultauthorizationpolicy.go new file mode 100644 index 00000000000..0364e6bba4d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_defaultauthorizationpolicy.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAuthorizationPolicy struct { + AllowedApplications *[]string `json:"allowedApplications,omitempty"` + AllowedPrincipals *AllowedPrincipals `json:"allowedPrincipals,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_encryptionsettings.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_encryptionsettings.go new file mode 100644 index 00000000000..775aa1b9fca --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_encryptionsettings.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionSettings struct { + ContainerAppAuthEncryptionSecretName *string `json:"containerAppAuthEncryptionSecretName,omitempty"` + ContainerAppAuthSigningSecretName *string `json:"containerAppAuthSigningSecretName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_facebook.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_facebook.go new file mode 100644 index 00000000000..d354c73120e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_facebook.go @@ -0,0 +1,11 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Facebook struct { + Enabled *bool `json:"enabled,omitempty"` + GraphApiVersion *string `json:"graphApiVersion,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_forwardproxy.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_forwardproxy.go new file mode 100644 index 00000000000..15f8944d7d0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_forwardproxy.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ForwardProxy struct { + Convention *ForwardProxyConvention `json:"convention,omitempty"` + CustomHostHeaderName *string `json:"customHostHeaderName,omitempty"` + CustomProtoHeaderName *string `json:"customProtoHeaderName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_github.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_github.go new file mode 100644 index 00000000000..d63088b7c68 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_github.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHub struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_globalvalidation.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_globalvalidation.go new file mode 100644 index 00000000000..f2b4e6a7bbf --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_globalvalidation.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalValidation struct { + ExcludedPaths *[]string `json:"excludedPaths,omitempty"` + RedirectToProvider *string `json:"redirectToProvider,omitempty"` + UnauthenticatedClientAction *UnauthenticatedClientActionV2 `json:"unauthenticatedClientAction,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_google.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_google.go new file mode 100644 index 00000000000..6df90407ba4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_google.go @@ -0,0 +1,11 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Google struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` + Validation *AllowedAudiencesValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettings.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettings.go new file mode 100644 index 00000000000..b12578d6a4f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettings.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettings struct { + ForwardProxy *ForwardProxy `json:"forwardProxy,omitempty"` + RequireHTTPS *bool `json:"requireHttps,omitempty"` + Routes *HTTPSettingsRoutes `json:"routes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettingsroutes.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettingsroutes.go new file mode 100644 index 00000000000..77768a0aaa3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_httpsettingsroutes.go @@ -0,0 +1,8 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettingsRoutes struct { + ApiPrefix *string `json:"apiPrefix,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_identityproviders.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_identityproviders.go new file mode 100644 index 00000000000..3ea9ba760f8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_identityproviders.go @@ -0,0 +1,15 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviders struct { + Apple *Apple `json:"apple,omitempty"` + AzureActiveDirectory *AzureActiveDirectory `json:"azureActiveDirectory,omitempty"` + AzureStaticWebApps *AzureStaticWebApps `json:"azureStaticWebApps,omitempty"` + CustomOpenIdConnectProviders *map[string]CustomOpenIdConnectProvider `json:"customOpenIdConnectProviders,omitempty"` + Facebook *Facebook `json:"facebook,omitempty"` + GitHub *GitHub `json:"gitHub,omitempty"` + Google *Google `json:"google,omitempty"` + Twitter *Twitter `json:"twitter,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_jwtclaimchecks.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_jwtclaimchecks.go new file mode 100644 index 00000000000..dc79e4613dd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_jwtclaimchecks.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JwtClaimChecks struct { + AllowedClientApplications *[]string `json:"allowedClientApplications,omitempty"` + AllowedGroups *[]string `json:"allowedGroups,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_login.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_login.go new file mode 100644 index 00000000000..98ea1447795 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_login.go @@ -0,0 +1,13 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Login struct { + AllowedExternalRedirectUrls *[]string `json:"allowedExternalRedirectUrls,omitempty"` + CookieExpiration *CookieExpiration `json:"cookieExpiration,omitempty"` + Nonce *Nonce `json:"nonce,omitempty"` + PreserveUrlFragmentsForLogins *bool `json:"preserveUrlFragmentsForLogins,omitempty"` + Routes *LoginRoutes `json:"routes,omitempty"` + TokenStore *TokenStore `json:"tokenStore,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginroutes.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginroutes.go new file mode 100644 index 00000000000..3bc35729049 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginroutes.go @@ -0,0 +1,8 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginRoutes struct { + LogoutEndpoint *string `json:"logoutEndpoint,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginscopes.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginscopes.go new file mode 100644 index 00000000000..12f3aa5d541 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_loginscopes.go @@ -0,0 +1,8 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginScopes struct { + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_nonce.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_nonce.go new file mode 100644 index 00000000000..ea13ee897e5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_nonce.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Nonce struct { + NonceExpirationInterval *string `json:"nonceExpirationInterval,omitempty"` + ValidateNonce *bool `json:"validateNonce,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectclientcredential.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectclientcredential.go new file mode 100644 index 00000000000..07860f39082 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectclientcredential.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectClientCredential struct { + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + Method *ClientCredentialMethod `json:"method,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectconfig.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectconfig.go new file mode 100644 index 00000000000..d99c17ee8cf --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectconfig.go @@ -0,0 +1,12 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectConfig struct { + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + CertificationUri *string `json:"certificationUri,omitempty"` + Issuer *string `json:"issuer,omitempty"` + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` + WellKnownOpenIdConfiguration *string `json:"wellKnownOpenIdConfiguration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectlogin.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectlogin.go new file mode 100644 index 00000000000..d5a6d880ae4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectlogin.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectLogin struct { + NameClaimType *string `json:"nameClaimType,omitempty"` + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectregistration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectregistration.go new file mode 100644 index 00000000000..178e8a393bc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_openidconnectregistration.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectRegistration struct { + ClientCredential *OpenIdConnectClientCredential `json:"clientCredential,omitempty"` + ClientId *string `json:"clientId,omitempty"` + OpenIdConnectConfiguration *OpenIdConnectConfig `json:"openIdConnectConfiguration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_tokenstore.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_tokenstore.go new file mode 100644 index 00000000000..61bb96269fe --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_tokenstore.go @@ -0,0 +1,10 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TokenStore struct { + AzureBlobStorage *BlobStorageTokenStore `json:"azureBlobStorage,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + TokenRefreshExtensionHours *float64 `json:"tokenRefreshExtensionHours,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitter.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitter.go new file mode 100644 index 00000000000..86411693f47 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitter.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Twitter struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *TwitterRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitterregistration.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitterregistration.go new file mode 100644 index 00000000000..9363c659750 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/model_twitterregistration.go @@ -0,0 +1,9 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TwitterRegistration struct { + ConsumerKey *string `json:"consumerKey,omitempty"` + ConsumerSecretSettingName *string `json:"consumerSecretSettingName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/predicates.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/predicates.go new file mode 100644 index 00000000000..588139a3fbb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/predicates.go @@ -0,0 +1,27 @@ +package containerappsauthconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthConfigOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AuthConfigOperationPredicate) Matches(input AuthConfig) 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/containerapps/2024-03-01/containerappsauthconfigs/version.go b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/version.go new file mode 100644 index 00000000000..3a5123f6a6d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsauthconfigs/version.go @@ -0,0 +1,12 @@ +package containerappsauthconfigs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/containerappsauthconfigs/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/README.md b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/README.md new file mode 100644 index 00000000000..24bc4af8792 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas` Documentation + +The `containerappsrevisionreplicas` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/containerappsrevisionreplicas" +``` + + +### Client Initialization + +```go +client := containerappsrevisionreplicas.NewContainerAppsRevisionReplicasClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsRevisionReplicasClient.GetReplica` + +```go +ctx := context.TODO() +id := containerappsrevisionreplicas.NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue", "replicaValue") + +read, err := client.GetReplica(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionReplicasClient.ListReplicas` + +```go +ctx := context.TODO() +id := containerappsrevisionreplicas.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.ListReplicas(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/containerapps/2024-03-01/containerappsrevisionreplicas/client.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/client.go new file mode 100644 index 00000000000..5945a5c4038 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/client.go @@ -0,0 +1,26 @@ +package containerappsrevisionreplicas + +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 ContainerAppsRevisionReplicasClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsRevisionReplicasClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsRevisionReplicasClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerappsrevisionreplicas", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsRevisionReplicasClient: %+v", err) + } + + return &ContainerAppsRevisionReplicasClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/constants.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/constants.go new file mode 100644 index 00000000000..8c0c5556098 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/constants.go @@ -0,0 +1,98 @@ +package containerappsrevisionreplicas + +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 ContainerAppContainerRunningState string + +const ( + ContainerAppContainerRunningStateRunning ContainerAppContainerRunningState = "Running" + ContainerAppContainerRunningStateTerminated ContainerAppContainerRunningState = "Terminated" + ContainerAppContainerRunningStateWaiting ContainerAppContainerRunningState = "Waiting" +) + +func PossibleValuesForContainerAppContainerRunningState() []string { + return []string{ + string(ContainerAppContainerRunningStateRunning), + string(ContainerAppContainerRunningStateTerminated), + string(ContainerAppContainerRunningStateWaiting), + } +} + +func (s *ContainerAppContainerRunningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerAppContainerRunningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerAppContainerRunningState(input string) (*ContainerAppContainerRunningState, error) { + vals := map[string]ContainerAppContainerRunningState{ + "running": ContainerAppContainerRunningStateRunning, + "terminated": ContainerAppContainerRunningStateTerminated, + "waiting": ContainerAppContainerRunningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerAppContainerRunningState(input) + return &out, nil +} + +type ContainerAppReplicaRunningState string + +const ( + ContainerAppReplicaRunningStateNotRunning ContainerAppReplicaRunningState = "NotRunning" + ContainerAppReplicaRunningStateRunning ContainerAppReplicaRunningState = "Running" + ContainerAppReplicaRunningStateUnknown ContainerAppReplicaRunningState = "Unknown" +) + +func PossibleValuesForContainerAppReplicaRunningState() []string { + return []string{ + string(ContainerAppReplicaRunningStateNotRunning), + string(ContainerAppReplicaRunningStateRunning), + string(ContainerAppReplicaRunningStateUnknown), + } +} + +func (s *ContainerAppReplicaRunningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerAppReplicaRunningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerAppReplicaRunningState(input string) (*ContainerAppReplicaRunningState, error) { + vals := map[string]ContainerAppReplicaRunningState{ + "notrunning": ContainerAppReplicaRunningStateNotRunning, + "running": ContainerAppReplicaRunningStateRunning, + "unknown": ContainerAppReplicaRunningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerAppReplicaRunningState(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica.go new file mode 100644 index 00000000000..2f799e6a951 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica.go @@ -0,0 +1,148 @@ +package containerappsrevisionreplicas + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReplicaId{}) +} + +var _ resourceids.ResourceId = &ReplicaId{} + +// ReplicaId is a struct representing the Resource ID for a Replica +type ReplicaId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + RevisionName string + ReplicaName string +} + +// NewReplicaID returns a new ReplicaId struct +func NewReplicaID(subscriptionId string, resourceGroupName string, containerAppName string, revisionName string, replicaName string) ReplicaId { + return ReplicaId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + RevisionName: revisionName, + ReplicaName: replicaName, + } +} + +// ParseReplicaID parses 'input' into a ReplicaId +func ParseReplicaID(input string) (*ReplicaId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReplicaIDInsensitively parses 'input' case-insensitively into a ReplicaId +// note: this method should only be used for API response data and not user input +func ParseReplicaIDInsensitively(input string) (*ReplicaId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReplicaId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReplicaId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReplicaId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.RevisionName, ok = input.Parsed["revisionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "revisionName", input) + } + + if id.ReplicaName, ok = input.Parsed["replicaName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "replicaName", input) + } + + return nil +} + +// ValidateReplicaID checks that 'input' can be parsed as a Replica ID +func ValidateReplicaID(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 := ParseReplicaID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Replica ID +func (id ReplicaId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/revisions/%s/replicas/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.RevisionName, id.ReplicaName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Replica ID +func (id ReplicaId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticRevisions", "revisions", "revisions"), + resourceids.UserSpecifiedSegment("revisionName", "revisionValue"), + resourceids.StaticSegment("staticReplicas", "replicas", "replicas"), + resourceids.UserSpecifiedSegment("replicaName", "replicaValue"), + } +} + +// String returns a human-readable description of this Replica ID +func (id ReplicaId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Revision Name: %q", id.RevisionName), + fmt.Sprintf("Replica Name: %q", id.ReplicaName), + } + return fmt.Sprintf("Replica (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica_test.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica_test.go new file mode 100644 index 00000000000..7bd9752b279 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_replica_test.go @@ -0,0 +1,372 @@ +package containerappsrevisionreplicas + +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 = &ReplicaId{} + +func TestNewReplicaID(t *testing.T) { + id := NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue", "replicaValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.RevisionName != "revisionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RevisionName'", id.RevisionName, "revisionValue") + } + + if id.ReplicaName != "replicaValue" { + t.Fatalf("Expected %q but got %q for Segment 'ReplicaName'", id.ReplicaName, "replicaValue") + } +} + +func TestFormatReplicaID(t *testing.T) { + actual := NewReplicaID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue", "replicaValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/replicas/replicaValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReplicaID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/replicas", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/replicas/replicaValue", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + ReplicaName: "replicaValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/replicas/replicaValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + } +} + +func TestParseReplicaIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReplicaId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/replicas", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe/rEpLiCaS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/replicas/replicaValue", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + ReplicaName: "replicaValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/replicas/replicaValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe/rEpLiCaS/rEpLiCaVaLuE", + Expected: &ReplicaId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + RevisionName: "rEvIsIoNvAlUe", + ReplicaName: "rEpLiCaVaLuE", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe/rEpLiCaS/rEpLiCaVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReplicaIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + if actual.ReplicaName != v.Expected.ReplicaName { + t.Fatalf("Expected %q but got %q for ReplicaName", v.Expected.ReplicaName, actual.ReplicaName) + } + + } +} + +func TestSegmentsForReplicaId(t *testing.T) { + segments := ReplicaId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReplicaId 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/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision.go new file mode 100644 index 00000000000..9f3f6992915 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision.go @@ -0,0 +1,139 @@ +package containerappsrevisionreplicas + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RevisionId{}) +} + +var _ resourceids.ResourceId = &RevisionId{} + +// RevisionId is a struct representing the Resource ID for a Revision +type RevisionId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + RevisionName string +} + +// NewRevisionID returns a new RevisionId struct +func NewRevisionID(subscriptionId string, resourceGroupName string, containerAppName string, revisionName string) RevisionId { + return RevisionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + RevisionName: revisionName, + } +} + +// ParseRevisionID parses 'input' into a RevisionId +func ParseRevisionID(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRevisionIDInsensitively parses 'input' case-insensitively into a RevisionId +// note: this method should only be used for API response data and not user input +func ParseRevisionIDInsensitively(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RevisionId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.RevisionName, ok = input.Parsed["revisionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "revisionName", input) + } + + return nil +} + +// ValidateRevisionID checks that 'input' can be parsed as a Revision ID +func ValidateRevisionID(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 := ParseRevisionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Revision ID +func (id RevisionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/revisions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.RevisionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Revision ID +func (id RevisionId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticRevisions", "revisions", "revisions"), + resourceids.UserSpecifiedSegment("revisionName", "revisionValue"), + } +} + +// String returns a human-readable description of this Revision ID +func (id RevisionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Revision Name: %q", id.RevisionName), + } + return fmt.Sprintf("Revision (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision_test.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision_test.go new file mode 100644 index 00000000000..22cc0e0e63c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/id_revision_test.go @@ -0,0 +1,327 @@ +package containerappsrevisionreplicas + +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 = &RevisionId{} + +func TestNewRevisionID(t *testing.T) { + id := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.RevisionName != "revisionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RevisionName'", id.RevisionName, "revisionValue") + } +} + +func TestFormatRevisionID(t *testing.T) { + actual := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRevisionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestParseRevisionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + RevisionName: "rEvIsIoNvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestSegmentsForRevisionId(t *testing.T) { + segments := RevisionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RevisionId 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/containerapps/2024-03-01/containerappsrevisionreplicas/method_getreplica.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/method_getreplica.go new file mode 100644 index 00000000000..f6ce85856e3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/method_getreplica.go @@ -0,0 +1,54 @@ +package containerappsrevisionreplicas + +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 GetReplicaOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Replica +} + +// GetReplica ... +func (c ContainerAppsRevisionReplicasClient) GetReplica(ctx context.Context, id ReplicaId) (result GetReplicaOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Replica + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/method_listreplicas.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/method_listreplicas.go new file mode 100644 index 00000000000..8bbd98c80b4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/method_listreplicas.go @@ -0,0 +1,55 @@ +package containerappsrevisionreplicas + +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 ListReplicasOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicaCollection +} + +// ListReplicas ... +func (c ContainerAppsRevisionReplicasClient) ListReplicas(ctx context.Context, id RevisionId) (result ListReplicasOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReplicaCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replica.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replica.go new file mode 100644 index 00000000000..9c16392147d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replica.go @@ -0,0 +1,16 @@ +package containerappsrevisionreplicas + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Replica struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReplicaProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacollection.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacollection.go new file mode 100644 index 00000000000..89102c20ef8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacollection.go @@ -0,0 +1,8 @@ +package containerappsrevisionreplicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaCollection struct { + Value []Replica `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacontainer.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacontainer.go new file mode 100644 index 00000000000..65f98712252 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicacontainer.go @@ -0,0 +1,16 @@ +package containerappsrevisionreplicas + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicaContainer struct { + ContainerId *string `json:"containerId,omitempty"` + ExecEndpoint *string `json:"execEndpoint,omitempty"` + LogStreamEndpoint *string `json:"logStreamEndpoint,omitempty"` + Name *string `json:"name,omitempty"` + Ready *bool `json:"ready,omitempty"` + RestartCount *int64 `json:"restartCount,omitempty"` + RunningState *ContainerAppContainerRunningState `json:"runningState,omitempty"` + RunningStateDetails *string `json:"runningStateDetails,omitempty"` + Started *bool `json:"started,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicaproperties.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicaproperties.go new file mode 100644 index 00000000000..46fd7615b76 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/model_replicaproperties.go @@ -0,0 +1,30 @@ +package containerappsrevisionreplicas + +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 ReplicaProperties struct { + Containers *[]ReplicaContainer `json:"containers,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + InitContainers *[]ReplicaContainer `json:"initContainers,omitempty"` + RunningState *ContainerAppReplicaRunningState `json:"runningState,omitempty"` + RunningStateDetails *string `json:"runningStateDetails,omitempty"` +} + +func (o *ReplicaProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ReplicaProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/version.go b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/version.go new file mode 100644 index 00000000000..dcc1e63b9f6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisionreplicas/version.go @@ -0,0 +1,12 @@ +package containerappsrevisionreplicas + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/containerappsrevisionreplicas/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/README.md b/resource-manager/containerapps/2024-03-01/containerappsrevisions/README.md new file mode 100644 index 00000000000..55b3f8b3f6a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/README.md @@ -0,0 +1,101 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappsrevisions` Documentation + +The `containerappsrevisions` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/containerappsrevisions" +``` + + +### Client Initialization + +```go +client := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsRevisionsClient.ActivateRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.ActivateRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.DeactivateRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.DeactivateRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.GetRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.GetRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.ListRevisions` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.ListRevisions(ctx, id, containerappsrevisions.DefaultListRevisionsOperationOptions())` can be used to do batched pagination +items, err := client.ListRevisionsComplete(ctx, id, containerappsrevisions.DefaultListRevisionsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.RestartRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.RestartRevision(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/containerapps/2024-03-01/containerappsrevisions/client.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/client.go new file mode 100644 index 00000000000..6dd288e2fae --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/client.go @@ -0,0 +1,26 @@ +package containerappsrevisions + +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 ContainerAppsRevisionsClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsRevisionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsRevisionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerappsrevisions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsRevisionsClient: %+v", err) + } + + return &ContainerAppsRevisionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/constants.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/constants.go new file mode 100644 index 00000000000..2e4af3ea882 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/constants.go @@ -0,0 +1,286 @@ +package containerappsrevisions + +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 RevisionHealthState string + +const ( + RevisionHealthStateHealthy RevisionHealthState = "Healthy" + RevisionHealthStateNone RevisionHealthState = "None" + RevisionHealthStateUnhealthy RevisionHealthState = "Unhealthy" +) + +func PossibleValuesForRevisionHealthState() []string { + return []string{ + string(RevisionHealthStateHealthy), + string(RevisionHealthStateNone), + string(RevisionHealthStateUnhealthy), + } +} + +func (s *RevisionHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionHealthState(input string) (*RevisionHealthState, error) { + vals := map[string]RevisionHealthState{ + "healthy": RevisionHealthStateHealthy, + "none": RevisionHealthStateNone, + "unhealthy": RevisionHealthStateUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionHealthState(input) + return &out, nil +} + +type RevisionProvisioningState string + +const ( + RevisionProvisioningStateDeprovisioned RevisionProvisioningState = "Deprovisioned" + RevisionProvisioningStateDeprovisioning RevisionProvisioningState = "Deprovisioning" + RevisionProvisioningStateFailed RevisionProvisioningState = "Failed" + RevisionProvisioningStateProvisioned RevisionProvisioningState = "Provisioned" + RevisionProvisioningStateProvisioning RevisionProvisioningState = "Provisioning" +) + +func PossibleValuesForRevisionProvisioningState() []string { + return []string{ + string(RevisionProvisioningStateDeprovisioned), + string(RevisionProvisioningStateDeprovisioning), + string(RevisionProvisioningStateFailed), + string(RevisionProvisioningStateProvisioned), + string(RevisionProvisioningStateProvisioning), + } +} + +func (s *RevisionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionProvisioningState(input string) (*RevisionProvisioningState, error) { + vals := map[string]RevisionProvisioningState{ + "deprovisioned": RevisionProvisioningStateDeprovisioned, + "deprovisioning": RevisionProvisioningStateDeprovisioning, + "failed": RevisionProvisioningStateFailed, + "provisioned": RevisionProvisioningStateProvisioned, + "provisioning": RevisionProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionProvisioningState(input) + return &out, nil +} + +type RevisionRunningState string + +const ( + RevisionRunningStateDegraded RevisionRunningState = "Degraded" + RevisionRunningStateFailed RevisionRunningState = "Failed" + RevisionRunningStateProcessing RevisionRunningState = "Processing" + RevisionRunningStateRunning RevisionRunningState = "Running" + RevisionRunningStateStopped RevisionRunningState = "Stopped" + RevisionRunningStateUnknown RevisionRunningState = "Unknown" +) + +func PossibleValuesForRevisionRunningState() []string { + return []string{ + string(RevisionRunningStateDegraded), + string(RevisionRunningStateFailed), + string(RevisionRunningStateProcessing), + string(RevisionRunningStateRunning), + string(RevisionRunningStateStopped), + string(RevisionRunningStateUnknown), + } +} + +func (s *RevisionRunningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionRunningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionRunningState(input string) (*RevisionRunningState, error) { + vals := map[string]RevisionRunningState{ + "degraded": RevisionRunningStateDegraded, + "failed": RevisionRunningStateFailed, + "processing": RevisionRunningStateProcessing, + "running": RevisionRunningStateRunning, + "stopped": RevisionRunningStateStopped, + "unknown": RevisionRunningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionRunningState(input) + return &out, nil +} + +type Scheme string + +const ( + SchemeHTTP Scheme = "HTTP" + SchemeHTTPS Scheme = "HTTPS" +) + +func PossibleValuesForScheme() []string { + return []string{ + string(SchemeHTTP), + string(SchemeHTTPS), + } +} + +func (s *Scheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheme(input string) (*Scheme, error) { + vals := map[string]Scheme{ + "http": SchemeHTTP, + "https": SchemeHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Scheme(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeAzureFile StorageType = "AzureFile" + StorageTypeEmptyDir StorageType = "EmptyDir" + StorageTypeSecret StorageType = "Secret" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeAzureFile), + string(StorageTypeEmptyDir), + string(StorageTypeSecret), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "azurefile": StorageTypeAzureFile, + "emptydir": StorageTypeEmptyDir, + "secret": StorageTypeSecret, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type Type string + +const ( + TypeLiveness Type = "Liveness" + TypeReadiness Type = "Readiness" + TypeStartup Type = "Startup" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeLiveness), + string(TypeReadiness), + string(TypeStartup), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "liveness": TypeLiveness, + "readiness": TypeReadiness, + "startup": TypeStartup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp.go new file mode 100644 index 00000000000..469c5109b01 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp.go @@ -0,0 +1,130 @@ +package containerappsrevisions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppId{}) +} + +var _ resourceids.ResourceId = &ContainerAppId{} + +// ContainerAppId is a struct representing the Resource ID for a Container App +type ContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewContainerAppID returns a new ContainerAppId struct +func NewContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ContainerAppId { + return ContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseContainerAppID parses 'input' into a ContainerAppId +func ParseContainerAppID(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppIDInsensitively parses 'input' case-insensitively into a ContainerAppId +// note: this method should only be used for API response data and not user input +func ParseContainerAppIDInsensitively(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateContainerAppID checks that 'input' can be parsed as a Container App ID +func ValidateContainerAppID(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 := ParseContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App ID +func (id ContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App ID +func (id ContainerAppId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Container App ID +func (id ContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp_test.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp_test.go new file mode 100644 index 00000000000..3092edee96f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_containerapp_test.go @@ -0,0 +1,282 @@ +package containerappsrevisions + +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 = &ContainerAppId{} + +func TestNewContainerAppID(t *testing.T) { + id := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatContainerAppID(t *testing.T) { + actual := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForContainerAppId(t *testing.T) { + segments := ContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppId 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/containerapps/2024-03-01/containerappsrevisions/id_revision.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_revision.go new file mode 100644 index 00000000000..54f63273632 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_revision.go @@ -0,0 +1,139 @@ +package containerappsrevisions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RevisionId{}) +} + +var _ resourceids.ResourceId = &RevisionId{} + +// RevisionId is a struct representing the Resource ID for a Revision +type RevisionId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + RevisionName string +} + +// NewRevisionID returns a new RevisionId struct +func NewRevisionID(subscriptionId string, resourceGroupName string, containerAppName string, revisionName string) RevisionId { + return RevisionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + RevisionName: revisionName, + } +} + +// ParseRevisionID parses 'input' into a RevisionId +func ParseRevisionID(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRevisionIDInsensitively parses 'input' case-insensitively into a RevisionId +// note: this method should only be used for API response data and not user input +func ParseRevisionIDInsensitively(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RevisionId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.RevisionName, ok = input.Parsed["revisionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "revisionName", input) + } + + return nil +} + +// ValidateRevisionID checks that 'input' can be parsed as a Revision ID +func ValidateRevisionID(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 := ParseRevisionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Revision ID +func (id RevisionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/revisions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.RevisionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Revision ID +func (id RevisionId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticRevisions", "revisions", "revisions"), + resourceids.UserSpecifiedSegment("revisionName", "revisionValue"), + } +} + +// String returns a human-readable description of this Revision ID +func (id RevisionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Revision Name: %q", id.RevisionName), + } + return fmt.Sprintf("Revision (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_revision_test.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_revision_test.go new file mode 100644 index 00000000000..2c19af5f55d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/id_revision_test.go @@ -0,0 +1,327 @@ +package containerappsrevisions + +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 = &RevisionId{} + +func TestNewRevisionID(t *testing.T) { + id := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.RevisionName != "revisionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RevisionName'", id.RevisionName, "revisionValue") + } +} + +func TestFormatRevisionID(t *testing.T) { + actual := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRevisionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestParseRevisionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/revisions/revisionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + RevisionName: "rEvIsIoNvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestSegmentsForRevisionId(t *testing.T) { + segments := RevisionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RevisionId 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/containerapps/2024-03-01/containerappsrevisions/method_activaterevision.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_activaterevision.go new file mode 100644 index 00000000000..1745777ac96 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_activaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +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 ActivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ActivateRevision ... +func (c ContainerAppsRevisionsClient) ActivateRevision(ctx context.Context, id RevisionId) (result ActivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/activate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_deactivaterevision.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_deactivaterevision.go new file mode 100644 index 00000000000..46be1cffefd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_deactivaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +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 DeactivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeactivateRevision ... +func (c ContainerAppsRevisionsClient) DeactivateRevision(ctx context.Context, id RevisionId) (result DeactivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deactivate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_getrevision.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_getrevision.go new file mode 100644 index 00000000000..f2d02c1605e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_getrevision.go @@ -0,0 +1,54 @@ +package containerappsrevisions + +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 GetRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Revision +} + +// GetRevision ... +func (c ContainerAppsRevisionsClient) GetRevision(ctx context.Context, id RevisionId) (result GetRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Revision + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_listrevisions.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_listrevisions.go new file mode 100644 index 00000000000..a6b5bf891c1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_listrevisions.go @@ -0,0 +1,119 @@ +package containerappsrevisions + +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 ListRevisionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Revision +} + +type ListRevisionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Revision +} + +type ListRevisionsOperationOptions struct { + Filter *string +} + +func DefaultListRevisionsOperationOptions() ListRevisionsOperationOptions { + return ListRevisionsOperationOptions{} +} + +func (o ListRevisionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRevisionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListRevisionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListRevisions ... +func (c ContainerAppsRevisionsClient) ListRevisions(ctx context.Context, id ContainerAppId, options ListRevisionsOperationOptions) (result ListRevisionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/revisions", 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 *[]Revision `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRevisionsComplete retrieves all the results into a single object +func (c ContainerAppsRevisionsClient) ListRevisionsComplete(ctx context.Context, id ContainerAppId, options ListRevisionsOperationOptions) (ListRevisionsCompleteResult, error) { + return c.ListRevisionsCompleteMatchingPredicate(ctx, id, options, RevisionOperationPredicate{}) +} + +// ListRevisionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsRevisionsClient) ListRevisionsCompleteMatchingPredicate(ctx context.Context, id ContainerAppId, options ListRevisionsOperationOptions, predicate RevisionOperationPredicate) (result ListRevisionsCompleteResult, err error) { + items := make([]Revision, 0) + + resp, err := c.ListRevisions(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 = ListRevisionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_restartrevision.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_restartrevision.go new file mode 100644 index 00000000000..e228b363490 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/method_restartrevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +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 RestartRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RestartRevision ... +func (c ContainerAppsRevisionsClient) RestartRevision(ctx context.Context, id RevisionId) (result RestartRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_basecontainer.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_basecontainer.go new file mode 100644 index 00000000000..1826920dd68 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_basecontainer.go @@ -0,0 +1,14 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseContainer struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_container.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_container.go new file mode 100644 index 00000000000..7f1c19ea4b7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_container.go @@ -0,0 +1,15 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Probes *[]ContainerAppProbe `json:"probes,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobe.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobe.go new file mode 100644 index 00000000000..4ce8a07dffb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobe.go @@ -0,0 +1,16 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbe struct { + FailureThreshold *int64 `json:"failureThreshold,omitempty"` + HTTPGet *ContainerAppProbeHTTPGet `json:"httpGet,omitempty"` + InitialDelaySeconds *int64 `json:"initialDelaySeconds,omitempty"` + PeriodSeconds *int64 `json:"periodSeconds,omitempty"` + SuccessThreshold *int64 `json:"successThreshold,omitempty"` + TcpSocket *ContainerAppProbeTcpSocket `json:"tcpSocket,omitempty"` + TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpget.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpget.go new file mode 100644 index 00000000000..d52a1cf5da3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpget.go @@ -0,0 +1,12 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGet struct { + HTTPHeaders *[]ContainerAppProbeHTTPGetHTTPHeadersInlined `json:"httpHeaders,omitempty"` + Host *string `json:"host,omitempty"` + Path *string `json:"path,omitempty"` + Port int64 `json:"port"` + Scheme *Scheme `json:"scheme,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpgethttpheadersinlined.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpgethttpheadersinlined.go new file mode 100644 index 00000000000..d1917e04cf0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobehttpgethttpheadersinlined.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGetHTTPHeadersInlined struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobetcpsocket.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobetcpsocket.go new file mode 100644 index 00000000000..c751a9f613a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerappprobetcpsocket.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeTcpSocket struct { + Host *string `json:"host,omitempty"` + Port int64 `json:"port"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerresources.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerresources.go new file mode 100644 index 00000000000..3e3de8997a9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_containerresources.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + EphemeralStorage *string `json:"ephemeralStorage,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_customscalerule.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_customscalerule.go new file mode 100644 index 00000000000..601fb82b559 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_customscalerule.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_environmentvar.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_environmentvar.go new file mode 100644 index 00000000000..1b4d78fc7ed --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_environmentvar.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_httpscalerule.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_httpscalerule.go new file mode 100644 index 00000000000..17656fa5908 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_httpscalerule.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_queuescalerule.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_queuescalerule.go new file mode 100644 index 00000000000..016cc178897 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_queuescalerule.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + QueueLength *int64 `json:"queueLength,omitempty"` + QueueName *string `json:"queueName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revision.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revision.go new file mode 100644 index 00000000000..3b31b4ca691 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revision.go @@ -0,0 +1,16 @@ +package containerappsrevisions + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Revision struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RevisionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revisionproperties.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revisionproperties.go new file mode 100644 index 00000000000..9c61e1f4b45 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_revisionproperties.go @@ -0,0 +1,48 @@ +package containerappsrevisions + +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 RevisionProperties struct { + Active *bool `json:"active,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + HealthState *RevisionHealthState `json:"healthState,omitempty"` + LastActiveTime *string `json:"lastActiveTime,omitempty"` + ProvisioningError *string `json:"provisioningError,omitempty"` + ProvisioningState *RevisionProvisioningState `json:"provisioningState,omitempty"` + Replicas *int64 `json:"replicas,omitempty"` + RunningState *RevisionRunningState `json:"runningState,omitempty"` + Template *Template `json:"template,omitempty"` + TrafficWeight *int64 `json:"trafficWeight,omitempty"` +} + +func (o *RevisionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *RevisionProperties) GetLastActiveTimeAsTime() (*time.Time, error) { + if o.LastActiveTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastActiveTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetLastActiveTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastActiveTime = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scale.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scale.go new file mode 100644 index 00000000000..f6e99c4b779 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scale.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Scale struct { + MaxReplicas *int64 `json:"maxReplicas,omitempty"` + MinReplicas *int64 `json:"minReplicas,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scalerule.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scalerule.go new file mode 100644 index 00000000000..c456a55fad2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scalerule.go @@ -0,0 +1,12 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRule struct { + AzureQueue *QueueScaleRule `json:"azureQueue,omitempty"` + Custom *CustomScaleRule `json:"custom,omitempty"` + HTTP *HTTPScaleRule `json:"http,omitempty"` + Name *string `json:"name,omitempty"` + Tcp *TcpScaleRule `json:"tcp,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scaleruleauth.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scaleruleauth.go new file mode 100644 index 00000000000..2135985725a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_secretvolumeitem.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_secretvolumeitem.go new file mode 100644 index 00000000000..507833690ca --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_secretvolumeitem.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretVolumeItem struct { + Path *string `json:"path,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_servicebind.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_servicebind.go new file mode 100644 index 00000000000..91f1da05ffd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_servicebind.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceBind struct { + Name *string `json:"name,omitempty"` + ServiceId *string `json:"serviceId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_tcpscalerule.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_tcpscalerule.go new file mode 100644 index 00000000000..be173ac2b1a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_tcpscalerule.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TcpScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_template.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_template.go new file mode 100644 index 00000000000..8de2ea6c5bb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_template.go @@ -0,0 +1,14 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Template struct { + Containers *[]Container `json:"containers,omitempty"` + InitContainers *[]BaseContainer `json:"initContainers,omitempty"` + RevisionSuffix *string `json:"revisionSuffix,omitempty"` + Scale *Scale `json:"scale,omitempty"` + ServiceBinds *[]ServiceBind `json:"serviceBinds,omitempty"` + TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + Volumes *[]Volume `json:"volumes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volume.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volume.go new file mode 100644 index 00000000000..8088c22d516 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volume.go @@ -0,0 +1,12 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Volume struct { + MountOptions *string `json:"mountOptions,omitempty"` + Name *string `json:"name,omitempty"` + Secrets *[]SecretVolumeItem `json:"secrets,omitempty"` + StorageName *string `json:"storageName,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volumemount.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volumemount.go new file mode 100644 index 00000000000..2c57b8dd4c1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/model_volumemount.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeMount struct { + MountPath *string `json:"mountPath,omitempty"` + SubPath *string `json:"subPath,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappsrevisions/predicates.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/predicates.go new file mode 100644 index 00000000000..264c9985b0d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/predicates.go @@ -0,0 +1,27 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevisionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RevisionOperationPredicate) Matches(input Revision) 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/containerapps/2024-03-01/containerappsrevisions/version.go b/resource-manager/containerapps/2024-03-01/containerappsrevisions/version.go new file mode 100644 index 00000000000..bae4610f417 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappsrevisions/version.go @@ -0,0 +1,12 @@ +package containerappsrevisions + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/containerappsrevisions/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/README.md b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/README.md new file mode 100644 index 00000000000..4795fe584bf --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/containerappssourcecontrols` Documentation + +The `containerappssourcecontrols` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/containerappssourcecontrols" +``` + + +### Client Initialization + +```go +client := containerappssourcecontrols.NewContainerAppsSourceControlsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsSourceControlsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := containerappssourcecontrols.NewSourceControlID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "sourceControlValue") + +payload := containerappssourcecontrols.SourceControl{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsSourceControlsClient.Delete` + +```go +ctx := context.TODO() +id := containerappssourcecontrols.NewSourceControlID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "sourceControlValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsSourceControlsClient.Get` + +```go +ctx := context.TODO() +id := containerappssourcecontrols.NewSourceControlID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "sourceControlValue") + +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: `ContainerAppsSourceControlsClient.ListByContainerApp` + +```go +ctx := context.TODO() +id := containerappssourcecontrols.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.ListByContainerApp(ctx, id)` can be used to do batched pagination +items, err := client.ListByContainerAppComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/client.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/client.go new file mode 100644 index 00000000000..eb9a8a10a09 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/client.go @@ -0,0 +1,26 @@ +package containerappssourcecontrols + +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 ContainerAppsSourceControlsClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsSourceControlsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsSourceControlsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerappssourcecontrols", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsSourceControlsClient: %+v", err) + } + + return &ContainerAppsSourceControlsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/constants.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/constants.go new file mode 100644 index 00000000000..efb9bb4bbc4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/constants.go @@ -0,0 +1,57 @@ +package containerappssourcecontrols + +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 SourceControlOperationState string + +const ( + SourceControlOperationStateCanceled SourceControlOperationState = "Canceled" + SourceControlOperationStateFailed SourceControlOperationState = "Failed" + SourceControlOperationStateInProgress SourceControlOperationState = "InProgress" + SourceControlOperationStateSucceeded SourceControlOperationState = "Succeeded" +) + +func PossibleValuesForSourceControlOperationState() []string { + return []string{ + string(SourceControlOperationStateCanceled), + string(SourceControlOperationStateFailed), + string(SourceControlOperationStateInProgress), + string(SourceControlOperationStateSucceeded), + } +} + +func (s *SourceControlOperationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceControlOperationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceControlOperationState(input string) (*SourceControlOperationState, error) { + vals := map[string]SourceControlOperationState{ + "canceled": SourceControlOperationStateCanceled, + "failed": SourceControlOperationStateFailed, + "inprogress": SourceControlOperationStateInProgress, + "succeeded": SourceControlOperationStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceControlOperationState(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp.go new file mode 100644 index 00000000000..eac989dd012 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp.go @@ -0,0 +1,130 @@ +package containerappssourcecontrols + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppId{}) +} + +var _ resourceids.ResourceId = &ContainerAppId{} + +// ContainerAppId is a struct representing the Resource ID for a Container App +type ContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewContainerAppID returns a new ContainerAppId struct +func NewContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ContainerAppId { + return ContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseContainerAppID parses 'input' into a ContainerAppId +func ParseContainerAppID(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppIDInsensitively parses 'input' case-insensitively into a ContainerAppId +// note: this method should only be used for API response data and not user input +func ParseContainerAppIDInsensitively(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateContainerAppID checks that 'input' can be parsed as a Container App ID +func ValidateContainerAppID(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 := ParseContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App ID +func (id ContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App ID +func (id ContainerAppId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Container App ID +func (id ContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp_test.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp_test.go new file mode 100644 index 00000000000..aadd4603387 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_containerapp_test.go @@ -0,0 +1,282 @@ +package containerappssourcecontrols + +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 = &ContainerAppId{} + +func TestNewContainerAppID(t *testing.T) { + id := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatContainerAppID(t *testing.T) { + actual := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForContainerAppId(t *testing.T) { + segments := ContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppId 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/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol.go new file mode 100644 index 00000000000..e8444fd36fb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol.go @@ -0,0 +1,139 @@ +package containerappssourcecontrols + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SourceControlId{}) +} + +var _ resourceids.ResourceId = &SourceControlId{} + +// SourceControlId is a struct representing the Resource ID for a Source Control +type SourceControlId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + SourceControlName string +} + +// NewSourceControlID returns a new SourceControlId struct +func NewSourceControlID(subscriptionId string, resourceGroupName string, containerAppName string, sourceControlName string) SourceControlId { + return SourceControlId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + SourceControlName: sourceControlName, + } +} + +// ParseSourceControlID parses 'input' into a SourceControlId +func ParseSourceControlID(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSourceControlIDInsensitively parses 'input' case-insensitively into a SourceControlId +// note: this method should only be used for API response data and not user input +func ParseSourceControlIDInsensitively(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SourceControlId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.SourceControlName, ok = input.Parsed["sourceControlName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sourceControlName", input) + } + + return nil +} + +// ValidateSourceControlID checks that 'input' can be parsed as a Source Control ID +func ValidateSourceControlID(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 := ParseSourceControlID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Source Control ID +func (id SourceControlId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/sourceControls/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.SourceControlName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Source Control ID +func (id SourceControlId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticSourceControls", "sourceControls", "sourceControls"), + resourceids.UserSpecifiedSegment("sourceControlName", "sourceControlValue"), + } +} + +// String returns a human-readable description of this Source Control ID +func (id SourceControlId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Source Control Name: %q", id.SourceControlName), + } + return fmt.Sprintf("Source Control (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol_test.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol_test.go new file mode 100644 index 00000000000..a11e2d23b9d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/id_sourcecontrol_test.go @@ -0,0 +1,327 @@ +package containerappssourcecontrols + +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 = &SourceControlId{} + +func TestNewSourceControlID(t *testing.T) { + id := NewSourceControlID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "sourceControlValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.SourceControlName != "sourceControlValue" { + t.Fatalf("Expected %q but got %q for Segment 'SourceControlName'", id.SourceControlName, "sourceControlValue") + } +} + +func TestFormatSourceControlID(t *testing.T) { + actual := NewSourceControlID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "sourceControlValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/sourceControls/sourceControlValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSourceControlID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/sourceControls", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/sourceControls/sourceControlValue", + Expected: &SourceControlId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + SourceControlName: "sourceControlValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/sourceControls/sourceControlValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestParseSourceControlIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/sourceControls", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/sOuRcEcOnTrOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/sourceControls/sourceControlValue", + Expected: &SourceControlId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + SourceControlName: "sourceControlValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/sourceControls/sourceControlValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/sOuRcEcOnTrOlS/sOuRcEcOnTrOlVaLuE", + Expected: &SourceControlId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + SourceControlName: "sOuRcEcOnTrOlVaLuE", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/sOuRcEcOnTrOlS/sOuRcEcOnTrOlVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestSegmentsForSourceControlId(t *testing.T) { + segments := SourceControlId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SourceControlId 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/containerapps/2024-03-01/containerappssourcecontrols/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_createorupdate.go new file mode 100644 index 00000000000..2c94c7b08fc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_createorupdate.go @@ -0,0 +1,75 @@ +package containerappssourcecontrols + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// CreateOrUpdate ... +func (c ContainerAppsSourceControlsClient) CreateOrUpdate(ctx context.Context, id SourceControlId, input SourceControl) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ContainerAppsSourceControlsClient) CreateOrUpdateThenPoll(ctx context.Context, id SourceControlId, input SourceControl) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_delete.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_delete.go new file mode 100644 index 00000000000..45da30be268 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_delete.go @@ -0,0 +1,71 @@ +package containerappssourcecontrols + +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 ContainerAppsSourceControlsClient) Delete(ctx context.Context, id SourceControlId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ContainerAppsSourceControlsClient) DeleteThenPoll(ctx context.Context, id SourceControlId) 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/containerapps/2024-03-01/containerappssourcecontrols/method_get.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_get.go new file mode 100644 index 00000000000..0c0bdf0b5e4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_get.go @@ -0,0 +1,54 @@ +package containerappssourcecontrols + +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 *SourceControl +} + +// Get ... +func (c ContainerAppsSourceControlsClient) Get(ctx context.Context, id SourceControlId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SourceControl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_listbycontainerapp.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_listbycontainerapp.go new file mode 100644 index 00000000000..3c49e44b5c2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/method_listbycontainerapp.go @@ -0,0 +1,91 @@ +package containerappssourcecontrols + +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 ListByContainerAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SourceControl +} + +type ListByContainerAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []SourceControl +} + +// ListByContainerApp ... +func (c ContainerAppsSourceControlsClient) ListByContainerApp(ctx context.Context, id ContainerAppId) (result ListByContainerAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls", 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 *[]SourceControl `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByContainerAppComplete retrieves all the results into a single object +func (c ContainerAppsSourceControlsClient) ListByContainerAppComplete(ctx context.Context, id ContainerAppId) (ListByContainerAppCompleteResult, error) { + return c.ListByContainerAppCompleteMatchingPredicate(ctx, id, SourceControlOperationPredicate{}) +} + +// ListByContainerAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsSourceControlsClient) ListByContainerAppCompleteMatchingPredicate(ctx context.Context, id ContainerAppId, predicate SourceControlOperationPredicate) (result ListByContainerAppCompleteResult, err error) { + items := make([]SourceControl, 0) + + resp, err := c.ListByContainerApp(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 = ListByContainerAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_azurecredentials.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_azurecredentials.go new file mode 100644 index 00000000000..ccb7c6817cb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_azurecredentials.go @@ -0,0 +1,12 @@ +package containerappssourcecontrols + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureCredentials struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecret *string `json:"clientSecret,omitempty"` + Kind *string `json:"kind,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_githubactionconfiguration.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_githubactionconfiguration.go new file mode 100644 index 00000000000..ae0f9a31808 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_githubactionconfiguration.go @@ -0,0 +1,16 @@ +package containerappssourcecontrols + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GithubActionConfiguration struct { + AzureCredentials *AzureCredentials `json:"azureCredentials,omitempty"` + ContextPath *string `json:"contextPath,omitempty"` + GitHubPersonalAccessToken *string `json:"githubPersonalAccessToken,omitempty"` + Image *string `json:"image,omitempty"` + Os *string `json:"os,omitempty"` + PublishType *string `json:"publishType,omitempty"` + RegistryInfo *RegistryInfo `json:"registryInfo,omitempty"` + RuntimeStack *string `json:"runtimeStack,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_registryinfo.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_registryinfo.go new file mode 100644 index 00000000000..c2f9a160f71 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_registryinfo.go @@ -0,0 +1,10 @@ +package containerappssourcecontrols + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryInfo struct { + RegistryPassword *string `json:"registryPassword,omitempty"` + RegistryUrl *string `json:"registryUrl,omitempty"` + RegistryUserName *string `json:"registryUserName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrol.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrol.go new file mode 100644 index 00000000000..c04cf1897be --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrol.go @@ -0,0 +1,16 @@ +package containerappssourcecontrols + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceControl struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SourceControlProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrolproperties.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrolproperties.go new file mode 100644 index 00000000000..34a25bab4ce --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/model_sourcecontrolproperties.go @@ -0,0 +1,11 @@ +package containerappssourcecontrols + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceControlProperties struct { + Branch *string `json:"branch,omitempty"` + GitHubActionConfiguration *GithubActionConfiguration `json:"githubActionConfiguration,omitempty"` + OperationState *SourceControlOperationState `json:"operationState,omitempty"` + RepoUrl *string `json:"repoUrl,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/predicates.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/predicates.go new file mode 100644 index 00000000000..38f640c20f4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/predicates.go @@ -0,0 +1,27 @@ +package containerappssourcecontrols + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceControlOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p SourceControlOperationPredicate) Matches(input SourceControl) 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/containerapps/2024-03-01/containerappssourcecontrols/version.go b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/version.go new file mode 100644 index 00000000000..7356e7c867f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/containerappssourcecontrols/version.go @@ -0,0 +1,12 @@ +package containerappssourcecontrols + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/containerappssourcecontrols/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/README.md b/resource-manager/containerapps/2024-03-01/daprcomponents/README.md new file mode 100644 index 00000000000..0287cc1438e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/README.md @@ -0,0 +1,192 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/daprcomponents` Documentation + +The `daprcomponents` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/daprcomponents" +``` + + +### Client Initialization + +```go +client := daprcomponents.NewDaprComponentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DaprComponentsClient.ConnectedEnvironmentsDaprComponentsCreateOrUpdate` + +```go +ctx := context.TODO() +id := daprcomponents.NewConnectedEnvironmentDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "daprComponentValue") + +payload := daprcomponents.DaprComponent{ + // ... +} + + +read, err := client.ConnectedEnvironmentsDaprComponentsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DaprComponentsClient.ConnectedEnvironmentsDaprComponentsDelete` + +```go +ctx := context.TODO() +id := daprcomponents.NewConnectedEnvironmentDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "daprComponentValue") + +read, err := client.ConnectedEnvironmentsDaprComponentsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DaprComponentsClient.ConnectedEnvironmentsDaprComponentsGet` + +```go +ctx := context.TODO() +id := daprcomponents.NewConnectedEnvironmentDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "daprComponentValue") + +read, err := client.ConnectedEnvironmentsDaprComponentsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DaprComponentsClient.ConnectedEnvironmentsDaprComponentsList` + +```go +ctx := context.TODO() +id := daprcomponents.NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + +// alternatively `client.ConnectedEnvironmentsDaprComponentsList(ctx, id)` can be used to do batched pagination +items, err := client.ConnectedEnvironmentsDaprComponentsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DaprComponentsClient.ConnectedEnvironmentsDaprComponentsListSecrets` + +```go +ctx := context.TODO() +id := daprcomponents.NewConnectedEnvironmentDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "daprComponentValue") + +read, err := client.ConnectedEnvironmentsDaprComponentsListSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DaprComponentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := daprcomponents.NewDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "daprComponentValue") + +payload := daprcomponents.DaprComponent{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DaprComponentsClient.Delete` + +```go +ctx := context.TODO() +id := daprcomponents.NewDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "daprComponentValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DaprComponentsClient.Get` + +```go +ctx := context.TODO() +id := daprcomponents.NewDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "daprComponentValue") + +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: `DaprComponentsClient.List` + +```go +ctx := context.TODO() +id := daprcomponents.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// 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: `DaprComponentsClient.ListSecrets` + +```go +ctx := context.TODO() +id := daprcomponents.NewDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "daprComponentValue") + +read, err := client.ListSecrets(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/containerapps/2024-03-01/daprcomponents/client.go b/resource-manager/containerapps/2024-03-01/daprcomponents/client.go new file mode 100644 index 00000000000..f018f00bdee --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/client.go @@ -0,0 +1,26 @@ +package daprcomponents + +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 DaprComponentsClient struct { + Client *resourcemanager.Client +} + +func NewDaprComponentsClientWithBaseURI(sdkApi sdkEnv.Api) (*DaprComponentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "daprcomponents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DaprComponentsClient: %+v", err) + } + + return &DaprComponentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment.go new file mode 100644 index 00000000000..94391e0338e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment.go @@ -0,0 +1,130 @@ +package daprcomponents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentId{} + +// ConnectedEnvironmentId is a struct representing the Resource ID for a Connected Environment +type ConnectedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string +} + +// NewConnectedEnvironmentID returns a new ConnectedEnvironmentId struct +func NewConnectedEnvironmentID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string) ConnectedEnvironmentId { + return ConnectedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + } +} + +// ParseConnectedEnvironmentID parses 'input' into a ConnectedEnvironmentId +func ParseConnectedEnvironmentID(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentIDInsensitively(input string) (*ConnectedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentID checks that 'input' can be parsed as a Connected Environment ID +func ValidateConnectedEnvironmentID(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 := ParseConnectedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment ID +func (id ConnectedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment ID +func (id ConnectedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Connected Environment ID +func (id ConnectedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + } + return fmt.Sprintf("Connected Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment_test.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment_test.go new file mode 100644 index 00000000000..67aa8451963 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironment_test.go @@ -0,0 +1,282 @@ +package daprcomponents + +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 = &ConnectedEnvironmentId{} + +func TestNewConnectedEnvironmentID(t *testing.T) { + id := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } +} + +func TestFormatConnectedEnvironmentID(t *testing.T) { + actual := NewConnectedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestParseConnectedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Expected: &ConnectedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentId(t *testing.T) { + segments := ConnectedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentId 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/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent.go new file mode 100644 index 00000000000..554b54acb91 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent.go @@ -0,0 +1,139 @@ +package daprcomponents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectedEnvironmentDaprComponentId{}) +} + +var _ resourceids.ResourceId = &ConnectedEnvironmentDaprComponentId{} + +// ConnectedEnvironmentDaprComponentId is a struct representing the Resource ID for a Connected Environment Dapr Component +type ConnectedEnvironmentDaprComponentId struct { + SubscriptionId string + ResourceGroupName string + ConnectedEnvironmentName string + DaprComponentName string +} + +// NewConnectedEnvironmentDaprComponentID returns a new ConnectedEnvironmentDaprComponentId struct +func NewConnectedEnvironmentDaprComponentID(subscriptionId string, resourceGroupName string, connectedEnvironmentName string, daprComponentName string) ConnectedEnvironmentDaprComponentId { + return ConnectedEnvironmentDaprComponentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedEnvironmentName: connectedEnvironmentName, + DaprComponentName: daprComponentName, + } +} + +// ParseConnectedEnvironmentDaprComponentID parses 'input' into a ConnectedEnvironmentDaprComponentId +func ParseConnectedEnvironmentDaprComponentID(input string) (*ConnectedEnvironmentDaprComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentDaprComponentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentDaprComponentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedEnvironmentDaprComponentIDInsensitively parses 'input' case-insensitively into a ConnectedEnvironmentDaprComponentId +// note: this method should only be used for API response data and not user input +func ParseConnectedEnvironmentDaprComponentIDInsensitively(input string) (*ConnectedEnvironmentDaprComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectedEnvironmentDaprComponentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedEnvironmentDaprComponentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedEnvironmentDaprComponentId) 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.ConnectedEnvironmentName, ok = input.Parsed["connectedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedEnvironmentName", input) + } + + if id.DaprComponentName, ok = input.Parsed["daprComponentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "daprComponentName", input) + } + + return nil +} + +// ValidateConnectedEnvironmentDaprComponentID checks that 'input' can be parsed as a Connected Environment Dapr Component ID +func ValidateConnectedEnvironmentDaprComponentID(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 := ParseConnectedEnvironmentDaprComponentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Environment Dapr Component ID +func (id ConnectedEnvironmentDaprComponentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/connectedEnvironments/%s/daprComponents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedEnvironmentName, id.DaprComponentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Environment Dapr Component ID +func (id ConnectedEnvironmentDaprComponentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticConnectedEnvironments", "connectedEnvironments", "connectedEnvironments"), + resourceids.UserSpecifiedSegment("connectedEnvironmentName", "connectedEnvironmentValue"), + resourceids.StaticSegment("staticDaprComponents", "daprComponents", "daprComponents"), + resourceids.UserSpecifiedSegment("daprComponentName", "daprComponentValue"), + } +} + +// String returns a human-readable description of this Connected Environment Dapr Component ID +func (id ConnectedEnvironmentDaprComponentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Environment Name: %q", id.ConnectedEnvironmentName), + fmt.Sprintf("Dapr Component Name: %q", id.DaprComponentName), + } + return fmt.Sprintf("Connected Environment Dapr Component (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent_test.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent_test.go new file mode 100644 index 00000000000..0207db175e2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_connectedenvironmentdaprcomponent_test.go @@ -0,0 +1,327 @@ +package daprcomponents + +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 = &ConnectedEnvironmentDaprComponentId{} + +func TestNewConnectedEnvironmentDaprComponentID(t *testing.T) { + id := NewConnectedEnvironmentDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "daprComponentValue") + + 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.ConnectedEnvironmentName != "connectedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedEnvironmentName'", id.ConnectedEnvironmentName, "connectedEnvironmentValue") + } + + if id.DaprComponentName != "daprComponentValue" { + t.Fatalf("Expected %q but got %q for Segment 'DaprComponentName'", id.DaprComponentName, "daprComponentValue") + } +} + +func TestFormatConnectedEnvironmentDaprComponentID(t *testing.T) { + actual := NewConnectedEnvironmentDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedEnvironmentValue", "daprComponentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/daprComponents/daprComponentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedEnvironmentDaprComponentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentDaprComponentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/daprComponents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/daprComponents/daprComponentValue", + Expected: &ConnectedEnvironmentDaprComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + DaprComponentName: "daprComponentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/daprComponents/daprComponentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentDaprComponentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.DaprComponentName != v.Expected.DaprComponentName { + t.Fatalf("Expected %q but got %q for DaprComponentName", v.Expected.DaprComponentName, actual.DaprComponentName) + } + + } +} + +func TestParseConnectedEnvironmentDaprComponentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedEnvironmentDaprComponentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/daprComponents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/dApRcOmPoNeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/daprComponents/daprComponentValue", + Expected: &ConnectedEnvironmentDaprComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedEnvironmentName: "connectedEnvironmentValue", + DaprComponentName: "daprComponentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/connectedEnvironments/connectedEnvironmentValue/daprComponents/daprComponentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/dApRcOmPoNeNtS/dApRcOmPoNeNtVaLuE", + Expected: &ConnectedEnvironmentDaprComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedEnvironmentName: "cOnNeCtEdEnViRoNmEnTvAlUe", + DaprComponentName: "dApRcOmPoNeNtVaLuE", + }, + }, + { + // 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.aPp/cOnNeCtEdEnViRoNmEnTs/cOnNeCtEdEnViRoNmEnTvAlUe/dApRcOmPoNeNtS/dApRcOmPoNeNtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedEnvironmentDaprComponentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectedEnvironmentName != v.Expected.ConnectedEnvironmentName { + t.Fatalf("Expected %q but got %q for ConnectedEnvironmentName", v.Expected.ConnectedEnvironmentName, actual.ConnectedEnvironmentName) + } + + if actual.DaprComponentName != v.Expected.DaprComponentName { + t.Fatalf("Expected %q but got %q for DaprComponentName", v.Expected.DaprComponentName, actual.DaprComponentName) + } + + } +} + +func TestSegmentsForConnectedEnvironmentDaprComponentId(t *testing.T) { + segments := ConnectedEnvironmentDaprComponentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedEnvironmentDaprComponentId 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/containerapps/2024-03-01/daprcomponents/id_daprcomponent.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_daprcomponent.go new file mode 100644 index 00000000000..755d9dc094d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_daprcomponent.go @@ -0,0 +1,139 @@ +package daprcomponents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DaprComponentId{}) +} + +var _ resourceids.ResourceId = &DaprComponentId{} + +// DaprComponentId is a struct representing the Resource ID for a Dapr Component +type DaprComponentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + DaprComponentName string +} + +// NewDaprComponentID returns a new DaprComponentId struct +func NewDaprComponentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, daprComponentName string) DaprComponentId { + return DaprComponentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + DaprComponentName: daprComponentName, + } +} + +// ParseDaprComponentID parses 'input' into a DaprComponentId +func ParseDaprComponentID(input string) (*DaprComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DaprComponentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DaprComponentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDaprComponentIDInsensitively parses 'input' case-insensitively into a DaprComponentId +// note: this method should only be used for API response data and not user input +func ParseDaprComponentIDInsensitively(input string) (*DaprComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DaprComponentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DaprComponentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DaprComponentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.DaprComponentName, ok = input.Parsed["daprComponentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "daprComponentName", input) + } + + return nil +} + +// ValidateDaprComponentID checks that 'input' can be parsed as a Dapr Component ID +func ValidateDaprComponentID(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 := ParseDaprComponentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dapr Component ID +func (id DaprComponentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/daprComponents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.DaprComponentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dapr Component ID +func (id DaprComponentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticDaprComponents", "daprComponents", "daprComponents"), + resourceids.UserSpecifiedSegment("daprComponentName", "daprComponentValue"), + } +} + +// String returns a human-readable description of this Dapr Component ID +func (id DaprComponentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Dapr Component Name: %q", id.DaprComponentName), + } + return fmt.Sprintf("Dapr Component (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/id_daprcomponent_test.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_daprcomponent_test.go new file mode 100644 index 00000000000..cb4d34dae70 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_daprcomponent_test.go @@ -0,0 +1,327 @@ +package daprcomponents + +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 = &DaprComponentId{} + +func TestNewDaprComponentID(t *testing.T) { + id := NewDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "daprComponentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.DaprComponentName != "daprComponentValue" { + t.Fatalf("Expected %q but got %q for Segment 'DaprComponentName'", id.DaprComponentName, "daprComponentValue") + } +} + +func TestFormatDaprComponentID(t *testing.T) { + actual := NewDaprComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "daprComponentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/daprComponents/daprComponentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDaprComponentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DaprComponentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/daprComponents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/daprComponents/daprComponentValue", + Expected: &DaprComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + DaprComponentName: "daprComponentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/daprComponents/daprComponentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDaprComponentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.DaprComponentName != v.Expected.DaprComponentName { + t.Fatalf("Expected %q but got %q for DaprComponentName", v.Expected.DaprComponentName, actual.DaprComponentName) + } + + } +} + +func TestParseDaprComponentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DaprComponentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/daprComponents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dApRcOmPoNeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/daprComponents/daprComponentValue", + Expected: &DaprComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + DaprComponentName: "daprComponentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/daprComponents/daprComponentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dApRcOmPoNeNtS/dApRcOmPoNeNtVaLuE", + Expected: &DaprComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + DaprComponentName: "dApRcOmPoNeNtVaLuE", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dApRcOmPoNeNtS/dApRcOmPoNeNtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDaprComponentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.DaprComponentName != v.Expected.DaprComponentName { + t.Fatalf("Expected %q but got %q for DaprComponentName", v.Expected.DaprComponentName, actual.DaprComponentName) + } + + } +} + +func TestSegmentsForDaprComponentId(t *testing.T) { + segments := DaprComponentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DaprComponentId 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/containerapps/2024-03-01/daprcomponents/id_managedenvironment.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_managedenvironment.go new file mode 100644 index 00000000000..d2a90d1954e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_managedenvironment.go @@ -0,0 +1,130 @@ +package daprcomponents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentId{} + +// ManagedEnvironmentId is a struct representing the Resource ID for a Managed Environment +type ManagedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string +} + +// NewManagedEnvironmentID returns a new ManagedEnvironmentId struct +func NewManagedEnvironmentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string) ManagedEnvironmentId { + return ManagedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + } +} + +// ParseManagedEnvironmentID parses 'input' into a ManagedEnvironmentId +func ParseManagedEnvironmentID(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentIDInsensitively(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + return nil +} + +// ValidateManagedEnvironmentID checks that 'input' can be parsed as a Managed Environment ID +func ValidateManagedEnvironmentID(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 := ParseManagedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment ID +func (id ManagedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment ID +func (id ManagedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Managed Environment ID +func (id ManagedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + } + return fmt.Sprintf("Managed Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/id_managedenvironment_test.go b/resource-manager/containerapps/2024-03-01/daprcomponents/id_managedenvironment_test.go new file mode 100644 index 00000000000..4cae8ce7f5e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/id_managedenvironment_test.go @@ -0,0 +1,282 @@ +package daprcomponents + +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 = &ManagedEnvironmentId{} + +func TestNewManagedEnvironmentID(t *testing.T) { + id := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } +} + +func TestFormatManagedEnvironmentID(t *testing.T) { + actual := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestParseManagedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestSegmentsForManagedEnvironmentId(t *testing.T) { + segments := ManagedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentId 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/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentscreateorupdate.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentscreateorupdate.go new file mode 100644 index 00000000000..b372ec0d96c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentscreateorupdate.go @@ -0,0 +1,58 @@ +package daprcomponents + +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 ConnectedEnvironmentsDaprComponentsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DaprComponent +} + +// ConnectedEnvironmentsDaprComponentsCreateOrUpdate ... +func (c DaprComponentsClient) ConnectedEnvironmentsDaprComponentsCreateOrUpdate(ctx context.Context, id ConnectedEnvironmentDaprComponentId, input DaprComponent) (result ConnectedEnvironmentsDaprComponentsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DaprComponent + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsdelete.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsdelete.go new file mode 100644 index 00000000000..2b8c43d7177 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsdelete.go @@ -0,0 +1,47 @@ +package daprcomponents + +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 ConnectedEnvironmentsDaprComponentsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ConnectedEnvironmentsDaprComponentsDelete ... +func (c DaprComponentsClient) ConnectedEnvironmentsDaprComponentsDelete(ctx context.Context, id ConnectedEnvironmentDaprComponentId) (result ConnectedEnvironmentsDaprComponentsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsget.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsget.go new file mode 100644 index 00000000000..3336d264da5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentsget.go @@ -0,0 +1,54 @@ +package daprcomponents + +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 ConnectedEnvironmentsDaprComponentsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DaprComponent +} + +// ConnectedEnvironmentsDaprComponentsGet ... +func (c DaprComponentsClient) ConnectedEnvironmentsDaprComponentsGet(ctx context.Context, id ConnectedEnvironmentDaprComponentId) (result ConnectedEnvironmentsDaprComponentsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DaprComponent + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslist.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslist.go new file mode 100644 index 00000000000..7e24f6957ac --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslist.go @@ -0,0 +1,91 @@ +package daprcomponents + +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 ConnectedEnvironmentsDaprComponentsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DaprComponent +} + +type ConnectedEnvironmentsDaprComponentsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DaprComponent +} + +// ConnectedEnvironmentsDaprComponentsList ... +func (c DaprComponentsClient) ConnectedEnvironmentsDaprComponentsList(ctx context.Context, id ConnectedEnvironmentId) (result ConnectedEnvironmentsDaprComponentsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/daprComponents", 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 *[]DaprComponent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ConnectedEnvironmentsDaprComponentsListComplete retrieves all the results into a single object +func (c DaprComponentsClient) ConnectedEnvironmentsDaprComponentsListComplete(ctx context.Context, id ConnectedEnvironmentId) (ConnectedEnvironmentsDaprComponentsListCompleteResult, error) { + return c.ConnectedEnvironmentsDaprComponentsListCompleteMatchingPredicate(ctx, id, DaprComponentOperationPredicate{}) +} + +// ConnectedEnvironmentsDaprComponentsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DaprComponentsClient) ConnectedEnvironmentsDaprComponentsListCompleteMatchingPredicate(ctx context.Context, id ConnectedEnvironmentId, predicate DaprComponentOperationPredicate) (result ConnectedEnvironmentsDaprComponentsListCompleteResult, err error) { + items := make([]DaprComponent, 0) + + resp, err := c.ConnectedEnvironmentsDaprComponentsList(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 = ConnectedEnvironmentsDaprComponentsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslistsecrets.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslistsecrets.go new file mode 100644 index 00000000000..57cb5795567 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_connectedenvironmentsdaprcomponentslistsecrets.go @@ -0,0 +1,55 @@ +package daprcomponents + +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 ConnectedEnvironmentsDaprComponentsListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DaprSecretsCollection +} + +// ConnectedEnvironmentsDaprComponentsListSecrets ... +func (c DaprComponentsClient) ConnectedEnvironmentsDaprComponentsListSecrets(ctx context.Context, id ConnectedEnvironmentDaprComponentId) (result ConnectedEnvironmentsDaprComponentsListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DaprSecretsCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_createorupdate.go new file mode 100644 index 00000000000..d19e2f104cb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_createorupdate.go @@ -0,0 +1,58 @@ +package daprcomponents + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DaprComponent +} + +// CreateOrUpdate ... +func (c DaprComponentsClient) CreateOrUpdate(ctx context.Context, id DaprComponentId, input DaprComponent) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DaprComponent + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_delete.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_delete.go new file mode 100644 index 00000000000..211efc17f75 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_delete.go @@ -0,0 +1,47 @@ +package daprcomponents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DaprComponentsClient) Delete(ctx context.Context, id DaprComponentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_get.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_get.go new file mode 100644 index 00000000000..3ce780b6d03 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_get.go @@ -0,0 +1,54 @@ +package daprcomponents + +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 *DaprComponent +} + +// Get ... +func (c DaprComponentsClient) Get(ctx context.Context, id DaprComponentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DaprComponent + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/method_list.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_list.go new file mode 100644 index 00000000000..f8c32e7ec59 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_list.go @@ -0,0 +1,91 @@ +package daprcomponents + +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 *[]DaprComponent +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DaprComponent +} + +// List ... +func (c DaprComponentsClient) List(ctx context.Context, id ManagedEnvironmentId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/daprComponents", 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 *[]DaprComponent `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 DaprComponentsClient) ListComplete(ctx context.Context, id ManagedEnvironmentId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DaprComponentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DaprComponentsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate DaprComponentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DaprComponent, 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/containerapps/2024-03-01/daprcomponents/method_listsecrets.go b/resource-manager/containerapps/2024-03-01/daprcomponents/method_listsecrets.go new file mode 100644 index 00000000000..636ae80459c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/method_listsecrets.go @@ -0,0 +1,55 @@ +package daprcomponents + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DaprSecretsCollection +} + +// ListSecrets ... +func (c DaprComponentsClient) ListSecrets(ctx context.Context, id DaprComponentId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DaprSecretsCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponent.go b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponent.go new file mode 100644 index 00000000000..bb4b6f41c32 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponent.go @@ -0,0 +1,16 @@ +package daprcomponents + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprComponent struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DaprComponentProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponentproperties.go b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponentproperties.go new file mode 100644 index 00000000000..5dba15d7cdd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprcomponentproperties.go @@ -0,0 +1,15 @@ +package daprcomponents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprComponentProperties struct { + ComponentType *string `json:"componentType,omitempty"` + IgnoreErrors *bool `json:"ignoreErrors,omitempty"` + InitTimeout *string `json:"initTimeout,omitempty"` + Metadata *[]DaprMetadata `json:"metadata,omitempty"` + Scopes *[]string `json:"scopes,omitempty"` + SecretStoreComponent *string `json:"secretStoreComponent,omitempty"` + Secrets *[]Secret `json:"secrets,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprmetadata.go b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprmetadata.go new file mode 100644 index 00000000000..8b82e1749b4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprmetadata.go @@ -0,0 +1,10 @@ +package daprcomponents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprMetadata struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecret.go b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecret.go new file mode 100644 index 00000000000..82ce596575c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecret.go @@ -0,0 +1,9 @@ +package daprcomponents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprSecret struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecretscollection.go b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecretscollection.go new file mode 100644 index 00000000000..0f52a6c5f30 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/model_daprsecretscollection.go @@ -0,0 +1,8 @@ +package daprcomponents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprSecretsCollection struct { + Value []DaprSecret `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/model_secret.go b/resource-manager/containerapps/2024-03-01/daprcomponents/model_secret.go new file mode 100644 index 00000000000..a4647e5d6ec --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/model_secret.go @@ -0,0 +1,11 @@ +package daprcomponents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Secret struct { + Identity *string `json:"identity,omitempty"` + KeyVaultUrl *string `json:"keyVaultUrl,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/daprcomponents/predicates.go b/resource-manager/containerapps/2024-03-01/daprcomponents/predicates.go new file mode 100644 index 00000000000..c623d167466 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/predicates.go @@ -0,0 +1,27 @@ +package daprcomponents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprComponentOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DaprComponentOperationPredicate) Matches(input DaprComponent) 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/containerapps/2024-03-01/daprcomponents/version.go b/resource-manager/containerapps/2024-03-01/daprcomponents/version.go new file mode 100644 index 00000000000..02ae3cd889d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/daprcomponents/version.go @@ -0,0 +1,12 @@ +package daprcomponents + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/daprcomponents/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/README.md b/resource-manager/containerapps/2024-03-01/diagnostics/README.md new file mode 100644 index 00000000000..7b95aa26573 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/README.md @@ -0,0 +1,200 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/diagnostics` Documentation + +The `diagnostics` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/diagnostics" +``` + + +### Client Initialization + +```go +client := diagnostics.NewDiagnosticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiagnosticsClient.ContainerAppsDiagnosticsGetDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewContainerAppDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "detectorValue") + +read, err := client.ContainerAppsDiagnosticsGetDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ContainerAppsDiagnosticsGetRevision` + +```go +ctx := context.TODO() +id := diagnostics.NewRevisionsApiRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.ContainerAppsDiagnosticsGetRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ContainerAppsDiagnosticsGetRoot` + +```go +ctx := context.TODO() +id := diagnostics.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +read, err := client.ContainerAppsDiagnosticsGetRoot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ContainerAppsDiagnosticsListDetectors` + +```go +ctx := context.TODO() +id := diagnostics.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.ContainerAppsDiagnosticsListDetectors(ctx, id)` can be used to do batched pagination +items, err := client.ContainerAppsDiagnosticsListDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ContainerAppsDiagnosticsListRevisions` + +```go +ctx := context.TODO() +id := diagnostics.NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.ContainerAppsDiagnosticsListRevisions(ctx, id, diagnostics.DefaultContainerAppsDiagnosticsListRevisionsOperationOptions())` can be used to do batched pagination +items, err := client.ContainerAppsDiagnosticsListRevisionsComplete(ctx, id, diagnostics.DefaultContainerAppsDiagnosticsListRevisionsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.JobsGetDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorValue") + +read, err := client.JobsGetDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.JobsListDetectors` + +```go +ctx := context.TODO() +id := diagnostics.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +// alternatively `client.JobsListDetectors(ctx, id)` can be used to do batched pagination +items, err := client.JobsListDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.JobsProxyGet` + +```go +ctx := context.TODO() +id := diagnostics.NewDetectorPropertyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorPropertyValue") + +read, err := client.JobsProxyGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ManagedEnvironmentDiagnosticsGetDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewManagedEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "detectorValue") + +read, err := client.ManagedEnvironmentDiagnosticsGetDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ManagedEnvironmentDiagnosticsListDetectors` + +```go +ctx := context.TODO() +id := diagnostics.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// alternatively `client.ManagedEnvironmentDiagnosticsListDetectors(ctx, id)` can be used to do batched pagination +items, err := client.ManagedEnvironmentDiagnosticsListDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ManagedEnvironmentsDiagnosticsGetRoot` + +```go +ctx := context.TODO() +id := diagnostics.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +read, err := client.ManagedEnvironmentsDiagnosticsGetRoot(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/containerapps/2024-03-01/diagnostics/client.go b/resource-manager/containerapps/2024-03-01/diagnostics/client.go new file mode 100644 index 00000000000..134561e1c49 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/client.go @@ -0,0 +1,26 @@ +package diagnostics + +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 DiagnosticsClient struct { + Client *resourcemanager.Client +} + +func NewDiagnosticsClientWithBaseURI(sdkApi sdkEnv.Api) (*DiagnosticsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "diagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticsClient: %+v", err) + } + + return &DiagnosticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/constants.go b/resource-manager/containerapps/2024-03-01/diagnostics/constants.go new file mode 100644 index 00000000000..76cc6d7814e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/constants.go @@ -0,0 +1,876 @@ +package diagnostics + +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 Action string + +const ( + ActionAllow Action = "Allow" + ActionDeny Action = "Deny" +) + +func PossibleValuesForAction() []string { + return []string{ + string(ActionAllow), + string(ActionDeny), + } +} + +func (s *Action) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAction(input string) (*Action, error) { + vals := map[string]Action{ + "allow": ActionAllow, + "deny": ActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Action(input) + return &out, nil +} + +type ActiveRevisionsMode string + +const ( + ActiveRevisionsModeMultiple ActiveRevisionsMode = "Multiple" + ActiveRevisionsModeSingle ActiveRevisionsMode = "Single" +) + +func PossibleValuesForActiveRevisionsMode() []string { + return []string{ + string(ActiveRevisionsModeMultiple), + string(ActiveRevisionsModeSingle), + } +} + +func (s *ActiveRevisionsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveRevisionsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActiveRevisionsMode(input string) (*ActiveRevisionsMode, error) { + vals := map[string]ActiveRevisionsMode{ + "multiple": ActiveRevisionsModeMultiple, + "single": ActiveRevisionsModeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActiveRevisionsMode(input) + return &out, nil +} + +type Affinity string + +const ( + AffinityNone Affinity = "none" + AffinitySticky Affinity = "sticky" +) + +func PossibleValuesForAffinity() []string { + return []string{ + string(AffinityNone), + string(AffinitySticky), + } +} + +func (s *Affinity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAffinity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAffinity(input string) (*Affinity, error) { + vals := map[string]Affinity{ + "none": AffinityNone, + "sticky": AffinitySticky, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Affinity(input) + return &out, nil +} + +type AppProtocol string + +const ( + AppProtocolGrpc AppProtocol = "grpc" + AppProtocolHTTP AppProtocol = "http" +) + +func PossibleValuesForAppProtocol() []string { + return []string{ + string(AppProtocolGrpc), + string(AppProtocolHTTP), + } +} + +func (s *AppProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAppProtocol(input string) (*AppProtocol, error) { + vals := map[string]AppProtocol{ + "grpc": AppProtocolGrpc, + "http": AppProtocolHTTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AppProtocol(input) + return &out, nil +} + +type BindingType string + +const ( + BindingTypeDisabled BindingType = "Disabled" + BindingTypeSniEnabled BindingType = "SniEnabled" +) + +func PossibleValuesForBindingType() []string { + return []string{ + string(BindingTypeDisabled), + string(BindingTypeSniEnabled), + } +} + +func (s *BindingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBindingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBindingType(input string) (*BindingType, error) { + vals := map[string]BindingType{ + "disabled": BindingTypeDisabled, + "snienabled": BindingTypeSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BindingType(input) + return &out, nil +} + +type ContainerAppProvisioningState string + +const ( + ContainerAppProvisioningStateCanceled ContainerAppProvisioningState = "Canceled" + ContainerAppProvisioningStateDeleting ContainerAppProvisioningState = "Deleting" + ContainerAppProvisioningStateFailed ContainerAppProvisioningState = "Failed" + ContainerAppProvisioningStateInProgress ContainerAppProvisioningState = "InProgress" + ContainerAppProvisioningStateSucceeded ContainerAppProvisioningState = "Succeeded" +) + +func PossibleValuesForContainerAppProvisioningState() []string { + return []string{ + string(ContainerAppProvisioningStateCanceled), + string(ContainerAppProvisioningStateDeleting), + string(ContainerAppProvisioningStateFailed), + string(ContainerAppProvisioningStateInProgress), + string(ContainerAppProvisioningStateSucceeded), + } +} + +func (s *ContainerAppProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerAppProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerAppProvisioningState(input string) (*ContainerAppProvisioningState, error) { + vals := map[string]ContainerAppProvisioningState{ + "canceled": ContainerAppProvisioningStateCanceled, + "deleting": ContainerAppProvisioningStateDeleting, + "failed": ContainerAppProvisioningStateFailed, + "inprogress": ContainerAppProvisioningStateInProgress, + "succeeded": ContainerAppProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerAppProvisioningState(input) + return &out, nil +} + +type EnvironmentProvisioningState string + +const ( + EnvironmentProvisioningStateCanceled EnvironmentProvisioningState = "Canceled" + EnvironmentProvisioningStateFailed EnvironmentProvisioningState = "Failed" + EnvironmentProvisioningStateInfrastructureSetupComplete EnvironmentProvisioningState = "InfrastructureSetupComplete" + EnvironmentProvisioningStateInfrastructureSetupInProgress EnvironmentProvisioningState = "InfrastructureSetupInProgress" + EnvironmentProvisioningStateInitializationInProgress EnvironmentProvisioningState = "InitializationInProgress" + EnvironmentProvisioningStateScheduledForDelete EnvironmentProvisioningState = "ScheduledForDelete" + EnvironmentProvisioningStateSucceeded EnvironmentProvisioningState = "Succeeded" + EnvironmentProvisioningStateUpgradeFailed EnvironmentProvisioningState = "UpgradeFailed" + EnvironmentProvisioningStateUpgradeRequested EnvironmentProvisioningState = "UpgradeRequested" + EnvironmentProvisioningStateWaiting EnvironmentProvisioningState = "Waiting" +) + +func PossibleValuesForEnvironmentProvisioningState() []string { + return []string{ + string(EnvironmentProvisioningStateCanceled), + string(EnvironmentProvisioningStateFailed), + string(EnvironmentProvisioningStateInfrastructureSetupComplete), + string(EnvironmentProvisioningStateInfrastructureSetupInProgress), + string(EnvironmentProvisioningStateInitializationInProgress), + string(EnvironmentProvisioningStateScheduledForDelete), + string(EnvironmentProvisioningStateSucceeded), + string(EnvironmentProvisioningStateUpgradeFailed), + string(EnvironmentProvisioningStateUpgradeRequested), + string(EnvironmentProvisioningStateWaiting), + } +} + +func (s *EnvironmentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnvironmentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnvironmentProvisioningState(input string) (*EnvironmentProvisioningState, error) { + vals := map[string]EnvironmentProvisioningState{ + "canceled": EnvironmentProvisioningStateCanceled, + "failed": EnvironmentProvisioningStateFailed, + "infrastructuresetupcomplete": EnvironmentProvisioningStateInfrastructureSetupComplete, + "infrastructuresetupinprogress": EnvironmentProvisioningStateInfrastructureSetupInProgress, + "initializationinprogress": EnvironmentProvisioningStateInitializationInProgress, + "scheduledfordelete": EnvironmentProvisioningStateScheduledForDelete, + "succeeded": EnvironmentProvisioningStateSucceeded, + "upgradefailed": EnvironmentProvisioningStateUpgradeFailed, + "upgraderequested": EnvironmentProvisioningStateUpgradeRequested, + "waiting": EnvironmentProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnvironmentProvisioningState(input) + return &out, nil +} + +type ExtendedLocationTypes string + +const ( + ExtendedLocationTypesCustomLocation ExtendedLocationTypes = "CustomLocation" +) + +func PossibleValuesForExtendedLocationTypes() []string { + return []string{ + string(ExtendedLocationTypesCustomLocation), + } +} + +func (s *ExtendedLocationTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExtendedLocationTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExtendedLocationTypes(input string) (*ExtendedLocationTypes, error) { + vals := map[string]ExtendedLocationTypes{ + "customlocation": ExtendedLocationTypesCustomLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExtendedLocationTypes(input) + return &out, nil +} + +type IngressClientCertificateMode string + +const ( + IngressClientCertificateModeAccept IngressClientCertificateMode = "accept" + IngressClientCertificateModeIgnore IngressClientCertificateMode = "ignore" + IngressClientCertificateModeRequire IngressClientCertificateMode = "require" +) + +func PossibleValuesForIngressClientCertificateMode() []string { + return []string{ + string(IngressClientCertificateModeAccept), + string(IngressClientCertificateModeIgnore), + string(IngressClientCertificateModeRequire), + } +} + +func (s *IngressClientCertificateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIngressClientCertificateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIngressClientCertificateMode(input string) (*IngressClientCertificateMode, error) { + vals := map[string]IngressClientCertificateMode{ + "accept": IngressClientCertificateModeAccept, + "ignore": IngressClientCertificateModeIgnore, + "require": IngressClientCertificateModeRequire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IngressClientCertificateMode(input) + return &out, nil +} + +type IngressTransportMethod string + +const ( + IngressTransportMethodAuto IngressTransportMethod = "auto" + IngressTransportMethodHTTP IngressTransportMethod = "http" + IngressTransportMethodHTTPTwo IngressTransportMethod = "http2" + IngressTransportMethodTcp IngressTransportMethod = "tcp" +) + +func PossibleValuesForIngressTransportMethod() []string { + return []string{ + string(IngressTransportMethodAuto), + string(IngressTransportMethodHTTP), + string(IngressTransportMethodHTTPTwo), + string(IngressTransportMethodTcp), + } +} + +func (s *IngressTransportMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIngressTransportMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIngressTransportMethod(input string) (*IngressTransportMethod, error) { + vals := map[string]IngressTransportMethod{ + "auto": IngressTransportMethodAuto, + "http": IngressTransportMethodHTTP, + "http2": IngressTransportMethodHTTPTwo, + "tcp": IngressTransportMethodTcp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IngressTransportMethod(input) + return &out, nil +} + +type JobProvisioningState string + +const ( + JobProvisioningStateCanceled JobProvisioningState = "Canceled" + JobProvisioningStateDeleting JobProvisioningState = "Deleting" + JobProvisioningStateFailed JobProvisioningState = "Failed" + JobProvisioningStateInProgress JobProvisioningState = "InProgress" + JobProvisioningStateSucceeded JobProvisioningState = "Succeeded" +) + +func PossibleValuesForJobProvisioningState() []string { + return []string{ + string(JobProvisioningStateCanceled), + string(JobProvisioningStateDeleting), + string(JobProvisioningStateFailed), + string(JobProvisioningStateInProgress), + string(JobProvisioningStateSucceeded), + } +} + +func (s *JobProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobProvisioningState(input string) (*JobProvisioningState, error) { + vals := map[string]JobProvisioningState{ + "canceled": JobProvisioningStateCanceled, + "deleting": JobProvisioningStateDeleting, + "failed": JobProvisioningStateFailed, + "inprogress": JobProvisioningStateInProgress, + "succeeded": JobProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobProvisioningState(input) + return &out, nil +} + +type LogLevel string + +const ( + LogLevelDebug LogLevel = "debug" + LogLevelError LogLevel = "error" + LogLevelInfo LogLevel = "info" + LogLevelWarn LogLevel = "warn" +) + +func PossibleValuesForLogLevel() []string { + return []string{ + string(LogLevelDebug), + string(LogLevelError), + string(LogLevelInfo), + string(LogLevelWarn), + } +} + +func (s *LogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogLevel(input string) (*LogLevel, error) { + vals := map[string]LogLevel{ + "debug": LogLevelDebug, + "error": LogLevelError, + "info": LogLevelInfo, + "warn": LogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogLevel(input) + return &out, nil +} + +type RevisionHealthState string + +const ( + RevisionHealthStateHealthy RevisionHealthState = "Healthy" + RevisionHealthStateNone RevisionHealthState = "None" + RevisionHealthStateUnhealthy RevisionHealthState = "Unhealthy" +) + +func PossibleValuesForRevisionHealthState() []string { + return []string{ + string(RevisionHealthStateHealthy), + string(RevisionHealthStateNone), + string(RevisionHealthStateUnhealthy), + } +} + +func (s *RevisionHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionHealthState(input string) (*RevisionHealthState, error) { + vals := map[string]RevisionHealthState{ + "healthy": RevisionHealthStateHealthy, + "none": RevisionHealthStateNone, + "unhealthy": RevisionHealthStateUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionHealthState(input) + return &out, nil +} + +type RevisionProvisioningState string + +const ( + RevisionProvisioningStateDeprovisioned RevisionProvisioningState = "Deprovisioned" + RevisionProvisioningStateDeprovisioning RevisionProvisioningState = "Deprovisioning" + RevisionProvisioningStateFailed RevisionProvisioningState = "Failed" + RevisionProvisioningStateProvisioned RevisionProvisioningState = "Provisioned" + RevisionProvisioningStateProvisioning RevisionProvisioningState = "Provisioning" +) + +func PossibleValuesForRevisionProvisioningState() []string { + return []string{ + string(RevisionProvisioningStateDeprovisioned), + string(RevisionProvisioningStateDeprovisioning), + string(RevisionProvisioningStateFailed), + string(RevisionProvisioningStateProvisioned), + string(RevisionProvisioningStateProvisioning), + } +} + +func (s *RevisionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionProvisioningState(input string) (*RevisionProvisioningState, error) { + vals := map[string]RevisionProvisioningState{ + "deprovisioned": RevisionProvisioningStateDeprovisioned, + "deprovisioning": RevisionProvisioningStateDeprovisioning, + "failed": RevisionProvisioningStateFailed, + "provisioned": RevisionProvisioningStateProvisioned, + "provisioning": RevisionProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionProvisioningState(input) + return &out, nil +} + +type RevisionRunningState string + +const ( + RevisionRunningStateDegraded RevisionRunningState = "Degraded" + RevisionRunningStateFailed RevisionRunningState = "Failed" + RevisionRunningStateProcessing RevisionRunningState = "Processing" + RevisionRunningStateRunning RevisionRunningState = "Running" + RevisionRunningStateStopped RevisionRunningState = "Stopped" + RevisionRunningStateUnknown RevisionRunningState = "Unknown" +) + +func PossibleValuesForRevisionRunningState() []string { + return []string{ + string(RevisionRunningStateDegraded), + string(RevisionRunningStateFailed), + string(RevisionRunningStateProcessing), + string(RevisionRunningStateRunning), + string(RevisionRunningStateStopped), + string(RevisionRunningStateUnknown), + } +} + +func (s *RevisionRunningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionRunningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionRunningState(input string) (*RevisionRunningState, error) { + vals := map[string]RevisionRunningState{ + "degraded": RevisionRunningStateDegraded, + "failed": RevisionRunningStateFailed, + "processing": RevisionRunningStateProcessing, + "running": RevisionRunningStateRunning, + "stopped": RevisionRunningStateStopped, + "unknown": RevisionRunningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionRunningState(input) + return &out, nil +} + +type Scheme string + +const ( + SchemeHTTP Scheme = "HTTP" + SchemeHTTPS Scheme = "HTTPS" +) + +func PossibleValuesForScheme() []string { + return []string{ + string(SchemeHTTP), + string(SchemeHTTPS), + } +} + +func (s *Scheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheme(input string) (*Scheme, error) { + vals := map[string]Scheme{ + "http": SchemeHTTP, + "https": SchemeHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Scheme(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeAzureFile StorageType = "AzureFile" + StorageTypeEmptyDir StorageType = "EmptyDir" + StorageTypeSecret StorageType = "Secret" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeAzureFile), + string(StorageTypeEmptyDir), + string(StorageTypeSecret), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "azurefile": StorageTypeAzureFile, + "emptydir": StorageTypeEmptyDir, + "secret": StorageTypeSecret, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type TriggerType string + +const ( + TriggerTypeEvent TriggerType = "Event" + TriggerTypeManual TriggerType = "Manual" + TriggerTypeSchedule TriggerType = "Schedule" +) + +func PossibleValuesForTriggerType() []string { + return []string{ + string(TriggerTypeEvent), + string(TriggerTypeManual), + string(TriggerTypeSchedule), + } +} + +func (s *TriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerType(input string) (*TriggerType, error) { + vals := map[string]TriggerType{ + "event": TriggerTypeEvent, + "manual": TriggerTypeManual, + "schedule": TriggerTypeSchedule, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerType(input) + return &out, nil +} + +type Type string + +const ( + TypeLiveness Type = "Liveness" + TypeReadiness Type = "Readiness" + TypeStartup Type = "Startup" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeLiveness), + string(TypeReadiness), + string(TypeStartup), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "liveness": TypeLiveness, + "readiness": TypeReadiness, + "startup": TypeStartup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp.go new file mode 100644 index 00000000000..b9b33f26301 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp.go @@ -0,0 +1,130 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppId{}) +} + +var _ resourceids.ResourceId = &ContainerAppId{} + +// ContainerAppId is a struct representing the Resource ID for a Container App +type ContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewContainerAppID returns a new ContainerAppId struct +func NewContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ContainerAppId { + return ContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseContainerAppID parses 'input' into a ContainerAppId +func ParseContainerAppID(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppIDInsensitively parses 'input' case-insensitively into a ContainerAppId +// note: this method should only be used for API response data and not user input +func ParseContainerAppIDInsensitively(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateContainerAppID checks that 'input' can be parsed as a Container App ID +func ValidateContainerAppID(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 := ParseContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App ID +func (id ContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App ID +func (id ContainerAppId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Container App ID +func (id ContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp_test.go new file mode 100644 index 00000000000..36dd936e80f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerapp_test.go @@ -0,0 +1,282 @@ +package diagnostics + +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 = &ContainerAppId{} + +func TestNewContainerAppID(t *testing.T) { + id := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatContainerAppID(t *testing.T) { + actual := NewContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForContainerAppId(t *testing.T) { + segments := ContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppId 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/containerapps/2024-03-01/diagnostics/id_containerappdetector.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerappdetector.go new file mode 100644 index 00000000000..52799321d3c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerappdetector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppDetectorId{}) +} + +var _ resourceids.ResourceId = &ContainerAppDetectorId{} + +// ContainerAppDetectorId is a struct representing the Resource ID for a Container App Detector +type ContainerAppDetectorId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + DetectorName string +} + +// NewContainerAppDetectorID returns a new ContainerAppDetectorId struct +func NewContainerAppDetectorID(subscriptionId string, resourceGroupName string, containerAppName string, detectorName string) ContainerAppDetectorId { + return ContainerAppDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + DetectorName: detectorName, + } +} + +// ParseContainerAppDetectorID parses 'input' into a ContainerAppDetectorId +func ParseContainerAppDetectorID(input string) (*ContainerAppDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppDetectorIDInsensitively parses 'input' case-insensitively into a ContainerAppDetectorId +// note: this method should only be used for API response data and not user input +func ParseContainerAppDetectorIDInsensitively(input string) (*ContainerAppDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppDetectorId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateContainerAppDetectorID checks that 'input' can be parsed as a Container App Detector ID +func ValidateContainerAppDetectorID(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 := ParseContainerAppDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App Detector ID +func (id ContainerAppDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App Detector ID +func (id ContainerAppDetectorId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Container App Detector ID +func (id ContainerAppDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Container App Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_containerappdetector_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerappdetector_test.go new file mode 100644 index 00000000000..96a8a315172 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_containerappdetector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &ContainerAppDetectorId{} + +func TestNewContainerAppDetectorID(t *testing.T) { + id := NewContainerAppDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "detectorValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatContainerAppDetectorID(t *testing.T) { + actual := NewContainerAppDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue", + Expected: &ContainerAppDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseContainerAppDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue", + Expected: &ContainerAppDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &ContainerAppDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForContainerAppDetectorId(t *testing.T) { + segments := ContainerAppDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppDetectorId 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/containerapps/2024-03-01/diagnostics/id_detector.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_detector.go new file mode 100644 index 00000000000..008e20f601e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_detector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DetectorId{}) +} + +var _ resourceids.ResourceId = &DetectorId{} + +// DetectorId is a struct representing the Resource ID for a Detector +type DetectorId struct { + SubscriptionId string + ResourceGroupName string + JobName string + DetectorName string +} + +// NewDetectorID returns a new DetectorId struct +func NewDetectorID(subscriptionId string, resourceGroupName string, jobName string, detectorName string) DetectorId { + return DetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + JobName: jobName, + DetectorName: detectorName, + } +} + +// ParseDetectorID parses 'input' into a DetectorId +func ParseDetectorID(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorIDInsensitively parses 'input' case-insensitively into a DetectorId +// note: this method should only be used for API response data and not user input +func ParseDetectorIDInsensitively(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorId) 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.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDetectorID checks that 'input' can be parsed as a Detector ID +func ValidateDetectorID(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 := ParseDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector ID +func (id DetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/jobs/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.JobName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector ID +func (id DetectorId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Detector ID +func (id DetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Job Name: %q", id.JobName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_detector_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_detector_test.go new file mode 100644 index 00000000000..f2b5c552384 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_detector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &DetectorId{} + +func TestNewDetectorID(t *testing.T) { + id := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorValue") + + 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.JobName != "jobValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatDetectorID(t *testing.T) { + actual := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRs/dEtEcToRvAlUe", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + JobName: "jObVaLuE", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.aPp/jObS/jObVaLuE/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDetectorId(t *testing.T) { + segments := DetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorId 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/containerapps/2024-03-01/diagnostics/id_detectorproperty.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_detectorproperty.go new file mode 100644 index 00000000000..b689ef62e1d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_detectorproperty.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DetectorPropertyId{}) +} + +var _ resourceids.ResourceId = &DetectorPropertyId{} + +// DetectorPropertyId is a struct representing the Resource ID for a Detector Property +type DetectorPropertyId struct { + SubscriptionId string + ResourceGroupName string + JobName string + DetectorPropertyName string +} + +// NewDetectorPropertyID returns a new DetectorPropertyId struct +func NewDetectorPropertyID(subscriptionId string, resourceGroupName string, jobName string, detectorPropertyName string) DetectorPropertyId { + return DetectorPropertyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + JobName: jobName, + DetectorPropertyName: detectorPropertyName, + } +} + +// ParseDetectorPropertyID parses 'input' into a DetectorPropertyId +func ParseDetectorPropertyID(input string) (*DetectorPropertyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorPropertyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorPropertyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorPropertyIDInsensitively parses 'input' case-insensitively into a DetectorPropertyId +// note: this method should only be used for API response data and not user input +func ParseDetectorPropertyIDInsensitively(input string) (*DetectorPropertyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorPropertyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorPropertyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorPropertyId) 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.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + if id.DetectorPropertyName, ok = input.Parsed["detectorPropertyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorPropertyName", input) + } + + return nil +} + +// ValidateDetectorPropertyID checks that 'input' can be parsed as a Detector Property ID +func ValidateDetectorPropertyID(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 := ParseDetectorPropertyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector Property ID +func (id DetectorPropertyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/jobs/%s/detectorProperties/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.JobName, id.DetectorPropertyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector Property ID +func (id DetectorPropertyId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobValue"), + resourceids.StaticSegment("staticDetectorProperties", "detectorProperties", "detectorProperties"), + resourceids.UserSpecifiedSegment("detectorPropertyName", "detectorPropertyValue"), + } +} + +// String returns a human-readable description of this Detector Property ID +func (id DetectorPropertyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Job Name: %q", id.JobName), + fmt.Sprintf("Detector Property Name: %q", id.DetectorPropertyName), + } + return fmt.Sprintf("Detector Property (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_detectorproperty_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_detectorproperty_test.go new file mode 100644 index 00000000000..1f7256e3fb0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_detectorproperty_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &DetectorPropertyId{} + +func TestNewDetectorPropertyID(t *testing.T) { + id := NewDetectorPropertyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorPropertyValue") + + 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.JobName != "jobValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobValue") + } + + if id.DetectorPropertyName != "detectorPropertyValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorPropertyName'", id.DetectorPropertyName, "detectorPropertyValue") + } +} + +func TestFormatDetectorPropertyID(t *testing.T) { + actual := NewDetectorPropertyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorPropertyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorPropertyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorPropertyId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue", + Expected: &DetectorPropertyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorPropertyName: "detectorPropertyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorPropertyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorPropertyName != v.Expected.DetectorPropertyName { + t.Fatalf("Expected %q but got %q for DetectorPropertyName", v.Expected.DetectorPropertyName, actual.DetectorPropertyName) + } + + } +} + +func TestParseDetectorPropertyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorPropertyId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRpRoPeRtIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue", + Expected: &DetectorPropertyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorPropertyName: "detectorPropertyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRpRoPeRtIeS/dEtEcToRpRoPeRtYvAlUe", + Expected: &DetectorPropertyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + JobName: "jObVaLuE", + DetectorPropertyName: "dEtEcToRpRoPeRtYvAlUe", + }, + }, + { + // 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.aPp/jObS/jObVaLuE/dEtEcToRpRoPeRtIeS/dEtEcToRpRoPeRtYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorPropertyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorPropertyName != v.Expected.DetectorPropertyName { + t.Fatalf("Expected %q but got %q for DetectorPropertyName", v.Expected.DetectorPropertyName, actual.DetectorPropertyName) + } + + } +} + +func TestSegmentsForDetectorPropertyId(t *testing.T) { + segments := DetectorPropertyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorPropertyId 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/containerapps/2024-03-01/diagnostics/id_job.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_job.go new file mode 100644 index 00000000000..4e0a06fab0a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_job.go @@ -0,0 +1,130 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&JobId{}) +} + +var _ resourceids.ResourceId = &JobId{} + +// JobId is a struct representing the Resource ID for a Job +type JobId struct { + SubscriptionId string + ResourceGroupName string + JobName string +} + +// NewJobID returns a new JobId struct +func NewJobID(subscriptionId string, resourceGroupName string, jobName string) JobId { + return JobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + JobName: jobName, + } +} + +// ParseJobID parses 'input' into a JobId +func ParseJobID(input string) (*JobId, error) { + parser := resourceids.NewParserFromResourceIdType(&JobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := JobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseJobIDInsensitively parses 'input' case-insensitively into a JobId +// note: this method should only be used for API response data and not user input +func ParseJobIDInsensitively(input string) (*JobId, error) { + parser := resourceids.NewParserFromResourceIdType(&JobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := JobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *JobId) 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.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + return nil +} + +// ValidateJobID checks that 'input' can be parsed as a Job ID +func ValidateJobID(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 := ParseJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Job ID +func (id JobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/jobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.JobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Job ID +func (id JobId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobValue"), + } +} + +// String returns a human-readable description of this Job ID +func (id JobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Job Name: %q", id.JobName), + } + return fmt.Sprintf("Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_job_test.go similarity index 72% rename from resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster_test.go rename to resource-manager/containerapps/2024-03-01/diagnostics/id_job_test.go index 7bb477197bc..b7c7d91e093 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster_test.go +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_job_test.go @@ -1,4 +1,4 @@ -package eventhubsclustersupgrade +package diagnostics import ( "testing" @@ -9,10 +9,10 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -var _ resourceids.ResourceId = &ClusterId{} +var _ resourceids.ResourceId = &JobId{} -func TestNewClusterID(t *testing.T) { - id := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue") +func TestNewJobID(t *testing.T) { + id := NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") 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") @@ -22,24 +22,24 @@ func TestNewClusterID(t *testing.T) { t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") } - if id.ClusterName != "clusterValue" { - t.Fatalf("Expected %q but got %q for Segment 'ClusterName'", id.ClusterName, "clusterValue") + if id.JobName != "jobValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobValue") } } -func TestFormatClusterID(t *testing.T) { - actual := NewClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "clusterValue").ID() - expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub/clusters/clusterValue" +func TestFormatJobID(t *testing.T) { + actual := NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue" if actual != expected { t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) } } -func TestParseClusterID(t *testing.T) { +func TestParseJobID(t *testing.T) { testData := []struct { Input string Error bool - Expected *ClusterId + Expected *JobId }{ { // Incomplete URI @@ -73,33 +73,33 @@ func TestParseClusterID(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub/clusters", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub/clusters/clusterValue", - Expected: &ClusterId{ + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Expected: &JobId{ SubscriptionId: "12345678-1234-9876-4563-123456789012", ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", + JobName: "jobValue", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub/clusters/clusterValue/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseClusterID(v.Input) + actual, err := ParseJobID(v.Input) if err != nil { if v.Error { continue @@ -119,18 +119,18 @@ func TestParseClusterID(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) } } } -func TestParseClusterIDInsensitively(t *testing.T) { +func TestParseJobIDInsensitively(t *testing.T) { testData := []struct { Input string Error bool - Expected *ClusterId + Expected *JobId }{ { // Incomplete URI @@ -189,57 +189,57 @@ func TestParseClusterIDInsensitively(t *testing.T) { }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.eVeNtHuB", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", Error: true, }, { // Incomplete URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub/clusters", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", Error: true, }, { // Incomplete URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.eVeNtHuB/cLuStErS", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS", Error: true, }, { // Valid URI - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub/clusters/clusterValue", - Expected: &ClusterId{ + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Expected: &JobId{ SubscriptionId: "12345678-1234-9876-4563-123456789012", ResourceGroupName: "example-resource-group", - ClusterName: "clusterValue", + JobName: "jobValue", }, }, { // Invalid (Valid Uri with Extra segment) - Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.EventHub/clusters/clusterValue/extra", + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/extra", Error: true, }, { // Valid URI (mIxEd CaSe since this is insensitive) - Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.eVeNtHuB/cLuStErS/cLuStErVaLuE", - Expected: &ClusterId{ + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE", + Expected: &JobId{ SubscriptionId: "12345678-1234-9876-4563-123456789012", ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", - ClusterName: "cLuStErVaLuE", + JobName: "jObVaLuE", }, }, { // 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.eVeNtHuB/cLuStErS/cLuStErVaLuE/extra", + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/extra", Error: true, }, } for _, v := range testData { t.Logf("[DEBUG] Testing %q", v.Input) - actual, err := ParseClusterIDInsensitively(v.Input) + actual, err := ParseJobIDInsensitively(v.Input) if err != nil { if v.Error { continue @@ -259,17 +259,17 @@ func TestParseClusterIDInsensitively(t *testing.T) { t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) } - if actual.ClusterName != v.Expected.ClusterName { - t.Fatalf("Expected %q but got %q for ClusterName", v.Expected.ClusterName, actual.ClusterName) + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) } } } -func TestSegmentsForClusterId(t *testing.T) { - segments := ClusterId{}.Segments() +func TestSegmentsForJobId(t *testing.T) { + segments := JobId{}.Segments() if len(segments) == 0 { - t.Fatalf("ClusterId has no segments") + t.Fatalf("JobId has no segments") } uniqueNames := make(map[string]struct{}, 0) diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment.go new file mode 100644 index 00000000000..7200a7fa7c3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment.go @@ -0,0 +1,130 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentId{} + +// ManagedEnvironmentId is a struct representing the Resource ID for a Managed Environment +type ManagedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string +} + +// NewManagedEnvironmentID returns a new ManagedEnvironmentId struct +func NewManagedEnvironmentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string) ManagedEnvironmentId { + return ManagedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + } +} + +// ParseManagedEnvironmentID parses 'input' into a ManagedEnvironmentId +func ParseManagedEnvironmentID(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentIDInsensitively(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + return nil +} + +// ValidateManagedEnvironmentID checks that 'input' can be parsed as a Managed Environment ID +func ValidateManagedEnvironmentID(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 := ParseManagedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment ID +func (id ManagedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment ID +func (id ManagedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Managed Environment ID +func (id ManagedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + } + return fmt.Sprintf("Managed Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment_test.go new file mode 100644 index 00000000000..0876c424ec3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironment_test.go @@ -0,0 +1,282 @@ +package diagnostics + +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 = &ManagedEnvironmentId{} + +func TestNewManagedEnvironmentID(t *testing.T) { + id := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } +} + +func TestFormatManagedEnvironmentID(t *testing.T) { + actual := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestParseManagedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestSegmentsForManagedEnvironmentId(t *testing.T) { + segments := ManagedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentId 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/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector.go new file mode 100644 index 00000000000..208ee9069b4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentDetectorId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentDetectorId{} + +// ManagedEnvironmentDetectorId is a struct representing the Resource ID for a Managed Environment Detector +type ManagedEnvironmentDetectorId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + DetectorName string +} + +// NewManagedEnvironmentDetectorID returns a new ManagedEnvironmentDetectorId struct +func NewManagedEnvironmentDetectorID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, detectorName string) ManagedEnvironmentDetectorId { + return ManagedEnvironmentDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + DetectorName: detectorName, + } +} + +// ParseManagedEnvironmentDetectorID parses 'input' into a ManagedEnvironmentDetectorId +func ParseManagedEnvironmentDetectorID(input string) (*ManagedEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentDetectorIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentDetectorId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentDetectorIDInsensitively(input string) (*ManagedEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentDetectorId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateManagedEnvironmentDetectorID checks that 'input' can be parsed as a Managed Environment Detector ID +func ValidateManagedEnvironmentDetectorID(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 := ParseManagedEnvironmentDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment Detector ID +func (id ManagedEnvironmentDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment Detector ID +func (id ManagedEnvironmentDetectorId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Managed Environment Detector ID +func (id ManagedEnvironmentDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Managed Environment Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector_test.go new file mode 100644 index 00000000000..0ee10233d13 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_managedenvironmentdetector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &ManagedEnvironmentDetectorId{} + +func TestNewManagedEnvironmentDetectorID(t *testing.T) { + id := NewManagedEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "detectorValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatManagedEnvironmentDetectorID(t *testing.T) { + actual := NewManagedEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue", + Expected: &ManagedEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseManagedEnvironmentDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue", + Expected: &ManagedEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &ManagedEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForManagedEnvironmentDetectorId(t *testing.T) { + segments := ManagedEnvironmentDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentDetectorId 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/containerapps/2024-03-01/diagnostics/id_revisionsapirevision.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_revisionsapirevision.go new file mode 100644 index 00000000000..24c29accc47 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_revisionsapirevision.go @@ -0,0 +1,141 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RevisionsApiRevisionId{}) +} + +var _ resourceids.ResourceId = &RevisionsApiRevisionId{} + +// RevisionsApiRevisionId is a struct representing the Resource ID for a Revisions Api Revision +type RevisionsApiRevisionId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + RevisionName string +} + +// NewRevisionsApiRevisionID returns a new RevisionsApiRevisionId struct +func NewRevisionsApiRevisionID(subscriptionId string, resourceGroupName string, containerAppName string, revisionName string) RevisionsApiRevisionId { + return RevisionsApiRevisionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + RevisionName: revisionName, + } +} + +// ParseRevisionsApiRevisionID parses 'input' into a RevisionsApiRevisionId +func ParseRevisionsApiRevisionID(input string) (*RevisionsApiRevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionsApiRevisionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionsApiRevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRevisionsApiRevisionIDInsensitively parses 'input' case-insensitively into a RevisionsApiRevisionId +// note: this method should only be used for API response data and not user input +func ParseRevisionsApiRevisionIDInsensitively(input string) (*RevisionsApiRevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionsApiRevisionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionsApiRevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RevisionsApiRevisionId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.RevisionName, ok = input.Parsed["revisionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "revisionName", input) + } + + return nil +} + +// ValidateRevisionsApiRevisionID checks that 'input' can be parsed as a Revisions Api Revision ID +func ValidateRevisionsApiRevisionID(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 := ParseRevisionsApiRevisionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Revisions Api Revision ID +func (id RevisionsApiRevisionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/containerApps/%s/detectorProperties/revisionsApi/revisions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.RevisionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Revisions Api Revision ID +func (id RevisionsApiRevisionId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticDetectorProperties", "detectorProperties", "detectorProperties"), + resourceids.StaticSegment("staticRevisionsApi", "revisionsApi", "revisionsApi"), + resourceids.StaticSegment("staticRevisions", "revisions", "revisions"), + resourceids.UserSpecifiedSegment("revisionName", "revisionValue"), + } +} + +// String returns a human-readable description of this Revisions Api Revision ID +func (id RevisionsApiRevisionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Revision Name: %q", id.RevisionName), + } + return fmt.Sprintf("Revisions Api Revision (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/id_revisionsapirevision_test.go b/resource-manager/containerapps/2024-03-01/diagnostics/id_revisionsapirevision_test.go new file mode 100644 index 00000000000..bf4233cdacb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/id_revisionsapirevision_test.go @@ -0,0 +1,357 @@ +package diagnostics + +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 = &RevisionsApiRevisionId{} + +func TestNewRevisionsApiRevisionID(t *testing.T) { + id := NewRevisionsApiRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.RevisionName != "revisionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RevisionName'", id.RevisionName, "revisionValue") + } +} + +func TestFormatRevisionsApiRevisionID(t *testing.T) { + actual := NewRevisionsApiRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRevisionsApiRevisionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionsApiRevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue", + Expected: &RevisionsApiRevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionsApiRevisionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestParseRevisionsApiRevisionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionsApiRevisionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI/rEvIsIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue", + Expected: &RevisionsApiRevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/containerApps/containerAppValue/detectorProperties/revisionsApi/revisions/revisionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI/rEvIsIoNs/rEvIsIoNvAlUe", + Expected: &RevisionsApiRevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + RevisionName: "rEvIsIoNvAlUe", + }, + }, + { + // 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.aPp/cOnTaInErApPs/cOnTaInErApPvAlUe/dEtEcToRpRoPeRtIeS/rEvIsIoNsApI/rEvIsIoNs/rEvIsIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionsApiRevisionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestSegmentsForRevisionsApiRevisionId(t *testing.T) { + segments := RevisionsApiRevisionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RevisionsApiRevisionId 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/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetdetector.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetdetector.go new file mode 100644 index 00000000000..536d079858a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetdetector.go @@ -0,0 +1,54 @@ +package diagnostics + +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 ContainerAppsDiagnosticsGetDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Diagnostics +} + +// ContainerAppsDiagnosticsGetDetector ... +func (c DiagnosticsClient) ContainerAppsDiagnosticsGetDetector(ctx context.Context, id ContainerAppDetectorId) (result ContainerAppsDiagnosticsGetDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Diagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetrevision.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetrevision.go new file mode 100644 index 00000000000..6a28b8c8b69 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetrevision.go @@ -0,0 +1,54 @@ +package diagnostics + +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 ContainerAppsDiagnosticsGetRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Revision +} + +// ContainerAppsDiagnosticsGetRevision ... +func (c DiagnosticsClient) ContainerAppsDiagnosticsGetRevision(ctx context.Context, id RevisionsApiRevisionId) (result ContainerAppsDiagnosticsGetRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Revision + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetroot.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetroot.go new file mode 100644 index 00000000000..f19f93687e7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticsgetroot.go @@ -0,0 +1,55 @@ +package diagnostics + +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 ContainerAppsDiagnosticsGetRootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContainerApp +} + +// ContainerAppsDiagnosticsGetRoot ... +func (c DiagnosticsClient) ContainerAppsDiagnosticsGetRoot(ctx context.Context, id ContainerAppId) (result ContainerAppsDiagnosticsGetRootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectorProperties/rootApi", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContainerApp + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistdetectors.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistdetectors.go new file mode 100644 index 00000000000..7d5183b8f7c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistdetectors.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ContainerAppsDiagnosticsListDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Diagnostics +} + +type ContainerAppsDiagnosticsListDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Diagnostics +} + +// ContainerAppsDiagnosticsListDetectors ... +func (c DiagnosticsClient) ContainerAppsDiagnosticsListDetectors(ctx context.Context, id ContainerAppId) (result ContainerAppsDiagnosticsListDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]Diagnostics `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ContainerAppsDiagnosticsListDetectorsComplete retrieves all the results into a single object +func (c DiagnosticsClient) ContainerAppsDiagnosticsListDetectorsComplete(ctx context.Context, id ContainerAppId) (ContainerAppsDiagnosticsListDetectorsCompleteResult, error) { + return c.ContainerAppsDiagnosticsListDetectorsCompleteMatchingPredicate(ctx, id, DiagnosticsOperationPredicate{}) +} + +// ContainerAppsDiagnosticsListDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ContainerAppsDiagnosticsListDetectorsCompleteMatchingPredicate(ctx context.Context, id ContainerAppId, predicate DiagnosticsOperationPredicate) (result ContainerAppsDiagnosticsListDetectorsCompleteResult, err error) { + items := make([]Diagnostics, 0) + + resp, err := c.ContainerAppsDiagnosticsListDetectors(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 = ContainerAppsDiagnosticsListDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistrevisions.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistrevisions.go new file mode 100644 index 00000000000..0960f362210 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_containerappsdiagnosticslistrevisions.go @@ -0,0 +1,119 @@ +package diagnostics + +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 ContainerAppsDiagnosticsListRevisionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Revision +} + +type ContainerAppsDiagnosticsListRevisionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Revision +} + +type ContainerAppsDiagnosticsListRevisionsOperationOptions struct { + Filter *string +} + +func DefaultContainerAppsDiagnosticsListRevisionsOperationOptions() ContainerAppsDiagnosticsListRevisionsOperationOptions { + return ContainerAppsDiagnosticsListRevisionsOperationOptions{} +} + +func (o ContainerAppsDiagnosticsListRevisionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ContainerAppsDiagnosticsListRevisionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ContainerAppsDiagnosticsListRevisionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ContainerAppsDiagnosticsListRevisions ... +func (c DiagnosticsClient) ContainerAppsDiagnosticsListRevisions(ctx context.Context, id ContainerAppId, options ContainerAppsDiagnosticsListRevisionsOperationOptions) (result ContainerAppsDiagnosticsListRevisionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectorProperties/revisionsApi/revisions", 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 *[]Revision `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ContainerAppsDiagnosticsListRevisionsComplete retrieves all the results into a single object +func (c DiagnosticsClient) ContainerAppsDiagnosticsListRevisionsComplete(ctx context.Context, id ContainerAppId, options ContainerAppsDiagnosticsListRevisionsOperationOptions) (ContainerAppsDiagnosticsListRevisionsCompleteResult, error) { + return c.ContainerAppsDiagnosticsListRevisionsCompleteMatchingPredicate(ctx, id, options, RevisionOperationPredicate{}) +} + +// ContainerAppsDiagnosticsListRevisionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ContainerAppsDiagnosticsListRevisionsCompleteMatchingPredicate(ctx context.Context, id ContainerAppId, options ContainerAppsDiagnosticsListRevisionsOperationOptions, predicate RevisionOperationPredicate) (result ContainerAppsDiagnosticsListRevisionsCompleteResult, err error) { + items := make([]Revision, 0) + + resp, err := c.ContainerAppsDiagnosticsListRevisions(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 = ContainerAppsDiagnosticsListRevisionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_jobsgetdetector.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_jobsgetdetector.go new file mode 100644 index 00000000000..e368fa57e33 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_jobsgetdetector.go @@ -0,0 +1,54 @@ +package diagnostics + +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 JobsGetDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Diagnostics +} + +// JobsGetDetector ... +func (c DiagnosticsClient) JobsGetDetector(ctx context.Context, id DetectorId) (result JobsGetDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Diagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_jobslistdetectors.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_jobslistdetectors.go new file mode 100644 index 00000000000..1a80aba0cf2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_jobslistdetectors.go @@ -0,0 +1,91 @@ +package diagnostics + +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 JobsListDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Diagnostics +} + +type JobsListDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Diagnostics +} + +// JobsListDetectors ... +func (c DiagnosticsClient) JobsListDetectors(ctx context.Context, id JobId) (result JobsListDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]Diagnostics `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// JobsListDetectorsComplete retrieves all the results into a single object +func (c DiagnosticsClient) JobsListDetectorsComplete(ctx context.Context, id JobId) (JobsListDetectorsCompleteResult, error) { + return c.JobsListDetectorsCompleteMatchingPredicate(ctx, id, DiagnosticsOperationPredicate{}) +} + +// JobsListDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) JobsListDetectorsCompleteMatchingPredicate(ctx context.Context, id JobId, predicate DiagnosticsOperationPredicate) (result JobsListDetectorsCompleteResult, err error) { + items := make([]Diagnostics, 0) + + resp, err := c.JobsListDetectors(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 = JobsListDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_jobsproxyget.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_jobsproxyget.go new file mode 100644 index 00000000000..8195bd72b9d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_jobsproxyget.go @@ -0,0 +1,54 @@ +package diagnostics + +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 JobsProxyGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// JobsProxyGet ... +func (c DiagnosticsClient) JobsProxyGet(ctx context.Context, id DetectorPropertyId) (result JobsProxyGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Job + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticsgetdetector.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticsgetdetector.go new file mode 100644 index 00000000000..106b5ec9d4f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticsgetdetector.go @@ -0,0 +1,54 @@ +package diagnostics + +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 ManagedEnvironmentDiagnosticsGetDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Diagnostics +} + +// ManagedEnvironmentDiagnosticsGetDetector ... +func (c DiagnosticsClient) ManagedEnvironmentDiagnosticsGetDetector(ctx context.Context, id ManagedEnvironmentDetectorId) (result ManagedEnvironmentDiagnosticsGetDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Diagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticslistdetectors.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticslistdetectors.go new file mode 100644 index 00000000000..cb2cdb3abc3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentdiagnosticslistdetectors.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ManagedEnvironmentDiagnosticsListDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Diagnostics +} + +type ManagedEnvironmentDiagnosticsListDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Diagnostics +} + +// ManagedEnvironmentDiagnosticsListDetectors ... +func (c DiagnosticsClient) ManagedEnvironmentDiagnosticsListDetectors(ctx context.Context, id ManagedEnvironmentId) (result ManagedEnvironmentDiagnosticsListDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]Diagnostics `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagedEnvironmentDiagnosticsListDetectorsComplete retrieves all the results into a single object +func (c DiagnosticsClient) ManagedEnvironmentDiagnosticsListDetectorsComplete(ctx context.Context, id ManagedEnvironmentId) (ManagedEnvironmentDiagnosticsListDetectorsCompleteResult, error) { + return c.ManagedEnvironmentDiagnosticsListDetectorsCompleteMatchingPredicate(ctx, id, DiagnosticsOperationPredicate{}) +} + +// ManagedEnvironmentDiagnosticsListDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ManagedEnvironmentDiagnosticsListDetectorsCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate DiagnosticsOperationPredicate) (result ManagedEnvironmentDiagnosticsListDetectorsCompleteResult, err error) { + items := make([]Diagnostics, 0) + + resp, err := c.ManagedEnvironmentDiagnosticsListDetectors(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 = ManagedEnvironmentDiagnosticsListDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentsdiagnosticsgetroot.go b/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentsdiagnosticsgetroot.go new file mode 100644 index 00000000000..25fb922a48e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/method_managedenvironmentsdiagnosticsgetroot.go @@ -0,0 +1,55 @@ +package diagnostics + +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 ManagedEnvironmentsDiagnosticsGetRootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedEnvironment +} + +// ManagedEnvironmentsDiagnosticsGetRoot ... +func (c DiagnosticsClient) ManagedEnvironmentsDiagnosticsGetRoot(ctx context.Context, id ManagedEnvironmentId) (result ManagedEnvironmentsDiagnosticsGetRootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectorProperties/rootApi", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedEnvironment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_applogsconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_applogsconfiguration.go new file mode 100644 index 00000000000..90fe9ced93f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_applogsconfiguration.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppLogsConfiguration struct { + Destination *string `json:"destination,omitempty"` + LogAnalyticsConfiguration *LogAnalyticsConfiguration `json:"logAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_basecontainer.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_basecontainer.go new file mode 100644 index 00000000000..bf26a0fd70f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_basecontainer.go @@ -0,0 +1,14 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseContainer struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_configuration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_configuration.go new file mode 100644 index 00000000000..502c5d2371a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_configuration.go @@ -0,0 +1,14 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Configuration struct { + ActiveRevisionsMode *ActiveRevisionsMode `json:"activeRevisionsMode,omitempty"` + Dapr *Dapr `json:"dapr,omitempty"` + Ingress *Ingress `json:"ingress,omitempty"` + MaxInactiveRevisions *int64 `json:"maxInactiveRevisions,omitempty"` + Registries *[]RegistryCredentials `json:"registries,omitempty"` + Secrets *[]Secret `json:"secrets,omitempty"` + Service *Service `json:"service,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_container.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_container.go new file mode 100644 index 00000000000..7f3e49527c3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_container.go @@ -0,0 +1,15 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Probes *[]ContainerAppProbe `json:"probes,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_containerapp.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerapp.go new file mode 100644 index 00000000000..85fafde1e7c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerapp.go @@ -0,0 +1,22 @@ +package diagnostics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerApp struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + ManagedBy *string `json:"managedBy,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContainerAppProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobe.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobe.go new file mode 100644 index 00000000000..062f3583dc5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobe.go @@ -0,0 +1,16 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbe struct { + FailureThreshold *int64 `json:"failureThreshold,omitempty"` + HTTPGet *ContainerAppProbeHTTPGet `json:"httpGet,omitempty"` + InitialDelaySeconds *int64 `json:"initialDelaySeconds,omitempty"` + PeriodSeconds *int64 `json:"periodSeconds,omitempty"` + SuccessThreshold *int64 `json:"successThreshold,omitempty"` + TcpSocket *ContainerAppProbeTcpSocket `json:"tcpSocket,omitempty"` + TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpget.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpget.go new file mode 100644 index 00000000000..00fbe4d674c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpget.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGet struct { + HTTPHeaders *[]ContainerAppProbeHTTPGetHTTPHeadersInlined `json:"httpHeaders,omitempty"` + Host *string `json:"host,omitempty"` + Path *string `json:"path,omitempty"` + Port int64 `json:"port"` + Scheme *Scheme `json:"scheme,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpgethttpheadersinlined.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpgethttpheadersinlined.go new file mode 100644 index 00000000000..c2be2e96951 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobehttpgethttpheadersinlined.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGetHTTPHeadersInlined struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobetcpsocket.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobetcpsocket.go new file mode 100644 index 00000000000..0d96b8163d7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappprobetcpsocket.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeTcpSocket struct { + Host *string `json:"host,omitempty"` + Port int64 `json:"port"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappproperties.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappproperties.go new file mode 100644 index 00000000000..6f97ead8f1f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerappproperties.go @@ -0,0 +1,19 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProperties struct { + Configuration *Configuration `json:"configuration,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EventStreamEndpoint *string `json:"eventStreamEndpoint,omitempty"` + LatestReadyRevisionName *string `json:"latestReadyRevisionName,omitempty"` + LatestRevisionFqdn *string `json:"latestRevisionFqdn,omitempty"` + LatestRevisionName *string `json:"latestRevisionName,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + ProvisioningState *ContainerAppProvisioningState `json:"provisioningState,omitempty"` + Template *Template `json:"template,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_containerresources.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerresources.go new file mode 100644 index 00000000000..91f243cb51b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_containerresources.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + EphemeralStorage *string `json:"ephemeralStorage,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_corspolicy.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_corspolicy.go new file mode 100644 index 00000000000..6fe8eb6bfb6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_corspolicy.go @@ -0,0 +1,13 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsPolicy struct { + AllowCredentials *bool `json:"allowCredentials,omitempty"` + AllowedHeaders *[]string `json:"allowedHeaders,omitempty"` + AllowedMethods *[]string `json:"allowedMethods,omitempty"` + AllowedOrigins []string `json:"allowedOrigins"` + ExposeHeaders *[]string `json:"exposeHeaders,omitempty"` + MaxAge *int64 `json:"maxAge,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_customdomain.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_customdomain.go new file mode 100644 index 00000000000..060f10bbf3c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_customdomain.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDomain struct { + BindingType *BindingType `json:"bindingType,omitempty"` + CertificateId *string `json:"certificateId,omitempty"` + Name string `json:"name"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_customdomainconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_customdomainconfiguration.go new file mode 100644 index 00000000000..2ff6a5561e4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_customdomainconfiguration.go @@ -0,0 +1,32 @@ +package diagnostics + +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 CustomDomainConfiguration struct { + CertificatePassword *string `json:"certificatePassword,omitempty"` + CertificateValue *string `json:"certificateValue,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} + +func (o *CustomDomainConfiguration) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CustomDomainConfiguration) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_customscalerule.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_customscalerule.go new file mode 100644 index 00000000000..2eea2f60332 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_customscalerule.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_dapr.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_dapr.go new file mode 100644 index 00000000000..665efbc4e83 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_dapr.go @@ -0,0 +1,15 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dapr struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + AppProtocol *AppProtocol `json:"appProtocol,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *LogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_daprconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_daprconfiguration.go new file mode 100644 index 00000000000..512609602f3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_daprconfiguration.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfiguration struct { + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadata.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadata.go new file mode 100644 index 00000000000..d585c441cf3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadata.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadata struct { + PropertyBag *[]DiagnosticDataProviderMetadataPropertyBagInlined `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadatapropertybaginlined.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadatapropertybaginlined.go new file mode 100644 index 00000000000..ba23db4513b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdataprovidermetadatapropertybaginlined.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadataPropertyBagInlined struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponsecolumn.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponsecolumn.go new file mode 100644 index 00000000000..0b9744e7c04 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponsecolumn.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponseobject.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponseobject.go new file mode 100644 index 00000000000..2da1abb2602 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticdatatableresponseobject.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseObject struct { + Columns *[]DiagnosticDataTableResponseColumn `json:"columns,omitempty"` + Rows *[]interface{} `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticrendering.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticrendering.go new file mode 100644 index 00000000000..16b1a2ff8c9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticrendering.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticRendering struct { + Description *string `json:"description,omitempty"` + IsVisible *bool `json:"isVisible,omitempty"` + Title *string `json:"title,omitempty"` + Type *int64 `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnostics.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnostics.go new file mode 100644 index 00000000000..ff162b54cf4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnostics.go @@ -0,0 +1,16 @@ +package diagnostics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Diagnostics struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticsProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdataapiresponse.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdataapiresponse.go new file mode 100644 index 00000000000..affb30b265b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdataapiresponse.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDataApiResponse struct { + RenderingProperties *DiagnosticRendering `json:"renderingProperties,omitempty"` + Table *DiagnosticDataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdefinition.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdefinition.go new file mode 100644 index 00000000000..aa89d010ac5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsdefinition.go @@ -0,0 +1,16 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDefinition struct { + AnalysisTypes *[]string `json:"analysisTypes,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]DiagnosticSupportTopic `json:"supportTopicList,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsproperties.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsproperties.go new file mode 100644 index 00000000000..c18b6dd9de3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsproperties.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsProperties struct { + DataProviderMetadata *DiagnosticDataProviderMetadata `json:"dataProviderMetadata,omitempty"` + Dataset *[]DiagnosticsDataApiResponse `json:"dataset,omitempty"` + Metadata *DiagnosticsDefinition `json:"metadata,omitempty"` + Status *DiagnosticsStatus `json:"status,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsstatus.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsstatus.go new file mode 100644 index 00000000000..4bfc6af51df --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsstatus.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsStatus struct { + Message *string `json:"message,omitempty"` + StatusId *int64 `json:"statusId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsupporttopic.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsupporttopic.go new file mode 100644 index 00000000000..111e1e400e6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_diagnosticsupporttopic.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticSupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_environmentvar.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_environmentvar.go new file mode 100644 index 00000000000..6c7d3dc6fb1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_environmentvar.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_extendedlocation.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_extendedlocation.go new file mode 100644 index 00000000000..bc440ede620 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_extendedlocation.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *ExtendedLocationTypes `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_httpscalerule.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_httpscalerule.go new file mode 100644 index 00000000000..7bab42bcc2a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_httpscalerule.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_ingress.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_ingress.go new file mode 100644 index 00000000000..2b4d8191903 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_ingress.go @@ -0,0 +1,20 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ingress struct { + AdditionalPortMappings *[]IngressPortMapping `json:"additionalPortMappings,omitempty"` + AllowInsecure *bool `json:"allowInsecure,omitempty"` + ClientCertificateMode *IngressClientCertificateMode `json:"clientCertificateMode,omitempty"` + CorsPolicy *CorsPolicy `json:"corsPolicy,omitempty"` + CustomDomains *[]CustomDomain `json:"customDomains,omitempty"` + ExposedPort *int64 `json:"exposedPort,omitempty"` + External *bool `json:"external,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestrictionRule `json:"ipSecurityRestrictions,omitempty"` + StickySessions *IngressStickySessions `json:"stickySessions,omitempty"` + TargetPort *int64 `json:"targetPort,omitempty"` + Traffic *[]TrafficWeight `json:"traffic,omitempty"` + Transport *IngressTransportMethod `json:"transport,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_ingressportmapping.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_ingressportmapping.go new file mode 100644 index 00000000000..1c9776d6599 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_ingressportmapping.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IngressPortMapping struct { + ExposedPort *int64 `json:"exposedPort,omitempty"` + External bool `json:"external"` + TargetPort int64 `json:"targetPort"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_ingressstickysessions.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_ingressstickysessions.go new file mode 100644 index 00000000000..19d1b114937 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_ingressstickysessions.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IngressStickySessions struct { + Affinity *Affinity `json:"affinity,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_ipsecurityrestrictionrule.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_ipsecurityrestrictionrule.go new file mode 100644 index 00000000000..5c8f316c3e8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_ipsecurityrestrictionrule.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestrictionRule struct { + Action Action `json:"action"` + Description *string `json:"description,omitempty"` + IPAddressRange string `json:"ipAddressRange"` + Name string `json:"name"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_job.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_job.go new file mode 100644 index 00000000000..74caa4c68a8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_job.go @@ -0,0 +1,20 @@ +package diagnostics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Job struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *JobProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfiguration.go new file mode 100644 index 00000000000..a492097c801 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfiguration.go @@ -0,0 +1,15 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfiguration struct { + EventTriggerConfig *JobConfigurationEventTriggerConfig `json:"eventTriggerConfig,omitempty"` + ManualTriggerConfig *JobConfigurationManualTriggerConfig `json:"manualTriggerConfig,omitempty"` + Registries *[]RegistryCredentials `json:"registries,omitempty"` + ReplicaRetryLimit *int64 `json:"replicaRetryLimit,omitempty"` + ReplicaTimeout int64 `json:"replicaTimeout"` + ScheduleTriggerConfig *JobConfigurationScheduleTriggerConfig `json:"scheduleTriggerConfig,omitempty"` + Secrets *[]Secret `json:"secrets,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationeventtriggerconfig.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationeventtriggerconfig.go new file mode 100644 index 00000000000..d75b822a94a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationeventtriggerconfig.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfigurationEventTriggerConfig struct { + Parallelism *int64 `json:"parallelism,omitempty"` + ReplicaCompletionCount *int64 `json:"replicaCompletionCount,omitempty"` + Scale *JobScale `json:"scale,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationmanualtriggerconfig.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationmanualtriggerconfig.go new file mode 100644 index 00000000000..5e693724e3a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationmanualtriggerconfig.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfigurationManualTriggerConfig struct { + Parallelism *int64 `json:"parallelism,omitempty"` + ReplicaCompletionCount *int64 `json:"replicaCompletionCount,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationscheduletriggerconfig.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationscheduletriggerconfig.go new file mode 100644 index 00000000000..76a14e5c7e7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobconfigurationscheduletriggerconfig.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfigurationScheduleTriggerConfig struct { + CronExpression string `json:"cronExpression"` + Parallelism *int64 `json:"parallelism,omitempty"` + ReplicaCompletionCount *int64 `json:"replicaCompletionCount,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobproperties.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobproperties.go new file mode 100644 index 00000000000..4fb941531a7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobproperties.go @@ -0,0 +1,14 @@ +package diagnostics + +// 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 { + Configuration *JobConfiguration `json:"configuration,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EventStreamEndpoint *string `json:"eventStreamEndpoint,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + ProvisioningState *JobProvisioningState `json:"provisioningState,omitempty"` + Template *JobTemplate `json:"template,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobscale.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobscale.go new file mode 100644 index 00000000000..63b856e7ad6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobscale.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobScale struct { + MaxExecutions *int64 `json:"maxExecutions,omitempty"` + MinExecutions *int64 `json:"minExecutions,omitempty"` + PollingInterval *int64 `json:"pollingInterval,omitempty"` + Rules *[]JobScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobscalerule.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobscalerule.go new file mode 100644 index 00000000000..bfb7b922e1a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobscalerule.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_jobtemplate.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobtemplate.go new file mode 100644 index 00000000000..9474be5f0d8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_jobtemplate.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobTemplate struct { + Containers *[]Container `json:"containers,omitempty"` + InitContainers *[]BaseContainer `json:"initContainers,omitempty"` + Volumes *[]Volume `json:"volumes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_kedaconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_kedaconfiguration.go new file mode 100644 index 00000000000..fd1cbc3ab25 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_kedaconfiguration.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KedaConfiguration struct { + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_loganalyticsconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_loganalyticsconfiguration.go new file mode 100644 index 00000000000..6b3d70a2547 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_loganalyticsconfiguration.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsConfiguration struct { + CustomerId *string `json:"customerId,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironment.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironment.go new file mode 100644 index 00000000000..169df789ec9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironment.go @@ -0,0 +1,19 @@ +package diagnostics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironment struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedEnvironmentProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentproperties.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentproperties.go new file mode 100644 index 00000000000..e6e11d7d44d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentproperties.go @@ -0,0 +1,24 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentProperties struct { + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + CustomDomainConfiguration *CustomDomainConfiguration `json:"customDomainConfiguration,omitempty"` + DaprAIConnectionString *string `json:"daprAIConnectionString,omitempty"` + DaprAIInstrumentationKey *string `json:"daprAIInstrumentationKey,omitempty"` + DaprConfiguration *DaprConfiguration `json:"daprConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + EventStreamEndpoint *string `json:"eventStreamEndpoint,omitempty"` + InfrastructureResourceGroup *string `json:"infrastructureResourceGroup,omitempty"` + KedaConfiguration *KedaConfiguration `json:"kedaConfiguration,omitempty"` + PeerAuthentication *ManagedEnvironmentPropertiesPeerAuthentication `json:"peerAuthentication,omitempty"` + PeerTrafficConfiguration *ManagedEnvironmentPropertiesPeerTrafficConfiguration `json:"peerTrafficConfiguration,omitempty"` + ProvisioningState *EnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` + VnetConfiguration *VnetConfiguration `json:"vnetConfiguration,omitempty"` + WorkloadProfiles *[]WorkloadProfile `json:"workloadProfiles,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeerauthentication.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeerauthentication.go new file mode 100644 index 00000000000..dfaf7fc5ee0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeerauthentication.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentPropertiesPeerAuthentication struct { + Mtls *Mtls `json:"mtls,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfiguration.go new file mode 100644 index 00000000000..4d3803b94a2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfiguration.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentPropertiesPeerTrafficConfiguration struct { + Encryption *ManagedEnvironmentPropertiesPeerTrafficConfigurationEncryption `json:"encryption,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go new file mode 100644 index 00000000000..b0f11534e0b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentPropertiesPeerTrafficConfigurationEncryption struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_mtls.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_mtls.go new file mode 100644 index 00000000000..4d08ea1e46f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_mtls.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Mtls struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_queuescalerule.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_queuescalerule.go new file mode 100644 index 00000000000..8635a739569 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_queuescalerule.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + QueueLength *int64 `json:"queueLength,omitempty"` + QueueName *string `json:"queueName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_registrycredentials.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_registrycredentials.go new file mode 100644 index 00000000000..8ea29de9709 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_registrycredentials.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCredentials struct { + Identity *string `json:"identity,omitempty"` + PasswordSecretRef *string `json:"passwordSecretRef,omitempty"` + Server *string `json:"server,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_revision.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_revision.go new file mode 100644 index 00000000000..c34756ce75b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_revision.go @@ -0,0 +1,16 @@ +package diagnostics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Revision struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RevisionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_revisionproperties.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_revisionproperties.go new file mode 100644 index 00000000000..2fe29894e02 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_revisionproperties.go @@ -0,0 +1,48 @@ +package diagnostics + +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 RevisionProperties struct { + Active *bool `json:"active,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + HealthState *RevisionHealthState `json:"healthState,omitempty"` + LastActiveTime *string `json:"lastActiveTime,omitempty"` + ProvisioningError *string `json:"provisioningError,omitempty"` + ProvisioningState *RevisionProvisioningState `json:"provisioningState,omitempty"` + Replicas *int64 `json:"replicas,omitempty"` + RunningState *RevisionRunningState `json:"runningState,omitempty"` + Template *Template `json:"template,omitempty"` + TrafficWeight *int64 `json:"trafficWeight,omitempty"` +} + +func (o *RevisionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *RevisionProperties) GetLastActiveTimeAsTime() (*time.Time, error) { + if o.LastActiveTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastActiveTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetLastActiveTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastActiveTime = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_scale.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_scale.go new file mode 100644 index 00000000000..52b9a5320ef --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_scale.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Scale struct { + MaxReplicas *int64 `json:"maxReplicas,omitempty"` + MinReplicas *int64 `json:"minReplicas,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_scalerule.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_scalerule.go new file mode 100644 index 00000000000..9155fee0b3d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_scalerule.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRule struct { + AzureQueue *QueueScaleRule `json:"azureQueue,omitempty"` + Custom *CustomScaleRule `json:"custom,omitempty"` + HTTP *HTTPScaleRule `json:"http,omitempty"` + Name *string `json:"name,omitempty"` + Tcp *TcpScaleRule `json:"tcp,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_scaleruleauth.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_scaleruleauth.go new file mode 100644 index 00000000000..6fb4bc302f7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_secret.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_secret.go new file mode 100644 index 00000000000..e14eebe103c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_secret.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Secret struct { + Identity *string `json:"identity,omitempty"` + KeyVaultUrl *string `json:"keyVaultUrl,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_secretvolumeitem.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_secretvolumeitem.go new file mode 100644 index 00000000000..ca25f4a1e5f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_secretvolumeitem.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretVolumeItem struct { + Path *string `json:"path,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_service.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_service.go new file mode 100644 index 00000000000..5ef6553aca5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_service.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Service struct { + Type string `json:"type"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_servicebind.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_servicebind.go new file mode 100644 index 00000000000..f04e0404c8a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_servicebind.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceBind struct { + Name *string `json:"name,omitempty"` + ServiceId *string `json:"serviceId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_tcpscalerule.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_tcpscalerule.go new file mode 100644 index 00000000000..6b24cd9682d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_tcpscalerule.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TcpScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_template.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_template.go new file mode 100644 index 00000000000..3208fd170a2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_template.go @@ -0,0 +1,14 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Template struct { + Containers *[]Container `json:"containers,omitempty"` + InitContainers *[]BaseContainer `json:"initContainers,omitempty"` + RevisionSuffix *string `json:"revisionSuffix,omitempty"` + Scale *Scale `json:"scale,omitempty"` + ServiceBinds *[]ServiceBind `json:"serviceBinds,omitempty"` + TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + Volumes *[]Volume `json:"volumes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_trafficweight.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_trafficweight.go new file mode 100644 index 00000000000..2472dfcfbcd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_trafficweight.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficWeight struct { + Label *string `json:"label,omitempty"` + LatestRevision *bool `json:"latestRevision,omitempty"` + RevisionName *string `json:"revisionName,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_vnetconfiguration.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_vnetconfiguration.go new file mode 100644 index 00000000000..40c7c67e702 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_vnetconfiguration.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetConfiguration struct { + DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"` + InfrastructureSubnetId *string `json:"infrastructureSubnetId,omitempty"` + Internal *bool `json:"internal,omitempty"` + PlatformReservedCidr *string `json:"platformReservedCidr,omitempty"` + PlatformReservedDnsIP *string `json:"platformReservedDnsIP,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_volume.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_volume.go new file mode 100644 index 00000000000..3ef596dfe70 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_volume.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Volume struct { + MountOptions *string `json:"mountOptions,omitempty"` + Name *string `json:"name,omitempty"` + Secrets *[]SecretVolumeItem `json:"secrets,omitempty"` + StorageName *string `json:"storageName,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_volumemount.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_volumemount.go new file mode 100644 index 00000000000..7c3a7d2aa8c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_volumemount.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeMount struct { + MountPath *string `json:"mountPath,omitempty"` + SubPath *string `json:"subPath,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/model_workloadprofile.go b/resource-manager/containerapps/2024-03-01/diagnostics/model_workloadprofile.go new file mode 100644 index 00000000000..88283d198f1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/model_workloadprofile.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProfile struct { + MaximumCount *int64 `json:"maximumCount,omitempty"` + MinimumCount *int64 `json:"minimumCount,omitempty"` + Name string `json:"name"` + WorkloadProfileType string `json:"workloadProfileType"` +} diff --git a/resource-manager/containerapps/2024-03-01/diagnostics/predicates.go b/resource-manager/containerapps/2024-03-01/diagnostics/predicates.go new file mode 100644 index 00000000000..f8895351db6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/predicates.go @@ -0,0 +1,50 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DiagnosticsOperationPredicate) Matches(input Diagnostics) 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 +} + +type RevisionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RevisionOperationPredicate) Matches(input Revision) 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/containerapps/2024-03-01/diagnostics/version.go b/resource-manager/containerapps/2024-03-01/diagnostics/version.go new file mode 100644 index 00000000000..e5d57d40934 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/diagnostics/version.go @@ -0,0 +1,12 @@ +package diagnostics + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/diagnostics/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/README.md b/resource-manager/containerapps/2024-03-01/jobs/README.md new file mode 100644 index 00000000000..f9cdbcd2e47 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/README.md @@ -0,0 +1,261 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/jobs` Documentation + +The `jobs` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/jobs" +``` + + +### Client Initialization + +```go +client := jobs.NewJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `JobsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +payload := jobs.Job{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `JobsClient.Delete` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `JobsClient.ExecutionsList` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +// alternatively `client.ExecutionsList(ctx, id, jobs.DefaultExecutionsListOperationOptions())` can be used to do batched pagination +items, err := client.ExecutionsListComplete(ctx, id, jobs.DefaultExecutionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `JobsClient.Get` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +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: `JobsClient.GetDetector` + +```go +ctx := context.TODO() +id := jobs.NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorValue") + +read, err := client.GetDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `JobsClient.JobExecution` + +```go +ctx := context.TODO() +id := jobs.NewExecutionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "executionValue") + +read, err := client.JobExecution(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `JobsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `JobsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `JobsClient.ListDetectors` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +// alternatively `client.ListDetectors(ctx, id)` can be used to do batched pagination +items, err := client.ListDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `JobsClient.ListSecrets` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +read, err := client.ListSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `JobsClient.ProxyGet` + +```go +ctx := context.TODO() +id := jobs.NewDetectorPropertyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorPropertyValue") + +read, err := client.ProxyGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `JobsClient.Start` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +payload := jobs.JobExecutionTemplate{ + // ... +} + + +if err := client.StartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `JobsClient.StopExecution` + +```go +ctx := context.TODO() +id := jobs.NewExecutionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "executionValue") + +if err := client.StopExecutionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `JobsClient.StopMultipleExecutions` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +// alternatively `client.StopMultipleExecutions(ctx, id)` can be used to do batched pagination +items, err := client.StopMultipleExecutionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `JobsClient.Update` + +```go +ctx := context.TODO() +id := jobs.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + +payload := jobs.JobPatchProperties{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/containerapps/2024-03-01/jobs/client.go b/resource-manager/containerapps/2024-03-01/jobs/client.go new file mode 100644 index 00000000000..f89b0c72db7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/client.go @@ -0,0 +1,26 @@ +package jobs + +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 JobsClient struct { + Client *resourcemanager.Client +} + +func NewJobsClientWithBaseURI(sdkApi sdkEnv.Api) (*JobsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "jobs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating JobsClient: %+v", err) + } + + return &JobsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/constants.go b/resource-manager/containerapps/2024-03-01/jobs/constants.go new file mode 100644 index 00000000000..43f7d395f52 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/constants.go @@ -0,0 +1,289 @@ +package jobs + +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 JobExecutionRunningState string + +const ( + JobExecutionRunningStateDegraded JobExecutionRunningState = "Degraded" + JobExecutionRunningStateFailed JobExecutionRunningState = "Failed" + JobExecutionRunningStateProcessing JobExecutionRunningState = "Processing" + JobExecutionRunningStateRunning JobExecutionRunningState = "Running" + JobExecutionRunningStateStopped JobExecutionRunningState = "Stopped" + JobExecutionRunningStateSucceeded JobExecutionRunningState = "Succeeded" + JobExecutionRunningStateUnknown JobExecutionRunningState = "Unknown" +) + +func PossibleValuesForJobExecutionRunningState() []string { + return []string{ + string(JobExecutionRunningStateDegraded), + string(JobExecutionRunningStateFailed), + string(JobExecutionRunningStateProcessing), + string(JobExecutionRunningStateRunning), + string(JobExecutionRunningStateStopped), + string(JobExecutionRunningStateSucceeded), + string(JobExecutionRunningStateUnknown), + } +} + +func (s *JobExecutionRunningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobExecutionRunningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobExecutionRunningState(input string) (*JobExecutionRunningState, error) { + vals := map[string]JobExecutionRunningState{ + "degraded": JobExecutionRunningStateDegraded, + "failed": JobExecutionRunningStateFailed, + "processing": JobExecutionRunningStateProcessing, + "running": JobExecutionRunningStateRunning, + "stopped": JobExecutionRunningStateStopped, + "succeeded": JobExecutionRunningStateSucceeded, + "unknown": JobExecutionRunningStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobExecutionRunningState(input) + return &out, nil +} + +type JobProvisioningState string + +const ( + JobProvisioningStateCanceled JobProvisioningState = "Canceled" + JobProvisioningStateDeleting JobProvisioningState = "Deleting" + JobProvisioningStateFailed JobProvisioningState = "Failed" + JobProvisioningStateInProgress JobProvisioningState = "InProgress" + JobProvisioningStateSucceeded JobProvisioningState = "Succeeded" +) + +func PossibleValuesForJobProvisioningState() []string { + return []string{ + string(JobProvisioningStateCanceled), + string(JobProvisioningStateDeleting), + string(JobProvisioningStateFailed), + string(JobProvisioningStateInProgress), + string(JobProvisioningStateSucceeded), + } +} + +func (s *JobProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobProvisioningState(input string) (*JobProvisioningState, error) { + vals := map[string]JobProvisioningState{ + "canceled": JobProvisioningStateCanceled, + "deleting": JobProvisioningStateDeleting, + "failed": JobProvisioningStateFailed, + "inprogress": JobProvisioningStateInProgress, + "succeeded": JobProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobProvisioningState(input) + return &out, nil +} + +type Scheme string + +const ( + SchemeHTTP Scheme = "HTTP" + SchemeHTTPS Scheme = "HTTPS" +) + +func PossibleValuesForScheme() []string { + return []string{ + string(SchemeHTTP), + string(SchemeHTTPS), + } +} + +func (s *Scheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheme(input string) (*Scheme, error) { + vals := map[string]Scheme{ + "http": SchemeHTTP, + "https": SchemeHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Scheme(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeAzureFile StorageType = "AzureFile" + StorageTypeEmptyDir StorageType = "EmptyDir" + StorageTypeSecret StorageType = "Secret" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeAzureFile), + string(StorageTypeEmptyDir), + string(StorageTypeSecret), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "azurefile": StorageTypeAzureFile, + "emptydir": StorageTypeEmptyDir, + "secret": StorageTypeSecret, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type TriggerType string + +const ( + TriggerTypeEvent TriggerType = "Event" + TriggerTypeManual TriggerType = "Manual" + TriggerTypeSchedule TriggerType = "Schedule" +) + +func PossibleValuesForTriggerType() []string { + return []string{ + string(TriggerTypeEvent), + string(TriggerTypeManual), + string(TriggerTypeSchedule), + } +} + +func (s *TriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerType(input string) (*TriggerType, error) { + vals := map[string]TriggerType{ + "event": TriggerTypeEvent, + "manual": TriggerTypeManual, + "schedule": TriggerTypeSchedule, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerType(input) + return &out, nil +} + +type Type string + +const ( + TypeLiveness Type = "Liveness" + TypeReadiness Type = "Readiness" + TypeStartup Type = "Startup" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeLiveness), + string(TypeReadiness), + string(TypeStartup), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "liveness": TypeLiveness, + "readiness": TypeReadiness, + "startup": TypeStartup, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/id_detector.go b/resource-manager/containerapps/2024-03-01/jobs/id_detector.go new file mode 100644 index 00000000000..778152219f6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_detector.go @@ -0,0 +1,139 @@ +package jobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DetectorId{}) +} + +var _ resourceids.ResourceId = &DetectorId{} + +// DetectorId is a struct representing the Resource ID for a Detector +type DetectorId struct { + SubscriptionId string + ResourceGroupName string + JobName string + DetectorName string +} + +// NewDetectorID returns a new DetectorId struct +func NewDetectorID(subscriptionId string, resourceGroupName string, jobName string, detectorName string) DetectorId { + return DetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + JobName: jobName, + DetectorName: detectorName, + } +} + +// ParseDetectorID parses 'input' into a DetectorId +func ParseDetectorID(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorIDInsensitively parses 'input' case-insensitively into a DetectorId +// note: this method should only be used for API response data and not user input +func ParseDetectorIDInsensitively(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorId) 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.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDetectorID checks that 'input' can be parsed as a Detector ID +func ValidateDetectorID(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 := ParseDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector ID +func (id DetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/jobs/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.JobName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector ID +func (id DetectorId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Detector ID +func (id DetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Job Name: %q", id.JobName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/id_detector_test.go b/resource-manager/containerapps/2024-03-01/jobs/id_detector_test.go new file mode 100644 index 00000000000..180a5696bfd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_detector_test.go @@ -0,0 +1,327 @@ +package jobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DetectorId{} + +func TestNewDetectorID(t *testing.T) { + id := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorValue") + + 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.JobName != "jobValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatDetectorID(t *testing.T) { + actual := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRs/dEtEcToRvAlUe", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + JobName: "jObVaLuE", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.aPp/jObS/jObVaLuE/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDetectorId(t *testing.T) { + segments := DetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorId 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/containerapps/2024-03-01/jobs/id_detectorproperty.go b/resource-manager/containerapps/2024-03-01/jobs/id_detectorproperty.go new file mode 100644 index 00000000000..b073bcafefc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_detectorproperty.go @@ -0,0 +1,139 @@ +package jobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DetectorPropertyId{}) +} + +var _ resourceids.ResourceId = &DetectorPropertyId{} + +// DetectorPropertyId is a struct representing the Resource ID for a Detector Property +type DetectorPropertyId struct { + SubscriptionId string + ResourceGroupName string + JobName string + DetectorPropertyName string +} + +// NewDetectorPropertyID returns a new DetectorPropertyId struct +func NewDetectorPropertyID(subscriptionId string, resourceGroupName string, jobName string, detectorPropertyName string) DetectorPropertyId { + return DetectorPropertyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + JobName: jobName, + DetectorPropertyName: detectorPropertyName, + } +} + +// ParseDetectorPropertyID parses 'input' into a DetectorPropertyId +func ParseDetectorPropertyID(input string) (*DetectorPropertyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorPropertyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorPropertyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorPropertyIDInsensitively parses 'input' case-insensitively into a DetectorPropertyId +// note: this method should only be used for API response data and not user input +func ParseDetectorPropertyIDInsensitively(input string) (*DetectorPropertyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorPropertyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorPropertyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorPropertyId) 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.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + if id.DetectorPropertyName, ok = input.Parsed["detectorPropertyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorPropertyName", input) + } + + return nil +} + +// ValidateDetectorPropertyID checks that 'input' can be parsed as a Detector Property ID +func ValidateDetectorPropertyID(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 := ParseDetectorPropertyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector Property ID +func (id DetectorPropertyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/jobs/%s/detectorProperties/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.JobName, id.DetectorPropertyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector Property ID +func (id DetectorPropertyId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobValue"), + resourceids.StaticSegment("staticDetectorProperties", "detectorProperties", "detectorProperties"), + resourceids.UserSpecifiedSegment("detectorPropertyName", "detectorPropertyValue"), + } +} + +// String returns a human-readable description of this Detector Property ID +func (id DetectorPropertyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Job Name: %q", id.JobName), + fmt.Sprintf("Detector Property Name: %q", id.DetectorPropertyName), + } + return fmt.Sprintf("Detector Property (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/id_detectorproperty_test.go b/resource-manager/containerapps/2024-03-01/jobs/id_detectorproperty_test.go new file mode 100644 index 00000000000..58f56b5cdeb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_detectorproperty_test.go @@ -0,0 +1,327 @@ +package jobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DetectorPropertyId{} + +func TestNewDetectorPropertyID(t *testing.T) { + id := NewDetectorPropertyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorPropertyValue") + + 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.JobName != "jobValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobValue") + } + + if id.DetectorPropertyName != "detectorPropertyValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorPropertyName'", id.DetectorPropertyName, "detectorPropertyValue") + } +} + +func TestFormatDetectorPropertyID(t *testing.T) { + actual := NewDetectorPropertyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "detectorPropertyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorPropertyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorPropertyId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue", + Expected: &DetectorPropertyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorPropertyName: "detectorPropertyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorPropertyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorPropertyName != v.Expected.DetectorPropertyName { + t.Fatalf("Expected %q but got %q for DetectorPropertyName", v.Expected.DetectorPropertyName, actual.DetectorPropertyName) + } + + } +} + +func TestParseDetectorPropertyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorPropertyId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRpRoPeRtIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue", + Expected: &DetectorPropertyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + DetectorPropertyName: "detectorPropertyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/detectorProperties/detectorPropertyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/dEtEcToRpRoPeRtIeS/dEtEcToRpRoPeRtYvAlUe", + Expected: &DetectorPropertyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + JobName: "jObVaLuE", + DetectorPropertyName: "dEtEcToRpRoPeRtYvAlUe", + }, + }, + { + // 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.aPp/jObS/jObVaLuE/dEtEcToRpRoPeRtIeS/dEtEcToRpRoPeRtYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorPropertyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.DetectorPropertyName != v.Expected.DetectorPropertyName { + t.Fatalf("Expected %q but got %q for DetectorPropertyName", v.Expected.DetectorPropertyName, actual.DetectorPropertyName) + } + + } +} + +func TestSegmentsForDetectorPropertyId(t *testing.T) { + segments := DetectorPropertyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorPropertyId 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/containerapps/2024-03-01/jobs/id_execution.go b/resource-manager/containerapps/2024-03-01/jobs/id_execution.go new file mode 100644 index 00000000000..252582285a7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_execution.go @@ -0,0 +1,139 @@ +package jobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExecutionId{}) +} + +var _ resourceids.ResourceId = &ExecutionId{} + +// ExecutionId is a struct representing the Resource ID for a Execution +type ExecutionId struct { + SubscriptionId string + ResourceGroupName string + JobName string + ExecutionName string +} + +// NewExecutionID returns a new ExecutionId struct +func NewExecutionID(subscriptionId string, resourceGroupName string, jobName string, executionName string) ExecutionId { + return ExecutionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + JobName: jobName, + ExecutionName: executionName, + } +} + +// ParseExecutionID parses 'input' into a ExecutionId +func ParseExecutionID(input string) (*ExecutionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExecutionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExecutionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExecutionIDInsensitively parses 'input' case-insensitively into a ExecutionId +// note: this method should only be used for API response data and not user input +func ParseExecutionIDInsensitively(input string) (*ExecutionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExecutionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExecutionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExecutionId) 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.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + if id.ExecutionName, ok = input.Parsed["executionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "executionName", input) + } + + return nil +} + +// ValidateExecutionID checks that 'input' can be parsed as a Execution ID +func ValidateExecutionID(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 := ParseExecutionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Execution ID +func (id ExecutionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/jobs/%s/executions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.JobName, id.ExecutionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Execution ID +func (id ExecutionId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobValue"), + resourceids.StaticSegment("staticExecutions", "executions", "executions"), + resourceids.UserSpecifiedSegment("executionName", "executionValue"), + } +} + +// String returns a human-readable description of this Execution ID +func (id ExecutionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Job Name: %q", id.JobName), + fmt.Sprintf("Execution Name: %q", id.ExecutionName), + } + return fmt.Sprintf("Execution (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/id_execution_test.go b/resource-manager/containerapps/2024-03-01/jobs/id_execution_test.go new file mode 100644 index 00000000000..43026a69aa4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_execution_test.go @@ -0,0 +1,327 @@ +package jobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExecutionId{} + +func TestNewExecutionID(t *testing.T) { + id := NewExecutionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "executionValue") + + 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.JobName != "jobValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobValue") + } + + if id.ExecutionName != "executionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ExecutionName'", id.ExecutionName, "executionValue") + } +} + +func TestFormatExecutionID(t *testing.T) { + actual := NewExecutionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue", "executionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/executions/executionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExecutionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExecutionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/executions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/executions/executionValue", + Expected: &ExecutionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + ExecutionName: "executionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/executions/executionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExecutionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.ExecutionName != v.Expected.ExecutionName { + t.Fatalf("Expected %q but got %q for ExecutionName", v.Expected.ExecutionName, actual.ExecutionName) + } + + } +} + +func TestParseExecutionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExecutionId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/executions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/eXeCuTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/executions/executionValue", + Expected: &ExecutionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + ExecutionName: "executionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/executions/executionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE/eXeCuTiOnS/eXeCuTiOnVaLuE", + Expected: &ExecutionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + JobName: "jObVaLuE", + ExecutionName: "eXeCuTiOnVaLuE", + }, + }, + { + // 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.aPp/jObS/jObVaLuE/eXeCuTiOnS/eXeCuTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExecutionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + if actual.ExecutionName != v.Expected.ExecutionName { + t.Fatalf("Expected %q but got %q for ExecutionName", v.Expected.ExecutionName, actual.ExecutionName) + } + + } +} + +func TestSegmentsForExecutionId(t *testing.T) { + segments := ExecutionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExecutionId 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/containerapps/2024-03-01/jobs/id_job.go b/resource-manager/containerapps/2024-03-01/jobs/id_job.go new file mode 100644 index 00000000000..818f9f6aa82 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_job.go @@ -0,0 +1,130 @@ +package jobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&JobId{}) +} + +var _ resourceids.ResourceId = &JobId{} + +// JobId is a struct representing the Resource ID for a Job +type JobId struct { + SubscriptionId string + ResourceGroupName string + JobName string +} + +// NewJobID returns a new JobId struct +func NewJobID(subscriptionId string, resourceGroupName string, jobName string) JobId { + return JobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + JobName: jobName, + } +} + +// ParseJobID parses 'input' into a JobId +func ParseJobID(input string) (*JobId, error) { + parser := resourceids.NewParserFromResourceIdType(&JobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := JobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseJobIDInsensitively parses 'input' case-insensitively into a JobId +// note: this method should only be used for API response data and not user input +func ParseJobIDInsensitively(input string) (*JobId, error) { + parser := resourceids.NewParserFromResourceIdType(&JobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := JobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *JobId) 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.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + return nil +} + +// ValidateJobID checks that 'input' can be parsed as a Job ID +func ValidateJobID(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 := ParseJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Job ID +func (id JobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/jobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.JobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Job ID +func (id JobId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobValue"), + } +} + +// String returns a human-readable description of this Job ID +func (id JobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Job Name: %q", id.JobName), + } + return fmt.Sprintf("Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/id_job_test.go b/resource-manager/containerapps/2024-03-01/jobs/id_job_test.go new file mode 100644 index 00000000000..b4a8d5749db --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/id_job_test.go @@ -0,0 +1,282 @@ +package jobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &JobId{} + +func TestNewJobID(t *testing.T) { + id := NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue") + + 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.JobName != "jobValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobValue") + } +} + +func TestFormatJobID(t *testing.T) { + actual := NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "jobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *JobId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Expected: &JobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + } +} + +func TestParseJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *JobId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue", + Expected: &JobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + JobName: "jobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/jobs/jobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/jObS/jObVaLuE", + Expected: &JobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + JobName: "jObVaLuE", + }, + }, + { + // 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.aPp/jObS/jObVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + } +} + +func TestSegmentsForJobId(t *testing.T) { + segments := JobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("JobId 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/containerapps/2024-03-01/jobs/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/jobs/method_createorupdate.go new file mode 100644 index 00000000000..ef6e9f361f5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_createorupdate.go @@ -0,0 +1,75 @@ +package jobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// CreateOrUpdate ... +func (c JobsClient) CreateOrUpdate(ctx context.Context, id JobId, input Job) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c JobsClient) CreateOrUpdateThenPoll(ctx context.Context, id JobId, input Job) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_delete.go b/resource-manager/containerapps/2024-03-01/jobs/method_delete.go new file mode 100644 index 00000000000..8523d87d6af --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_delete.go @@ -0,0 +1,71 @@ +package jobs + +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 JobsClient) Delete(ctx context.Context, id JobId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 JobsClient) DeleteThenPoll(ctx context.Context, id JobId) 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/containerapps/2024-03-01/jobs/method_executionslist.go b/resource-manager/containerapps/2024-03-01/jobs/method_executionslist.go new file mode 100644 index 00000000000..a22dbedda83 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_executionslist.go @@ -0,0 +1,119 @@ +package jobs + +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 ExecutionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]JobExecution +} + +type ExecutionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []JobExecution +} + +type ExecutionsListOperationOptions struct { + Filter *string +} + +func DefaultExecutionsListOperationOptions() ExecutionsListOperationOptions { + return ExecutionsListOperationOptions{} +} + +func (o ExecutionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecutionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecutionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ExecutionsList ... +func (c JobsClient) ExecutionsList(ctx context.Context, id JobId, options ExecutionsListOperationOptions) (result ExecutionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/executions", 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 *[]JobExecution `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ExecutionsListComplete retrieves all the results into a single object +func (c JobsClient) ExecutionsListComplete(ctx context.Context, id JobId, options ExecutionsListOperationOptions) (ExecutionsListCompleteResult, error) { + return c.ExecutionsListCompleteMatchingPredicate(ctx, id, options, JobExecutionOperationPredicate{}) +} + +// ExecutionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c JobsClient) ExecutionsListCompleteMatchingPredicate(ctx context.Context, id JobId, options ExecutionsListOperationOptions, predicate JobExecutionOperationPredicate) (result ExecutionsListCompleteResult, err error) { + items := make([]JobExecution, 0) + + resp, err := c.ExecutionsList(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 = ExecutionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_get.go b/resource-manager/containerapps/2024-03-01/jobs/method_get.go new file mode 100644 index 00000000000..3e21435af33 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_get.go @@ -0,0 +1,54 @@ +package jobs + +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 JobsClient) Get(ctx context.Context, id JobId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Job + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_getdetector.go b/resource-manager/containerapps/2024-03-01/jobs/method_getdetector.go new file mode 100644 index 00000000000..548f39c5369 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_getdetector.go @@ -0,0 +1,54 @@ +package jobs + +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 GetDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Diagnostics +} + +// GetDetector ... +func (c JobsClient) GetDetector(ctx context.Context, id DetectorId) (result GetDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Diagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_jobexecution.go b/resource-manager/containerapps/2024-03-01/jobs/method_jobexecution.go new file mode 100644 index 00000000000..910aedeff62 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_jobexecution.go @@ -0,0 +1,54 @@ +package jobs + +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 JobExecutionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JobExecution +} + +// JobExecution ... +func (c JobsClient) JobExecution(ctx context.Context, id ExecutionId) (result JobExecutionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model JobExecution + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_listbyresourcegroup.go b/resource-manager/containerapps/2024-03-01/jobs/method_listbyresourcegroup.go new file mode 100644 index 00000000000..b58439ead82 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package jobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Job +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Job +} + +// ListByResourceGroup ... +func (c JobsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/jobs", 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 *[]Job `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c JobsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, JobOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c JobsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate JobOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Job, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_listbysubscription.go b/resource-manager/containerapps/2024-03-01/jobs/method_listbysubscription.go new file mode 100644 index 00000000000..cb7c936e321 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_listbysubscription.go @@ -0,0 +1,92 @@ +package jobs + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Job +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Job +} + +// ListBySubscription ... +func (c JobsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/jobs", 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 *[]Job `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c JobsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, JobOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c JobsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate JobOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Job, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_listdetectors.go b/resource-manager/containerapps/2024-03-01/jobs/method_listdetectors.go new file mode 100644 index 00000000000..e8535fe2e43 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_listdetectors.go @@ -0,0 +1,91 @@ +package jobs + +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 ListDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Diagnostics +} + +type ListDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Diagnostics +} + +// ListDetectors ... +func (c JobsClient) ListDetectors(ctx context.Context, id JobId) (result ListDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]Diagnostics `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDetectorsComplete retrieves all the results into a single object +func (c JobsClient) ListDetectorsComplete(ctx context.Context, id JobId) (ListDetectorsCompleteResult, error) { + return c.ListDetectorsCompleteMatchingPredicate(ctx, id, DiagnosticsOperationPredicate{}) +} + +// ListDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c JobsClient) ListDetectorsCompleteMatchingPredicate(ctx context.Context, id JobId, predicate DiagnosticsOperationPredicate) (result ListDetectorsCompleteResult, err error) { + items := make([]Diagnostics, 0) + + resp, err := c.ListDetectors(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 = ListDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_listsecrets.go b/resource-manager/containerapps/2024-03-01/jobs/method_listsecrets.go new file mode 100644 index 00000000000..33fe668d3c9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_listsecrets.go @@ -0,0 +1,55 @@ +package jobs + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JobSecretsCollection +} + +// ListSecrets ... +func (c JobsClient) ListSecrets(ctx context.Context, id JobId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model JobSecretsCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_proxyget.go b/resource-manager/containerapps/2024-03-01/jobs/method_proxyget.go new file mode 100644 index 00000000000..ec53882d687 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_proxyget.go @@ -0,0 +1,54 @@ +package jobs + +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 ProxyGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Job +} + +// ProxyGet ... +func (c JobsClient) ProxyGet(ctx context.Context, id DetectorPropertyId) (result ProxyGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Job + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_start.go b/resource-manager/containerapps/2024-03-01/jobs/method_start.go new file mode 100644 index 00000000000..9be83c5ebf0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_start.go @@ -0,0 +1,75 @@ +package jobs + +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 StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *JobExecutionBase +} + +// Start ... +func (c JobsClient) Start(ctx context.Context, id JobId, input JobExecutionTemplate) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", 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 +} + +// StartThenPoll performs Start then polls until it's completed +func (c JobsClient) StartThenPoll(ctx context.Context, id JobId, input JobExecutionTemplate) error { + result, err := c.Start(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_stopexecution.go b/resource-manager/containerapps/2024-03-01/jobs/method_stopexecution.go new file mode 100644 index 00000000000..47c37cf69a7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_stopexecution.go @@ -0,0 +1,70 @@ +package jobs + +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 StopExecutionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StopExecution ... +func (c JobsClient) StopExecution(ctx context.Context, id ExecutionId) (result StopExecutionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 +} + +// StopExecutionThenPoll performs StopExecution then polls until it's completed +func (c JobsClient) StopExecutionThenPoll(ctx context.Context, id ExecutionId) error { + result, err := c.StopExecution(ctx, id) + if err != nil { + return fmt.Errorf("performing StopExecution: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopExecution: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_stopmultipleexecutions.go b/resource-manager/containerapps/2024-03-01/jobs/method_stopmultipleexecutions.go new file mode 100644 index 00000000000..8f8ea6da61b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_stopmultipleexecutions.go @@ -0,0 +1,76 @@ +package jobs + +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 StopMultipleExecutionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]JobExecution +} + +type StopMultipleExecutionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []JobExecution +} + +// StopMultipleExecutions ... +func (c JobsClient) StopMultipleExecutions(ctx context.Context, id JobId) (result StopMultipleExecutionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", 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 +} + +// StopMultipleExecutionsThenPoll performs StopMultipleExecutions then polls until it's completed +func (c JobsClient) StopMultipleExecutionsThenPoll(ctx context.Context, id JobId) error { + result, err := c.StopMultipleExecutions(ctx, id) + if err != nil { + return fmt.Errorf("performing StopMultipleExecutions: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopMultipleExecutions: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/method_update.go b/resource-manager/containerapps/2024-03-01/jobs/method_update.go new file mode 100644 index 00000000000..b88a194a95e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/method_update.go @@ -0,0 +1,75 @@ +package jobs + +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 *Job +} + +// Update ... +func (c JobsClient) Update(ctx context.Context, id JobId, input JobPatchProperties) (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 JobsClient) UpdateThenPoll(ctx context.Context, id JobId, input JobPatchProperties) 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/containerapps/2024-03-01/jobs/model_basecontainer.go b/resource-manager/containerapps/2024-03-01/jobs/model_basecontainer.go new file mode 100644 index 00000000000..e2472facf92 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_basecontainer.go @@ -0,0 +1,14 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseContainer struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_container.go b/resource-manager/containerapps/2024-03-01/jobs/model_container.go new file mode 100644 index 00000000000..803c30e898e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_container.go @@ -0,0 +1,15 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Probes *[]ContainerAppProbe `json:"probes,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobe.go b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobe.go new file mode 100644 index 00000000000..e89f40cc897 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobe.go @@ -0,0 +1,16 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbe struct { + FailureThreshold *int64 `json:"failureThreshold,omitempty"` + HTTPGet *ContainerAppProbeHTTPGet `json:"httpGet,omitempty"` + InitialDelaySeconds *int64 `json:"initialDelaySeconds,omitempty"` + PeriodSeconds *int64 `json:"periodSeconds,omitempty"` + SuccessThreshold *int64 `json:"successThreshold,omitempty"` + TcpSocket *ContainerAppProbeTcpSocket `json:"tcpSocket,omitempty"` + TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"` + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` + Type *Type `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpget.go b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpget.go new file mode 100644 index 00000000000..1ab675e4593 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpget.go @@ -0,0 +1,12 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGet struct { + HTTPHeaders *[]ContainerAppProbeHTTPGetHTTPHeadersInlined `json:"httpHeaders,omitempty"` + Host *string `json:"host,omitempty"` + Path *string `json:"path,omitempty"` + Port int64 `json:"port"` + Scheme *Scheme `json:"scheme,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpgethttpheadersinlined.go b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpgethttpheadersinlined.go new file mode 100644 index 00000000000..becc34945ce --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobehttpgethttpheadersinlined.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeHTTPGetHTTPHeadersInlined struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobetcpsocket.go b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobetcpsocket.go new file mode 100644 index 00000000000..e9e583e3982 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_containerappprobetcpsocket.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProbeTcpSocket struct { + Host *string `json:"host,omitempty"` + Port int64 `json:"port"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_containerresources.go b/resource-manager/containerapps/2024-03-01/jobs/model_containerresources.go new file mode 100644 index 00000000000..f48b9f76786 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_containerresources.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + EphemeralStorage *string `json:"ephemeralStorage,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadata.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadata.go new file mode 100644 index 00000000000..06c119bbae1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadata.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadata struct { + PropertyBag *[]DiagnosticDataProviderMetadataPropertyBagInlined `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadatapropertybaginlined.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadatapropertybaginlined.go new file mode 100644 index 00000000000..04a6fbcd52e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdataprovidermetadatapropertybaginlined.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadataPropertyBagInlined struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponsecolumn.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponsecolumn.go new file mode 100644 index 00000000000..a26027ca613 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponsecolumn.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponseobject.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponseobject.go new file mode 100644 index 00000000000..b69b892b9ed --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticdatatableresponseobject.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseObject struct { + Columns *[]DiagnosticDataTableResponseColumn `json:"columns,omitempty"` + Rows *[]interface{} `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticrendering.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticrendering.go new file mode 100644 index 00000000000..157c4b30835 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticrendering.go @@ -0,0 +1,11 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticRendering struct { + Description *string `json:"description,omitempty"` + IsVisible *bool `json:"isVisible,omitempty"` + Title *string `json:"title,omitempty"` + Type *int64 `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnostics.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnostics.go new file mode 100644 index 00000000000..7ae29be0ad6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnostics.go @@ -0,0 +1,16 @@ +package jobs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Diagnostics struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticsProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdataapiresponse.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdataapiresponse.go new file mode 100644 index 00000000000..57329a4aea3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdataapiresponse.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDataApiResponse struct { + RenderingProperties *DiagnosticRendering `json:"renderingProperties,omitempty"` + Table *DiagnosticDataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdefinition.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdefinition.go new file mode 100644 index 00000000000..9ffb303aaae --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsdefinition.go @@ -0,0 +1,16 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDefinition struct { + AnalysisTypes *[]string `json:"analysisTypes,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]DiagnosticSupportTopic `json:"supportTopicList,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsproperties.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsproperties.go new file mode 100644 index 00000000000..a6012a1a0dd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsproperties.go @@ -0,0 +1,11 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsProperties struct { + DataProviderMetadata *DiagnosticDataProviderMetadata `json:"dataProviderMetadata,omitempty"` + Dataset *[]DiagnosticsDataApiResponse `json:"dataset,omitempty"` + Metadata *DiagnosticsDefinition `json:"metadata,omitempty"` + Status *DiagnosticsStatus `json:"status,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsstatus.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsstatus.go new file mode 100644 index 00000000000..0ff1fe8b90c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsstatus.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsStatus struct { + Message *string `json:"message,omitempty"` + StatusId *int64 `json:"statusId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsupporttopic.go b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsupporttopic.go new file mode 100644 index 00000000000..a68cb40cb63 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_diagnosticsupporttopic.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticSupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_environmentvar.go b/resource-manager/containerapps/2024-03-01/jobs/model_environmentvar.go new file mode 100644 index 00000000000..ca2a887d4a4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_environmentvar.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_job.go b/resource-manager/containerapps/2024-03-01/jobs/model_job.go new file mode 100644 index 00000000000..ba41ac0c4a3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_job.go @@ -0,0 +1,20 @@ +package jobs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Job struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *JobProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobconfiguration.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfiguration.go new file mode 100644 index 00000000000..df524860dbb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfiguration.go @@ -0,0 +1,15 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfiguration struct { + EventTriggerConfig *JobConfigurationEventTriggerConfig `json:"eventTriggerConfig,omitempty"` + ManualTriggerConfig *JobConfigurationManualTriggerConfig `json:"manualTriggerConfig,omitempty"` + Registries *[]RegistryCredentials `json:"registries,omitempty"` + ReplicaRetryLimit *int64 `json:"replicaRetryLimit,omitempty"` + ReplicaTimeout int64 `json:"replicaTimeout"` + ScheduleTriggerConfig *JobConfigurationScheduleTriggerConfig `json:"scheduleTriggerConfig,omitempty"` + Secrets *[]Secret `json:"secrets,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationeventtriggerconfig.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationeventtriggerconfig.go new file mode 100644 index 00000000000..a50616ad9c4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationeventtriggerconfig.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfigurationEventTriggerConfig struct { + Parallelism *int64 `json:"parallelism,omitempty"` + ReplicaCompletionCount *int64 `json:"replicaCompletionCount,omitempty"` + Scale *JobScale `json:"scale,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationmanualtriggerconfig.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationmanualtriggerconfig.go new file mode 100644 index 00000000000..bb4bd29d5ac --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationmanualtriggerconfig.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfigurationManualTriggerConfig struct { + Parallelism *int64 `json:"parallelism,omitempty"` + ReplicaCompletionCount *int64 `json:"replicaCompletionCount,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationscheduletriggerconfig.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationscheduletriggerconfig.go new file mode 100644 index 00000000000..6e82bdb6621 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobconfigurationscheduletriggerconfig.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobConfigurationScheduleTriggerConfig struct { + CronExpression string `json:"cronExpression"` + Parallelism *int64 `json:"parallelism,omitempty"` + ReplicaCompletionCount *int64 `json:"replicaCompletionCount,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobexecution.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecution.go new file mode 100644 index 00000000000..04a28d5b095 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecution.go @@ -0,0 +1,11 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobExecution struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *JobExecutionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionbase.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionbase.go new file mode 100644 index 00000000000..b6bf9e5b55b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionbase.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobExecutionBase struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutioncontainer.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutioncontainer.go new file mode 100644 index 00000000000..709af1fd836 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutioncontainer.go @@ -0,0 +1,13 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobExecutionContainer struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionproperties.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionproperties.go new file mode 100644 index 00000000000..2587bfd7515 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutionproperties.go @@ -0,0 +1,41 @@ +package jobs + +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 JobExecutionProperties struct { + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *JobExecutionRunningState `json:"status,omitempty"` + Template *JobExecutionTemplate `json:"template,omitempty"` +} + +func (o *JobExecutionProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobExecutionProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *JobExecutionProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *JobExecutionProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutiontemplate.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutiontemplate.go new file mode 100644 index 00000000000..b7f77c77693 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobexecutiontemplate.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobExecutionTemplate struct { + Containers *[]JobExecutionContainer `json:"containers,omitempty"` + InitContainers *[]JobExecutionContainer `json:"initContainers,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobpatchproperties.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobpatchproperties.go new file mode 100644 index 00000000000..38da76cd7f4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobpatchproperties.go @@ -0,0 +1,14 @@ +package jobs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobPatchProperties struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *JobPatchPropertiesProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobpatchpropertiesproperties.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobpatchpropertiesproperties.go new file mode 100644 index 00000000000..c1d2ed337c2 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobpatchpropertiesproperties.go @@ -0,0 +1,12 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobPatchPropertiesProperties struct { + Configuration *JobConfiguration `json:"configuration,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EventStreamEndpoint *string `json:"eventStreamEndpoint,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + Template *JobTemplate `json:"template,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobproperties.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobproperties.go new file mode 100644 index 00000000000..9865a06d79f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobproperties.go @@ -0,0 +1,14 @@ +package jobs + +// 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 { + Configuration *JobConfiguration `json:"configuration,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EventStreamEndpoint *string `json:"eventStreamEndpoint,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + ProvisioningState *JobProvisioningState `json:"provisioningState,omitempty"` + Template *JobTemplate `json:"template,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobscale.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobscale.go new file mode 100644 index 00000000000..c13b18eea1b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobscale.go @@ -0,0 +1,11 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobScale struct { + MaxExecutions *int64 `json:"maxExecutions,omitempty"` + MinExecutions *int64 `json:"minExecutions,omitempty"` + PollingInterval *int64 `json:"pollingInterval,omitempty"` + Rules *[]JobScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobscalerule.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobscalerule.go new file mode 100644 index 00000000000..31ed52a2cfd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobscalerule.go @@ -0,0 +1,11 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobsecretscollection.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobsecretscollection.go new file mode 100644 index 00000000000..9844058eda6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobsecretscollection.go @@ -0,0 +1,8 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobSecretsCollection struct { + Value []Secret `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_jobtemplate.go b/resource-manager/containerapps/2024-03-01/jobs/model_jobtemplate.go new file mode 100644 index 00000000000..6e9bce871a9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_jobtemplate.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobTemplate struct { + Containers *[]Container `json:"containers,omitempty"` + InitContainers *[]BaseContainer `json:"initContainers,omitempty"` + Volumes *[]Volume `json:"volumes,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_registrycredentials.go b/resource-manager/containerapps/2024-03-01/jobs/model_registrycredentials.go new file mode 100644 index 00000000000..c82f4c12456 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_registrycredentials.go @@ -0,0 +1,11 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCredentials struct { + Identity *string `json:"identity,omitempty"` + PasswordSecretRef *string `json:"passwordSecretRef,omitempty"` + Server *string `json:"server,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_scaleruleauth.go b/resource-manager/containerapps/2024-03-01/jobs/model_scaleruleauth.go new file mode 100644 index 00000000000..92b41db202a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_secret.go b/resource-manager/containerapps/2024-03-01/jobs/model_secret.go new file mode 100644 index 00000000000..8aee0a491c3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_secret.go @@ -0,0 +1,11 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Secret struct { + Identity *string `json:"identity,omitempty"` + KeyVaultUrl *string `json:"keyVaultUrl,omitempty"` + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_secretvolumeitem.go b/resource-manager/containerapps/2024-03-01/jobs/model_secretvolumeitem.go new file mode 100644 index 00000000000..bfa219692a9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_secretvolumeitem.go @@ -0,0 +1,9 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretVolumeItem struct { + Path *string `json:"path,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_volume.go b/resource-manager/containerapps/2024-03-01/jobs/model_volume.go new file mode 100644 index 00000000000..4414f8230a1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_volume.go @@ -0,0 +1,12 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Volume struct { + MountOptions *string `json:"mountOptions,omitempty"` + Name *string `json:"name,omitempty"` + Secrets *[]SecretVolumeItem `json:"secrets,omitempty"` + StorageName *string `json:"storageName,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/model_volumemount.go b/resource-manager/containerapps/2024-03-01/jobs/model_volumemount.go new file mode 100644 index 00000000000..2274bfc6b08 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/model_volumemount.go @@ -0,0 +1,10 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeMount struct { + MountPath *string `json:"mountPath,omitempty"` + SubPath *string `json:"subPath,omitempty"` + VolumeName *string `json:"volumeName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/jobs/predicates.go b/resource-manager/containerapps/2024-03-01/jobs/predicates.go new file mode 100644 index 00000000000..d558cc7f436 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/predicates.go @@ -0,0 +1,78 @@ +package jobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DiagnosticsOperationPredicate) Matches(input Diagnostics) 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 +} + +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 && *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 +} + +type JobExecutionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p JobExecutionOperationPredicate) Matches(input JobExecution) 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/containerapps/2024-03-01/jobs/version.go b/resource-manager/containerapps/2024-03-01/jobs/version.go new file mode 100644 index 00000000000..76827f0e322 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/jobs/version.go @@ -0,0 +1,12 @@ +package jobs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/jobs/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/README.md b/resource-manager/containerapps/2024-03-01/managedcertificates/README.md new file mode 100644 index 00000000000..1b4cc768fd9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/managedcertificates` Documentation + +The `managedcertificates` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/managedcertificates" +``` + + +### Client Initialization + +```go +client := managedcertificates.NewManagedCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedCertificatesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := managedcertificates.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +payload := managedcertificates.ManagedCertificate{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedCertificatesClient.Delete` + +```go +ctx := context.TODO() +id := managedcertificates.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedCertificatesClient.Get` + +```go +ctx := context.TODO() +id := managedcertificates.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +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: `ManagedCertificatesClient.List` + +```go +ctx := context.TODO() +id := managedcertificates.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// 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: `ManagedCertificatesClient.Update` + +```go +ctx := context.TODO() +id := managedcertificates.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +payload := managedcertificates.ManagedCertificatePatch{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/client.go b/resource-manager/containerapps/2024-03-01/managedcertificates/client.go new file mode 100644 index 00000000000..4d48850b531 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/client.go @@ -0,0 +1,26 @@ +package managedcertificates + +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 ManagedCertificatesClient struct { + Client *resourcemanager.Client +} + +func NewManagedCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedCertificatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedcertificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedCertificatesClient: %+v", err) + } + + return &ManagedCertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/constants.go b/resource-manager/containerapps/2024-03-01/managedcertificates/constants.go new file mode 100644 index 00000000000..cf87213c665 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/constants.go @@ -0,0 +1,104 @@ +package managedcertificates + +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 CertificateProvisioningState string + +const ( + CertificateProvisioningStateCanceled CertificateProvisioningState = "Canceled" + CertificateProvisioningStateDeleteFailed CertificateProvisioningState = "DeleteFailed" + CertificateProvisioningStateFailed CertificateProvisioningState = "Failed" + CertificateProvisioningStatePending CertificateProvisioningState = "Pending" + CertificateProvisioningStateSucceeded CertificateProvisioningState = "Succeeded" +) + +func PossibleValuesForCertificateProvisioningState() []string { + return []string{ + string(CertificateProvisioningStateCanceled), + string(CertificateProvisioningStateDeleteFailed), + string(CertificateProvisioningStateFailed), + string(CertificateProvisioningStatePending), + string(CertificateProvisioningStateSucceeded), + } +} + +func (s *CertificateProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProvisioningState(input string) (*CertificateProvisioningState, error) { + vals := map[string]CertificateProvisioningState{ + "canceled": CertificateProvisioningStateCanceled, + "deletefailed": CertificateProvisioningStateDeleteFailed, + "failed": CertificateProvisioningStateFailed, + "pending": CertificateProvisioningStatePending, + "succeeded": CertificateProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProvisioningState(input) + return &out, nil +} + +type ManagedCertificateDomainControlValidation string + +const ( + ManagedCertificateDomainControlValidationCNAME ManagedCertificateDomainControlValidation = "CNAME" + ManagedCertificateDomainControlValidationHTTP ManagedCertificateDomainControlValidation = "HTTP" + ManagedCertificateDomainControlValidationTXT ManagedCertificateDomainControlValidation = "TXT" +) + +func PossibleValuesForManagedCertificateDomainControlValidation() []string { + return []string{ + string(ManagedCertificateDomainControlValidationCNAME), + string(ManagedCertificateDomainControlValidationHTTP), + string(ManagedCertificateDomainControlValidationTXT), + } +} + +func (s *ManagedCertificateDomainControlValidation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedCertificateDomainControlValidation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedCertificateDomainControlValidation(input string) (*ManagedCertificateDomainControlValidation, error) { + vals := map[string]ManagedCertificateDomainControlValidation{ + "cname": ManagedCertificateDomainControlValidationCNAME, + "http": ManagedCertificateDomainControlValidationHTTP, + "txt": ManagedCertificateDomainControlValidationTXT, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedCertificateDomainControlValidation(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate.go b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate.go new file mode 100644 index 00000000000..87752a47a9d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate.go @@ -0,0 +1,139 @@ +package managedcertificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedCertificateId{}) +} + +var _ resourceids.ResourceId = &ManagedCertificateId{} + +// ManagedCertificateId is a struct representing the Resource ID for a Managed Certificate +type ManagedCertificateId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + ManagedCertificateName string +} + +// NewManagedCertificateID returns a new ManagedCertificateId struct +func NewManagedCertificateID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, managedCertificateName string) ManagedCertificateId { + return ManagedCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + ManagedCertificateName: managedCertificateName, + } +} + +// ParseManagedCertificateID parses 'input' into a ManagedCertificateId +func ParseManagedCertificateID(input string) (*ManagedCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedCertificateIDInsensitively parses 'input' case-insensitively into a ManagedCertificateId +// note: this method should only be used for API response data and not user input +func ParseManagedCertificateIDInsensitively(input string) (*ManagedCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedCertificateId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.ManagedCertificateName, ok = input.Parsed["managedCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedCertificateName", input) + } + + return nil +} + +// ValidateManagedCertificateID checks that 'input' can be parsed as a Managed Certificate ID +func ValidateManagedCertificateID(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 := ParseManagedCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Certificate ID +func (id ManagedCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/managedCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.ManagedCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Certificate ID +func (id ManagedCertificateId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticManagedCertificates", "managedCertificates", "managedCertificates"), + resourceids.UserSpecifiedSegment("managedCertificateName", "managedCertificateValue"), + } +} + +// String returns a human-readable description of this Managed Certificate ID +func (id ManagedCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Managed Certificate Name: %q", id.ManagedCertificateName), + } + return fmt.Sprintf("Managed Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate_test.go b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate_test.go new file mode 100644 index 00000000000..4c248af8e6f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedcertificate_test.go @@ -0,0 +1,327 @@ +package managedcertificates + +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 = &ManagedCertificateId{} + +func TestNewManagedCertificateID(t *testing.T) { + id := NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.ManagedCertificateName != "managedCertificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedCertificateName'", id.ManagedCertificateName, "managedCertificateValue") + } +} + +func TestFormatManagedCertificateID(t *testing.T) { + actual := NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue", + Expected: &ManagedCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + ManagedCertificateName: "managedCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.ManagedCertificateName != v.Expected.ManagedCertificateName { + t.Fatalf("Expected %q but got %q for ManagedCertificateName", v.Expected.ManagedCertificateName, actual.ManagedCertificateName) + } + + } +} + +func TestParseManagedCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/mAnAgEdCeRtIfIcAtEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue", + Expected: &ManagedCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + ManagedCertificateName: "managedCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/mAnAgEdCeRtIfIcAtEs/mAnAgEdCeRtIfIcAtEvAlUe", + Expected: &ManagedCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + ManagedCertificateName: "mAnAgEdCeRtIfIcAtEvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/mAnAgEdCeRtIfIcAtEs/mAnAgEdCeRtIfIcAtEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.ManagedCertificateName != v.Expected.ManagedCertificateName { + t.Fatalf("Expected %q but got %q for ManagedCertificateName", v.Expected.ManagedCertificateName, actual.ManagedCertificateName) + } + + } +} + +func TestSegmentsForManagedCertificateId(t *testing.T) { + segments := ManagedCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedCertificateId 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/containerapps/2024-03-01/managedcertificates/id_managedenvironment.go b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedenvironment.go new file mode 100644 index 00000000000..caee9fab87c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedenvironment.go @@ -0,0 +1,130 @@ +package managedcertificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentId{} + +// ManagedEnvironmentId is a struct representing the Resource ID for a Managed Environment +type ManagedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string +} + +// NewManagedEnvironmentID returns a new ManagedEnvironmentId struct +func NewManagedEnvironmentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string) ManagedEnvironmentId { + return ManagedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + } +} + +// ParseManagedEnvironmentID parses 'input' into a ManagedEnvironmentId +func ParseManagedEnvironmentID(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentIDInsensitively(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + return nil +} + +// ValidateManagedEnvironmentID checks that 'input' can be parsed as a Managed Environment ID +func ValidateManagedEnvironmentID(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 := ParseManagedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment ID +func (id ManagedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment ID +func (id ManagedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Managed Environment ID +func (id ManagedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + } + return fmt.Sprintf("Managed Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedenvironment_test.go b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedenvironment_test.go new file mode 100644 index 00000000000..fa8d0e0396a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/id_managedenvironment_test.go @@ -0,0 +1,282 @@ +package managedcertificates + +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 = &ManagedEnvironmentId{} + +func TestNewManagedEnvironmentID(t *testing.T) { + id := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } +} + +func TestFormatManagedEnvironmentID(t *testing.T) { + actual := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestParseManagedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestSegmentsForManagedEnvironmentId(t *testing.T) { + segments := ManagedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentId 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/containerapps/2024-03-01/managedcertificates/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/managedcertificates/method_createorupdate.go new file mode 100644 index 00000000000..e94da589871 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/method_createorupdate.go @@ -0,0 +1,75 @@ +package managedcertificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCertificate +} + +// CreateOrUpdate ... +func (c ManagedCertificatesClient) CreateOrUpdate(ctx context.Context, id ManagedCertificateId, input ManagedCertificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedCertificatesClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedCertificateId, input ManagedCertificate) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/method_delete.go b/resource-manager/containerapps/2024-03-01/managedcertificates/method_delete.go new file mode 100644 index 00000000000..14acf6d7f88 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/method_delete.go @@ -0,0 +1,47 @@ +package managedcertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ManagedCertificatesClient) Delete(ctx context.Context, id ManagedCertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/method_get.go b/resource-manager/containerapps/2024-03-01/managedcertificates/method_get.go new file mode 100644 index 00000000000..ee99eddd759 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/method_get.go @@ -0,0 +1,54 @@ +package managedcertificates + +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 *ManagedCertificate +} + +// Get ... +func (c ManagedCertificatesClient) Get(ctx context.Context, id ManagedCertificateId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/method_list.go b/resource-manager/containerapps/2024-03-01/managedcertificates/method_list.go new file mode 100644 index 00000000000..e6e0b5426f9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/method_list.go @@ -0,0 +1,91 @@ +package managedcertificates + +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 *[]ManagedCertificate +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCertificate +} + +// List ... +func (c ManagedCertificatesClient) List(ctx context.Context, id ManagedEnvironmentId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedCertificates", 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 *[]ManagedCertificate `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 ManagedCertificatesClient) ListComplete(ctx context.Context, id ManagedEnvironmentId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ManagedCertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedCertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate ManagedCertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ManagedCertificate, 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/containerapps/2024-03-01/managedcertificates/method_update.go b/resource-manager/containerapps/2024-03-01/managedcertificates/method_update.go new file mode 100644 index 00000000000..6bbba8cc98c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/method_update.go @@ -0,0 +1,58 @@ +package managedcertificates + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCertificate +} + +// Update ... +func (c ManagedCertificatesClient) Update(ctx context.Context, id ManagedCertificateId, input ManagedCertificatePatch) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ManagedCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificate.go b/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificate.go new file mode 100644 index 00000000000..5e6732f19ce --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificate.go @@ -0,0 +1,18 @@ +package managedcertificates + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCertificate struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedCertificateProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificatepatch.go b/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificatepatch.go new file mode 100644 index 00000000000..856b680a8f5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificatepatch.go @@ -0,0 +1,8 @@ +package managedcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCertificatePatch struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificateproperties.go b/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificateproperties.go new file mode 100644 index 00000000000..6c1d6afb577 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/model_managedcertificateproperties.go @@ -0,0 +1,12 @@ +package managedcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCertificateProperties struct { + DomainControlValidation *ManagedCertificateDomainControlValidation `json:"domainControlValidation,omitempty"` + Error *string `json:"error,omitempty"` + ProvisioningState *CertificateProvisioningState `json:"provisioningState,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + ValidationToken *string `json:"validationToken,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/predicates.go b/resource-manager/containerapps/2024-03-01/managedcertificates/predicates.go new file mode 100644 index 00000000000..08e68d7dbf0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/predicates.go @@ -0,0 +1,32 @@ +package managedcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCertificateOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedCertificateOperationPredicate) Matches(input ManagedCertificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerapps/2024-03-01/managedcertificates/version.go b/resource-manager/containerapps/2024-03-01/managedcertificates/version.go new file mode 100644 index 00000000000..2a4083d47d3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedcertificates/version.go @@ -0,0 +1,12 @@ +package managedcertificates + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedcertificates/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/README.md b/resource-manager/containerapps/2024-03-01/managedenvironments/README.md new file mode 100644 index 00000000000..471d3b21fc5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/README.md @@ -0,0 +1,398 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/managedenvironments` Documentation + +The `managedenvironments` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/managedenvironments" +``` + + +### Client Initialization + +```go +client := managedenvironments.NewManagedEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedEnvironmentsClient.CertificatesCreateOrUpdate` + +```go +ctx := context.TODO() +id := managedenvironments.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +payload := managedenvironments.Certificate{ + // ... +} + + +read, err := client.CertificatesCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.CertificatesDelete` + +```go +ctx := context.TODO() +id := managedenvironments.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +read, err := client.CertificatesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.CertificatesGet` + +```go +ctx := context.TODO() +id := managedenvironments.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +read, err := client.CertificatesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.CertificatesList` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// alternatively `client.CertificatesList(ctx, id)` can be used to do batched pagination +items, err := client.CertificatesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.CertificatesUpdate` + +```go +ctx := context.TODO() +id := managedenvironments.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + +payload := managedenvironments.CertificatePatch{ + // ... +} + + +read, err := client.CertificatesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +payload := managedenvironments.ManagedEnvironment{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.DiagnosticsGetRoot` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +read, err := client.DiagnosticsGetRoot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +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: `ManagedEnvironmentsClient.GetAuthToken` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +read, err := client.GetAuthToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ListWorkloadProfileStates` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// alternatively `client.ListWorkloadProfileStates(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkloadProfileStatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ManagedCertificatesCreateOrUpdate` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +payload := managedenvironments.ManagedCertificate{ + // ... +} + + +if err := client.ManagedCertificatesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ManagedCertificatesDelete` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +read, err := client.ManagedCertificatesDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ManagedCertificatesGet` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +read, err := client.ManagedCertificatesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ManagedCertificatesList` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// alternatively `client.ManagedCertificatesList(ctx, id)` can be used to do batched pagination +items, err := client.ManagedCertificatesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ManagedCertificatesUpdate` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + +payload := managedenvironments.ManagedCertificatePatch{ + // ... +} + + +read, err := client.ManagedCertificatesUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ManagedEnvironmentDiagnosticsGetDetector` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "detectorValue") + +read, err := client.ManagedEnvironmentDiagnosticsGetDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.ManagedEnvironmentDiagnosticsListDetectors` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// alternatively `client.ManagedEnvironmentDiagnosticsListDetectors(ctx, id)` can be used to do batched pagination +items, err := client.ManagedEnvironmentDiagnosticsListDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.NamespacesCheckNameAvailability` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +payload := managedenvironments.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.NamespacesCheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := managedenvironments.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +payload := managedenvironments.ManagedEnvironment{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/client.go b/resource-manager/containerapps/2024-03-01/managedenvironments/client.go new file mode 100644 index 00000000000..d1f90d9f441 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/client.go @@ -0,0 +1,26 @@ +package managedenvironments + +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 ManagedEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewManagedEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedEnvironmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedEnvironmentsClient: %+v", err) + } + + return &ManagedEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/constants.go b/resource-manager/containerapps/2024-03-01/managedenvironments/constants.go new file mode 100644 index 00000000000..012abd06faa --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/constants.go @@ -0,0 +1,210 @@ +package managedenvironments + +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 CertificateProvisioningState string + +const ( + CertificateProvisioningStateCanceled CertificateProvisioningState = "Canceled" + CertificateProvisioningStateDeleteFailed CertificateProvisioningState = "DeleteFailed" + CertificateProvisioningStateFailed CertificateProvisioningState = "Failed" + CertificateProvisioningStatePending CertificateProvisioningState = "Pending" + CertificateProvisioningStateSucceeded CertificateProvisioningState = "Succeeded" +) + +func PossibleValuesForCertificateProvisioningState() []string { + return []string{ + string(CertificateProvisioningStateCanceled), + string(CertificateProvisioningStateDeleteFailed), + string(CertificateProvisioningStateFailed), + string(CertificateProvisioningStatePending), + string(CertificateProvisioningStateSucceeded), + } +} + +func (s *CertificateProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProvisioningState(input string) (*CertificateProvisioningState, error) { + vals := map[string]CertificateProvisioningState{ + "canceled": CertificateProvisioningStateCanceled, + "deletefailed": CertificateProvisioningStateDeleteFailed, + "failed": CertificateProvisioningStateFailed, + "pending": CertificateProvisioningStatePending, + "succeeded": CertificateProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProvisioningState(input) + return &out, nil +} + +type CheckNameAvailabilityReason string + +const ( + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +func PossibleValuesForCheckNameAvailabilityReason() []string { + return []string{ + string(CheckNameAvailabilityReasonAlreadyExists), + string(CheckNameAvailabilityReasonInvalid), + } +} + +func (s *CheckNameAvailabilityReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameAvailabilityReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameAvailabilityReason(input string) (*CheckNameAvailabilityReason, error) { + vals := map[string]CheckNameAvailabilityReason{ + "alreadyexists": CheckNameAvailabilityReasonAlreadyExists, + "invalid": CheckNameAvailabilityReasonInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameAvailabilityReason(input) + return &out, nil +} + +type EnvironmentProvisioningState string + +const ( + EnvironmentProvisioningStateCanceled EnvironmentProvisioningState = "Canceled" + EnvironmentProvisioningStateFailed EnvironmentProvisioningState = "Failed" + EnvironmentProvisioningStateInfrastructureSetupComplete EnvironmentProvisioningState = "InfrastructureSetupComplete" + EnvironmentProvisioningStateInfrastructureSetupInProgress EnvironmentProvisioningState = "InfrastructureSetupInProgress" + EnvironmentProvisioningStateInitializationInProgress EnvironmentProvisioningState = "InitializationInProgress" + EnvironmentProvisioningStateScheduledForDelete EnvironmentProvisioningState = "ScheduledForDelete" + EnvironmentProvisioningStateSucceeded EnvironmentProvisioningState = "Succeeded" + EnvironmentProvisioningStateUpgradeFailed EnvironmentProvisioningState = "UpgradeFailed" + EnvironmentProvisioningStateUpgradeRequested EnvironmentProvisioningState = "UpgradeRequested" + EnvironmentProvisioningStateWaiting EnvironmentProvisioningState = "Waiting" +) + +func PossibleValuesForEnvironmentProvisioningState() []string { + return []string{ + string(EnvironmentProvisioningStateCanceled), + string(EnvironmentProvisioningStateFailed), + string(EnvironmentProvisioningStateInfrastructureSetupComplete), + string(EnvironmentProvisioningStateInfrastructureSetupInProgress), + string(EnvironmentProvisioningStateInitializationInProgress), + string(EnvironmentProvisioningStateScheduledForDelete), + string(EnvironmentProvisioningStateSucceeded), + string(EnvironmentProvisioningStateUpgradeFailed), + string(EnvironmentProvisioningStateUpgradeRequested), + string(EnvironmentProvisioningStateWaiting), + } +} + +func (s *EnvironmentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnvironmentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnvironmentProvisioningState(input string) (*EnvironmentProvisioningState, error) { + vals := map[string]EnvironmentProvisioningState{ + "canceled": EnvironmentProvisioningStateCanceled, + "failed": EnvironmentProvisioningStateFailed, + "infrastructuresetupcomplete": EnvironmentProvisioningStateInfrastructureSetupComplete, + "infrastructuresetupinprogress": EnvironmentProvisioningStateInfrastructureSetupInProgress, + "initializationinprogress": EnvironmentProvisioningStateInitializationInProgress, + "scheduledfordelete": EnvironmentProvisioningStateScheduledForDelete, + "succeeded": EnvironmentProvisioningStateSucceeded, + "upgradefailed": EnvironmentProvisioningStateUpgradeFailed, + "upgraderequested": EnvironmentProvisioningStateUpgradeRequested, + "waiting": EnvironmentProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnvironmentProvisioningState(input) + return &out, nil +} + +type ManagedCertificateDomainControlValidation string + +const ( + ManagedCertificateDomainControlValidationCNAME ManagedCertificateDomainControlValidation = "CNAME" + ManagedCertificateDomainControlValidationHTTP ManagedCertificateDomainControlValidation = "HTTP" + ManagedCertificateDomainControlValidationTXT ManagedCertificateDomainControlValidation = "TXT" +) + +func PossibleValuesForManagedCertificateDomainControlValidation() []string { + return []string{ + string(ManagedCertificateDomainControlValidationCNAME), + string(ManagedCertificateDomainControlValidationHTTP), + string(ManagedCertificateDomainControlValidationTXT), + } +} + +func (s *ManagedCertificateDomainControlValidation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedCertificateDomainControlValidation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedCertificateDomainControlValidation(input string) (*ManagedCertificateDomainControlValidation, error) { + vals := map[string]ManagedCertificateDomainControlValidation{ + "cname": ManagedCertificateDomainControlValidationCNAME, + "http": ManagedCertificateDomainControlValidationHTTP, + "txt": ManagedCertificateDomainControlValidationTXT, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedCertificateDomainControlValidation(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate.go new file mode 100644 index 00000000000..8f924206e86 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate.go @@ -0,0 +1,139 @@ +package managedenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate_test.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate_test.go new file mode 100644 index 00000000000..859f146f8d0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_certificate_test.go @@ -0,0 +1,327 @@ +package managedenvironments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/certificates/certificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate.go new file mode 100644 index 00000000000..610fc08db29 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate.go @@ -0,0 +1,139 @@ +package managedenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedCertificateId{}) +} + +var _ resourceids.ResourceId = &ManagedCertificateId{} + +// ManagedCertificateId is a struct representing the Resource ID for a Managed Certificate +type ManagedCertificateId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + ManagedCertificateName string +} + +// NewManagedCertificateID returns a new ManagedCertificateId struct +func NewManagedCertificateID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, managedCertificateName string) ManagedCertificateId { + return ManagedCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + ManagedCertificateName: managedCertificateName, + } +} + +// ParseManagedCertificateID parses 'input' into a ManagedCertificateId +func ParseManagedCertificateID(input string) (*ManagedCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedCertificateIDInsensitively parses 'input' case-insensitively into a ManagedCertificateId +// note: this method should only be used for API response data and not user input +func ParseManagedCertificateIDInsensitively(input string) (*ManagedCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedCertificateId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.ManagedCertificateName, ok = input.Parsed["managedCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedCertificateName", input) + } + + return nil +} + +// ValidateManagedCertificateID checks that 'input' can be parsed as a Managed Certificate ID +func ValidateManagedCertificateID(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 := ParseManagedCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Certificate ID +func (id ManagedCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/managedCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.ManagedCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Certificate ID +func (id ManagedCertificateId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticManagedCertificates", "managedCertificates", "managedCertificates"), + resourceids.UserSpecifiedSegment("managedCertificateName", "managedCertificateValue"), + } +} + +// String returns a human-readable description of this Managed Certificate ID +func (id ManagedCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Managed Certificate Name: %q", id.ManagedCertificateName), + } + return fmt.Sprintf("Managed Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate_test.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate_test.go new file mode 100644 index 00000000000..1cacd6136a9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedcertificate_test.go @@ -0,0 +1,327 @@ +package managedenvironments + +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 = &ManagedCertificateId{} + +func TestNewManagedCertificateID(t *testing.T) { + id := NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.ManagedCertificateName != "managedCertificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedCertificateName'", id.ManagedCertificateName, "managedCertificateValue") + } +} + +func TestFormatManagedCertificateID(t *testing.T) { + actual := NewManagedCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "managedCertificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue", + Expected: &ManagedCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + ManagedCertificateName: "managedCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.ManagedCertificateName != v.Expected.ManagedCertificateName { + t.Fatalf("Expected %q but got %q for ManagedCertificateName", v.Expected.ManagedCertificateName, actual.ManagedCertificateName) + } + + } +} + +func TestParseManagedCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedCertificateId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/mAnAgEdCeRtIfIcAtEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue", + Expected: &ManagedCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + ManagedCertificateName: "managedCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/managedCertificates/managedCertificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/mAnAgEdCeRtIfIcAtEs/mAnAgEdCeRtIfIcAtEvAlUe", + Expected: &ManagedCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + ManagedCertificateName: "mAnAgEdCeRtIfIcAtEvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/mAnAgEdCeRtIfIcAtEs/mAnAgEdCeRtIfIcAtEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.ManagedCertificateName != v.Expected.ManagedCertificateName { + t.Fatalf("Expected %q but got %q for ManagedCertificateName", v.Expected.ManagedCertificateName, actual.ManagedCertificateName) + } + + } +} + +func TestSegmentsForManagedCertificateId(t *testing.T) { + segments := ManagedCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedCertificateId 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/containerapps/2024-03-01/managedenvironments/id_managedenvironment.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironment.go new file mode 100644 index 00000000000..e96a1dd8ba5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironment.go @@ -0,0 +1,130 @@ +package managedenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentId{} + +// ManagedEnvironmentId is a struct representing the Resource ID for a Managed Environment +type ManagedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string +} + +// NewManagedEnvironmentID returns a new ManagedEnvironmentId struct +func NewManagedEnvironmentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string) ManagedEnvironmentId { + return ManagedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + } +} + +// ParseManagedEnvironmentID parses 'input' into a ManagedEnvironmentId +func ParseManagedEnvironmentID(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentIDInsensitively(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + return nil +} + +// ValidateManagedEnvironmentID checks that 'input' can be parsed as a Managed Environment ID +func ValidateManagedEnvironmentID(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 := ParseManagedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment ID +func (id ManagedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment ID +func (id ManagedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Managed Environment ID +func (id ManagedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + } + return fmt.Sprintf("Managed Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironment_test.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironment_test.go new file mode 100644 index 00000000000..db5d8f7d9d1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironment_test.go @@ -0,0 +1,282 @@ +package managedenvironments + +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 = &ManagedEnvironmentId{} + +func TestNewManagedEnvironmentID(t *testing.T) { + id := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } +} + +func TestFormatManagedEnvironmentID(t *testing.T) { + actual := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestParseManagedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestSegmentsForManagedEnvironmentId(t *testing.T) { + segments := ManagedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentId 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/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector.go new file mode 100644 index 00000000000..6f4fce7eb18 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector.go @@ -0,0 +1,139 @@ +package managedenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentDetectorId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentDetectorId{} + +// ManagedEnvironmentDetectorId is a struct representing the Resource ID for a Managed Environment Detector +type ManagedEnvironmentDetectorId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + DetectorName string +} + +// NewManagedEnvironmentDetectorID returns a new ManagedEnvironmentDetectorId struct +func NewManagedEnvironmentDetectorID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, detectorName string) ManagedEnvironmentDetectorId { + return ManagedEnvironmentDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + DetectorName: detectorName, + } +} + +// ParseManagedEnvironmentDetectorID parses 'input' into a ManagedEnvironmentDetectorId +func ParseManagedEnvironmentDetectorID(input string) (*ManagedEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentDetectorIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentDetectorId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentDetectorIDInsensitively(input string) (*ManagedEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentDetectorId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateManagedEnvironmentDetectorID checks that 'input' can be parsed as a Managed Environment Detector ID +func ValidateManagedEnvironmentDetectorID(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 := ParseManagedEnvironmentDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment Detector ID +func (id ManagedEnvironmentDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment Detector ID +func (id ManagedEnvironmentDetectorId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Managed Environment Detector ID +func (id ManagedEnvironmentDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Managed Environment Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector_test.go b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector_test.go new file mode 100644 index 00000000000..ca139552cfd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/id_managedenvironmentdetector_test.go @@ -0,0 +1,327 @@ +package managedenvironments + +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 = &ManagedEnvironmentDetectorId{} + +func TestNewManagedEnvironmentDetectorID(t *testing.T) { + id := NewManagedEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "detectorValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatManagedEnvironmentDetectorID(t *testing.T) { + actual := NewManagedEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue", + Expected: &ManagedEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseManagedEnvironmentDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentDetectorId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue", + Expected: &ManagedEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &ManagedEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForManagedEnvironmentDetectorId(t *testing.T) { + segments := ManagedEnvironmentDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentDetectorId 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/containerapps/2024-03-01/managedenvironments/method_certificatescreateorupdate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatescreateorupdate.go new file mode 100644 index 00000000000..4b74842fc14 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatescreateorupdate.go @@ -0,0 +1,58 @@ +package managedenvironments + +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 CertificatesCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CertificatesCreateOrUpdate ... +func (c ManagedEnvironmentsClient) CertificatesCreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CertificatesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesdelete.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesdelete.go new file mode 100644 index 00000000000..d1abc892fb4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesdelete.go @@ -0,0 +1,47 @@ +package managedenvironments + +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 CertificatesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// CertificatesDelete ... +func (c ManagedEnvironmentsClient) CertificatesDelete(ctx context.Context, id CertificateId) (result CertificatesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesget.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesget.go new file mode 100644 index 00000000000..718c7d0f340 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesget.go @@ -0,0 +1,54 @@ +package managedenvironments + +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 CertificatesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CertificatesGet ... +func (c ManagedEnvironmentsClient) CertificatesGet(ctx context.Context, id CertificateId) (result CertificatesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificateslist.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificateslist.go new file mode 100644 index 00000000000..b13d72b5014 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificateslist.go @@ -0,0 +1,91 @@ +package managedenvironments + +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 CertificatesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type CertificatesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +// CertificatesList ... +func (c ManagedEnvironmentsClient) CertificatesList(ctx context.Context, id ManagedEnvironmentId) (result CertificatesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", 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 *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CertificatesListComplete retrieves all the results into a single object +func (c ManagedEnvironmentsClient) CertificatesListComplete(ctx context.Context, id ManagedEnvironmentId) (CertificatesListCompleteResult, error) { + return c.CertificatesListCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// CertificatesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedEnvironmentsClient) CertificatesListCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate CertificateOperationPredicate) (result CertificatesListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.CertificatesList(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 = CertificatesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesupdate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesupdate.go new file mode 100644 index 00000000000..761029f13c6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_certificatesupdate.go @@ -0,0 +1,58 @@ +package managedenvironments + +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 CertificatesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CertificatesUpdate ... +func (c ManagedEnvironmentsClient) CertificatesUpdate(ctx context.Context, id CertificateId, input CertificatePatch) (result CertificatesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_createorupdate.go new file mode 100644 index 00000000000..c48ed229fa4 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_createorupdate.go @@ -0,0 +1,75 @@ +package managedenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedEnvironment +} + +// CreateOrUpdate ... +func (c ManagedEnvironmentsClient) CreateOrUpdate(ctx context.Context, id ManagedEnvironmentId, input ManagedEnvironment) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedEnvironmentId, input ManagedEnvironment) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_delete.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_delete.go new file mode 100644 index 00000000000..3027fc878dd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_delete.go @@ -0,0 +1,71 @@ +package managedenvironments + +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 ManagedEnvironmentsClient) Delete(ctx context.Context, id ManagedEnvironmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ManagedEnvironmentsClient) DeleteThenPoll(ctx context.Context, id ManagedEnvironmentId) 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/containerapps/2024-03-01/managedenvironments/method_diagnosticsgetroot.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_diagnosticsgetroot.go new file mode 100644 index 00000000000..88cccae7e27 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_diagnosticsgetroot.go @@ -0,0 +1,55 @@ +package managedenvironments + +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 DiagnosticsGetRootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedEnvironment +} + +// DiagnosticsGetRoot ... +func (c ManagedEnvironmentsClient) DiagnosticsGetRoot(ctx context.Context, id ManagedEnvironmentId) (result DiagnosticsGetRootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectorProperties/rootApi", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedEnvironment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_get.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_get.go new file mode 100644 index 00000000000..8b0cdde0fe5 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_get.go @@ -0,0 +1,54 @@ +package managedenvironments + +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 *ManagedEnvironment +} + +// Get ... +func (c ManagedEnvironmentsClient) Get(ctx context.Context, id ManagedEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedEnvironment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_getauthtoken.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_getauthtoken.go new file mode 100644 index 00000000000..fe7eb3d026e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_getauthtoken.go @@ -0,0 +1,55 @@ +package managedenvironments + +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 GetAuthTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EnvironmentAuthToken +} + +// GetAuthToken ... +func (c ManagedEnvironmentsClient) GetAuthToken(ctx context.Context, id ManagedEnvironmentId) (result GetAuthTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getAuthtoken", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model EnvironmentAuthToken + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_listbyresourcegroup.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..af8d79cf392 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package managedenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedEnvironment +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedEnvironment +} + +// ListByResourceGroup ... +func (c ManagedEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/managedEnvironments", 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 *[]ManagedEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ManagedEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedEnvironmentOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedEnvironmentOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedEnvironment, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_listbysubscription.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_listbysubscription.go new file mode 100644 index 00000000000..39aad73bcd9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_listbysubscription.go @@ -0,0 +1,92 @@ +package managedenvironments + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedEnvironment +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedEnvironment +} + +// ListBySubscription ... +func (c ManagedEnvironmentsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.App/managedEnvironments", 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 *[]ManagedEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ManagedEnvironmentsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ManagedEnvironmentOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedEnvironmentsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedEnvironmentOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ManagedEnvironment, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_listworkloadprofilestates.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_listworkloadprofilestates.go new file mode 100644 index 00000000000..62cdd568da9 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_listworkloadprofilestates.go @@ -0,0 +1,91 @@ +package managedenvironments + +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 ListWorkloadProfileStatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkloadProfileStates +} + +type ListWorkloadProfileStatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkloadProfileStates +} + +// ListWorkloadProfileStates ... +func (c ManagedEnvironmentsClient) ListWorkloadProfileStates(ctx context.Context, id ManagedEnvironmentId) (result ListWorkloadProfileStatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/workloadProfileStates", 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 *[]WorkloadProfileStates `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkloadProfileStatesComplete retrieves all the results into a single object +func (c ManagedEnvironmentsClient) ListWorkloadProfileStatesComplete(ctx context.Context, id ManagedEnvironmentId) (ListWorkloadProfileStatesCompleteResult, error) { + return c.ListWorkloadProfileStatesCompleteMatchingPredicate(ctx, id, WorkloadProfileStatesOperationPredicate{}) +} + +// ListWorkloadProfileStatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedEnvironmentsClient) ListWorkloadProfileStatesCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate WorkloadProfileStatesOperationPredicate) (result ListWorkloadProfileStatesCompleteResult, err error) { + items := make([]WorkloadProfileStates, 0) + + resp, err := c.ListWorkloadProfileStates(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 = ListWorkloadProfileStatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatescreateorupdate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatescreateorupdate.go new file mode 100644 index 00000000000..f97b8b9cbb8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatescreateorupdate.go @@ -0,0 +1,75 @@ +package managedenvironments + +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 ManagedCertificatesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCertificate +} + +// ManagedCertificatesCreateOrUpdate ... +func (c ManagedEnvironmentsClient) ManagedCertificatesCreateOrUpdate(ctx context.Context, id ManagedCertificateId, input ManagedCertificate) (result ManagedCertificatesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// ManagedCertificatesCreateOrUpdateThenPoll performs ManagedCertificatesCreateOrUpdate then polls until it's completed +func (c ManagedEnvironmentsClient) ManagedCertificatesCreateOrUpdateThenPoll(ctx context.Context, id ManagedCertificateId, input ManagedCertificate) error { + result, err := c.ManagedCertificatesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ManagedCertificatesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ManagedCertificatesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesdelete.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesdelete.go new file mode 100644 index 00000000000..48f92220083 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesdelete.go @@ -0,0 +1,47 @@ +package managedenvironments + +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 ManagedCertificatesDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ManagedCertificatesDelete ... +func (c ManagedEnvironmentsClient) ManagedCertificatesDelete(ctx context.Context, id ManagedCertificateId) (result ManagedCertificatesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesget.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesget.go new file mode 100644 index 00000000000..7b3915bd5d8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesget.go @@ -0,0 +1,54 @@ +package managedenvironments + +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 ManagedCertificatesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCertificate +} + +// ManagedCertificatesGet ... +func (c ManagedEnvironmentsClient) ManagedCertificatesGet(ctx context.Context, id ManagedCertificateId) (result ManagedCertificatesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificateslist.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificateslist.go new file mode 100644 index 00000000000..08b61cbe56c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificateslist.go @@ -0,0 +1,91 @@ +package managedenvironments + +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 ManagedCertificatesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedCertificate +} + +type ManagedCertificatesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCertificate +} + +// ManagedCertificatesList ... +func (c ManagedEnvironmentsClient) ManagedCertificatesList(ctx context.Context, id ManagedEnvironmentId) (result ManagedCertificatesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedCertificates", 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 *[]ManagedCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagedCertificatesListComplete retrieves all the results into a single object +func (c ManagedEnvironmentsClient) ManagedCertificatesListComplete(ctx context.Context, id ManagedEnvironmentId) (ManagedCertificatesListCompleteResult, error) { + return c.ManagedCertificatesListCompleteMatchingPredicate(ctx, id, ManagedCertificateOperationPredicate{}) +} + +// ManagedCertificatesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedEnvironmentsClient) ManagedCertificatesListCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate ManagedCertificateOperationPredicate) (result ManagedCertificatesListCompleteResult, err error) { + items := make([]ManagedCertificate, 0) + + resp, err := c.ManagedCertificatesList(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 = ManagedCertificatesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesupdate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesupdate.go new file mode 100644 index 00000000000..d4ecb3dd00b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedcertificatesupdate.go @@ -0,0 +1,58 @@ +package managedenvironments + +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 ManagedCertificatesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCertificate +} + +// ManagedCertificatesUpdate ... +func (c ManagedEnvironmentsClient) ManagedCertificatesUpdate(ctx context.Context, id ManagedCertificateId, input ManagedCertificatePatch) (result ManagedCertificatesUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ManagedCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticsgetdetector.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticsgetdetector.go new file mode 100644 index 00000000000..43845d85187 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticsgetdetector.go @@ -0,0 +1,54 @@ +package managedenvironments + +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 ManagedEnvironmentDiagnosticsGetDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Diagnostics +} + +// ManagedEnvironmentDiagnosticsGetDetector ... +func (c ManagedEnvironmentsClient) ManagedEnvironmentDiagnosticsGetDetector(ctx context.Context, id ManagedEnvironmentDetectorId) (result ManagedEnvironmentDiagnosticsGetDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Diagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticslistdetectors.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticslistdetectors.go new file mode 100644 index 00000000000..f0debda005c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_managedenvironmentdiagnosticslistdetectors.go @@ -0,0 +1,91 @@ +package managedenvironments + +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 ManagedEnvironmentDiagnosticsListDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Diagnostics +} + +type ManagedEnvironmentDiagnosticsListDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Diagnostics +} + +// ManagedEnvironmentDiagnosticsListDetectors ... +func (c ManagedEnvironmentsClient) ManagedEnvironmentDiagnosticsListDetectors(ctx context.Context, id ManagedEnvironmentId) (result ManagedEnvironmentDiagnosticsListDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]Diagnostics `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagedEnvironmentDiagnosticsListDetectorsComplete retrieves all the results into a single object +func (c ManagedEnvironmentsClient) ManagedEnvironmentDiagnosticsListDetectorsComplete(ctx context.Context, id ManagedEnvironmentId) (ManagedEnvironmentDiagnosticsListDetectorsCompleteResult, error) { + return c.ManagedEnvironmentDiagnosticsListDetectorsCompleteMatchingPredicate(ctx, id, DiagnosticsOperationPredicate{}) +} + +// ManagedEnvironmentDiagnosticsListDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedEnvironmentsClient) ManagedEnvironmentDiagnosticsListDetectorsCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate DiagnosticsOperationPredicate) (result ManagedEnvironmentDiagnosticsListDetectorsCompleteResult, err error) { + items := make([]Diagnostics, 0) + + resp, err := c.ManagedEnvironmentDiagnosticsListDetectors(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 = ManagedEnvironmentDiagnosticsListDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_namespaceschecknameavailability.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_namespaceschecknameavailability.go new file mode 100644 index 00000000000..b1f2717072a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_namespaceschecknameavailability.go @@ -0,0 +1,59 @@ +package managedenvironments + +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 NamespacesCheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResponse +} + +// NamespacesCheckNameAvailability ... +func (c ManagedEnvironmentsClient) NamespacesCheckNameAvailability(ctx context.Context, id ManagedEnvironmentId, input CheckNameAvailabilityRequest) (result NamespacesCheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/method_update.go b/resource-manager/containerapps/2024-03-01/managedenvironments/method_update.go new file mode 100644 index 00000000000..68a3258e308 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/method_update.go @@ -0,0 +1,75 @@ +package managedenvironments + +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 *ManagedEnvironment +} + +// Update ... +func (c ManagedEnvironmentsClient) Update(ctx context.Context, id ManagedEnvironmentId, input ManagedEnvironment) (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 ManagedEnvironmentsClient) UpdateThenPoll(ctx context.Context, id ManagedEnvironmentId, input ManagedEnvironment) 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/containerapps/2024-03-01/managedenvironments/model_applogsconfiguration.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_applogsconfiguration.go new file mode 100644 index 00000000000..abdf9f78657 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_applogsconfiguration.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppLogsConfiguration struct { + Destination *string `json:"destination,omitempty"` + LogAnalyticsConfiguration *LogAnalyticsConfiguration `json:"logAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificate.go new file mode 100644 index 00000000000..484fed38c23 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificate.go @@ -0,0 +1,18 @@ +package managedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificatepatch.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificatepatch.go new file mode 100644 index 00000000000..2dac1ee3ef3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificatepatch.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatch struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificateproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificateproperties.go new file mode 100644 index 00000000000..dc685477167 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_certificateproperties.go @@ -0,0 +1,48 @@ +package managedenvironments + +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 CertificateProperties struct { + ExpirationDate *string `json:"expirationDate,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + Password *string `json:"password,omitempty"` + ProvisioningState *CertificateProvisioningState `json:"provisioningState,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SubjectAlternativeNames *[]string `json:"subjectAlternativeNames,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` + Value *string `json:"value,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityrequest.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityrequest.go new file mode 100644 index 00000000000..d294561f4e0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityrequest.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityresponse.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityresponse.go new file mode 100644 index 00000000000..4543ac719ef --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_checknameavailabilityresponse.go @@ -0,0 +1,10 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResponse struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *CheckNameAvailabilityReason `json:"reason,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_customdomainconfiguration.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_customdomainconfiguration.go new file mode 100644 index 00000000000..567a79cebd0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_customdomainconfiguration.go @@ -0,0 +1,32 @@ +package managedenvironments + +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 CustomDomainConfiguration struct { + CertificatePassword *string `json:"certificatePassword,omitempty"` + CertificateValue *string `json:"certificateValue,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} + +func (o *CustomDomainConfiguration) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CustomDomainConfiguration) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_daprconfiguration.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_daprconfiguration.go new file mode 100644 index 00000000000..53bd17d3757 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_daprconfiguration.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfiguration struct { + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadata.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadata.go new file mode 100644 index 00000000000..4370d2d5424 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadata.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadata struct { + PropertyBag *[]DiagnosticDataProviderMetadataPropertyBagInlined `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadatapropertybaginlined.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadatapropertybaginlined.go new file mode 100644 index 00000000000..4d896361710 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdataprovidermetadatapropertybaginlined.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataProviderMetadataPropertyBagInlined struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponsecolumn.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponsecolumn.go new file mode 100644 index 00000000000..ab6b5a67c29 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponsecolumn.go @@ -0,0 +1,10 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponseobject.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponseobject.go new file mode 100644 index 00000000000..27daeba457d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticdatatableresponseobject.go @@ -0,0 +1,10 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDataTableResponseObject struct { + Columns *[]DiagnosticDataTableResponseColumn `json:"columns,omitempty"` + Rows *[]interface{} `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticrendering.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticrendering.go new file mode 100644 index 00000000000..12c6de84296 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticrendering.go @@ -0,0 +1,11 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticRendering struct { + Description *string `json:"description,omitempty"` + IsVisible *bool `json:"isVisible,omitempty"` + Title *string `json:"title,omitempty"` + Type *int64 `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnostics.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnostics.go new file mode 100644 index 00000000000..206b21e02c0 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnostics.go @@ -0,0 +1,16 @@ +package managedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Diagnostics struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticsProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdataapiresponse.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdataapiresponse.go new file mode 100644 index 00000000000..f03854afb04 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdataapiresponse.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDataApiResponse struct { + RenderingProperties *DiagnosticRendering `json:"renderingProperties,omitempty"` + Table *DiagnosticDataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdefinition.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdefinition.go new file mode 100644 index 00000000000..4b111825f40 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsdefinition.go @@ -0,0 +1,16 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsDefinition struct { + AnalysisTypes *[]string `json:"analysisTypes,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]DiagnosticSupportTopic `json:"supportTopicList,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsproperties.go new file mode 100644 index 00000000000..b8b0624147b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsproperties.go @@ -0,0 +1,11 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsProperties struct { + DataProviderMetadata *DiagnosticDataProviderMetadata `json:"dataProviderMetadata,omitempty"` + Dataset *[]DiagnosticsDataApiResponse `json:"dataset,omitempty"` + Metadata *DiagnosticsDefinition `json:"metadata,omitempty"` + Status *DiagnosticsStatus `json:"status,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsstatus.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsstatus.go new file mode 100644 index 00000000000..bff7d6b2f93 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsstatus.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsStatus struct { + Message *string `json:"message,omitempty"` + StatusId *int64 `json:"statusId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsupporttopic.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsupporttopic.go new file mode 100644 index 00000000000..3402c1969af --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_diagnosticsupporttopic.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticSupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtoken.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtoken.go new file mode 100644 index 00000000000..500c9d59643 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtoken.go @@ -0,0 +1,18 @@ +package managedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentAuthToken struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *EnvironmentAuthTokenProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtokenproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtokenproperties.go new file mode 100644 index 00000000000..78e904953fd --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_environmentauthtokenproperties.go @@ -0,0 +1,27 @@ +package managedenvironments + +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 EnvironmentAuthTokenProperties struct { + Expires *string `json:"expires,omitempty"` + Token *string `json:"token,omitempty"` +} + +func (o *EnvironmentAuthTokenProperties) GetExpiresAsTime() (*time.Time, error) { + if o.Expires == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Expires, "2006-01-02T15:04:05Z07:00") +} + +func (o *EnvironmentAuthTokenProperties) SetExpiresAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Expires = &formatted +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_kedaconfiguration.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_kedaconfiguration.go new file mode 100644 index 00000000000..16513cb6808 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_kedaconfiguration.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KedaConfiguration struct { + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_loganalyticsconfiguration.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_loganalyticsconfiguration.go new file mode 100644 index 00000000000..f521fb6729d --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_loganalyticsconfiguration.go @@ -0,0 +1,9 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsConfiguration struct { + CustomerId *string `json:"customerId,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificate.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificate.go new file mode 100644 index 00000000000..7e1f1e64b10 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificate.go @@ -0,0 +1,18 @@ +package managedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCertificate struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedCertificateProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificatepatch.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificatepatch.go new file mode 100644 index 00000000000..4f8a0d6af6b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificatepatch.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCertificatePatch struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificateproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificateproperties.go new file mode 100644 index 00000000000..b67b5aec719 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedcertificateproperties.go @@ -0,0 +1,12 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCertificateProperties struct { + DomainControlValidation *ManagedCertificateDomainControlValidation `json:"domainControlValidation,omitempty"` + Error *string `json:"error,omitempty"` + ProvisioningState *CertificateProvisioningState `json:"provisioningState,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + ValidationToken *string `json:"validationToken,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironment.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironment.go new file mode 100644 index 00000000000..860e7bc7127 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironment.go @@ -0,0 +1,19 @@ +package managedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironment struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedEnvironmentProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentproperties.go new file mode 100644 index 00000000000..07ed752ece1 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentproperties.go @@ -0,0 +1,24 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentProperties struct { + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + CustomDomainConfiguration *CustomDomainConfiguration `json:"customDomainConfiguration,omitempty"` + DaprAIConnectionString *string `json:"daprAIConnectionString,omitempty"` + DaprAIInstrumentationKey *string `json:"daprAIInstrumentationKey,omitempty"` + DaprConfiguration *DaprConfiguration `json:"daprConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + EventStreamEndpoint *string `json:"eventStreamEndpoint,omitempty"` + InfrastructureResourceGroup *string `json:"infrastructureResourceGroup,omitempty"` + KedaConfiguration *KedaConfiguration `json:"kedaConfiguration,omitempty"` + PeerAuthentication *ManagedEnvironmentPropertiesPeerAuthentication `json:"peerAuthentication,omitempty"` + PeerTrafficConfiguration *ManagedEnvironmentPropertiesPeerTrafficConfiguration `json:"peerTrafficConfiguration,omitempty"` + ProvisioningState *EnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` + VnetConfiguration *VnetConfiguration `json:"vnetConfiguration,omitempty"` + WorkloadProfiles *[]WorkloadProfile `json:"workloadProfiles,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeerauthentication.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeerauthentication.go new file mode 100644 index 00000000000..3a549e03594 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeerauthentication.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentPropertiesPeerAuthentication struct { + Mtls *Mtls `json:"mtls,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfiguration.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfiguration.go new file mode 100644 index 00000000000..780049df980 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfiguration.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentPropertiesPeerTrafficConfiguration struct { + Encryption *ManagedEnvironmentPropertiesPeerTrafficConfigurationEncryption `json:"encryption,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go new file mode 100644 index 00000000000..06027684e92 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_managedenvironmentpropertiespeertrafficconfigurationencryption.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentPropertiesPeerTrafficConfigurationEncryption struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_mtls.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_mtls.go new file mode 100644 index 00000000000..a3a25e87695 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_mtls.go @@ -0,0 +1,8 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Mtls struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_vnetconfiguration.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_vnetconfiguration.go new file mode 100644 index 00000000000..014a2857454 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_vnetconfiguration.go @@ -0,0 +1,12 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetConfiguration struct { + DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"` + InfrastructureSubnetId *string `json:"infrastructureSubnetId,omitempty"` + Internal *bool `json:"internal,omitempty"` + PlatformReservedCidr *string `json:"platformReservedCidr,omitempty"` + PlatformReservedDnsIP *string `json:"platformReservedDnsIP,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofile.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofile.go new file mode 100644 index 00000000000..bcf34bbba5b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofile.go @@ -0,0 +1,11 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProfile struct { + MaximumCount *int64 `json:"maximumCount,omitempty"` + MinimumCount *int64 `json:"minimumCount,omitempty"` + Name string `json:"name"` + WorkloadProfileType string `json:"workloadProfileType"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestates.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestates.go new file mode 100644 index 00000000000..e0db3501de7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestates.go @@ -0,0 +1,16 @@ +package managedenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProfileStates struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkloadProfileStatesProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestatesproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestatesproperties.go new file mode 100644 index 00000000000..e5e7acb2d49 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/model_workloadprofilestatesproperties.go @@ -0,0 +1,10 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProfileStatesProperties struct { + CurrentCount *int64 `json:"currentCount,omitempty"` + MaximumCount *int64 `json:"maximumCount,omitempty"` + MinimumCount *int64 `json:"minimumCount,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironments/predicates.go b/resource-manager/containerapps/2024-03-01/managedenvironments/predicates.go new file mode 100644 index 00000000000..47decb01f0c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/predicates.go @@ -0,0 +1,139 @@ +package managedenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type DiagnosticsOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DiagnosticsOperationPredicate) Matches(input Diagnostics) 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 +} + +type ManagedCertificateOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedCertificateOperationPredicate) Matches(input ManagedCertificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ManagedEnvironmentOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p ManagedEnvironmentOperationPredicate) Matches(input ManagedEnvironment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WorkloadProfileStatesOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkloadProfileStatesOperationPredicate) Matches(input WorkloadProfileStates) 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/containerapps/2024-03-01/managedenvironments/version.go b/resource-manager/containerapps/2024-03-01/managedenvironments/version.go new file mode 100644 index 00000000000..725bcb7fac3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironments/version.go @@ -0,0 +1,12 @@ +package managedenvironments + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedenvironments/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/README.md b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/README.md new file mode 100644 index 00000000000..5423fb72720 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/README.md @@ -0,0 +1,89 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages` Documentation + +The `managedenvironmentsstorages` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/managedenvironmentsstorages" +``` + + +### Client Initialization + +```go +client := managedenvironmentsstorages.NewManagedEnvironmentsStoragesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedEnvironmentsStoragesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := managedenvironmentsstorages.NewStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "storageValue") + +payload := managedenvironmentsstorages.ManagedEnvironmentStorage{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsStoragesClient.Delete` + +```go +ctx := context.TODO() +id := managedenvironmentsstorages.NewStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "storageValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedEnvironmentsStoragesClient.Get` + +```go +ctx := context.TODO() +id := managedenvironmentsstorages.NewStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "storageValue") + +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: `ManagedEnvironmentsStoragesClient.List` + +```go +ctx := context.TODO() +id := managedenvironmentsstorages.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +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/containerapps/2024-03-01/managedenvironmentsstorages/client.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/client.go new file mode 100644 index 00000000000..48b7aee12b3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/client.go @@ -0,0 +1,26 @@ +package managedenvironmentsstorages + +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 ManagedEnvironmentsStoragesClient struct { + Client *resourcemanager.Client +} + +func NewManagedEnvironmentsStoragesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedEnvironmentsStoragesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedenvironmentsstorages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedEnvironmentsStoragesClient: %+v", err) + } + + return &ManagedEnvironmentsStoragesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/constants.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/constants.go new file mode 100644 index 00000000000..ea9d6dcf5bf --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/constants.go @@ -0,0 +1,51 @@ +package managedenvironmentsstorages + +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 AccessMode string + +const ( + AccessModeReadOnly AccessMode = "ReadOnly" + AccessModeReadWrite AccessMode = "ReadWrite" +) + +func PossibleValuesForAccessMode() []string { + return []string{ + string(AccessModeReadOnly), + string(AccessModeReadWrite), + } +} + +func (s *AccessMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccessMode(input string) (*AccessMode, error) { + vals := map[string]AccessMode{ + "readonly": AccessModeReadOnly, + "readwrite": AccessModeReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessMode(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment.go new file mode 100644 index 00000000000..4bf35d8d15b --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment.go @@ -0,0 +1,130 @@ +package managedenvironmentsstorages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentId{} + +// ManagedEnvironmentId is a struct representing the Resource ID for a Managed Environment +type ManagedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string +} + +// NewManagedEnvironmentID returns a new ManagedEnvironmentId struct +func NewManagedEnvironmentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string) ManagedEnvironmentId { + return ManagedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + } +} + +// ParseManagedEnvironmentID parses 'input' into a ManagedEnvironmentId +func ParseManagedEnvironmentID(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentIDInsensitively(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + return nil +} + +// ValidateManagedEnvironmentID checks that 'input' can be parsed as a Managed Environment ID +func ValidateManagedEnvironmentID(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 := ParseManagedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment ID +func (id ManagedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment ID +func (id ManagedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Managed Environment ID +func (id ManagedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + } + return fmt.Sprintf("Managed Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment_test.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment_test.go new file mode 100644 index 00000000000..45a11fbbf31 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_managedenvironment_test.go @@ -0,0 +1,282 @@ +package managedenvironmentsstorages + +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 = &ManagedEnvironmentId{} + +func TestNewManagedEnvironmentID(t *testing.T) { + id := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } +} + +func TestFormatManagedEnvironmentID(t *testing.T) { + actual := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestParseManagedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestSegmentsForManagedEnvironmentId(t *testing.T) { + segments := ManagedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentId 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/containerapps/2024-03-01/managedenvironmentsstorages/id_storage.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_storage.go new file mode 100644 index 00000000000..d3c5f4b065c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_storage.go @@ -0,0 +1,139 @@ +package managedenvironmentsstorages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StorageId{}) +} + +var _ resourceids.ResourceId = &StorageId{} + +// StorageId is a struct representing the Resource ID for a Storage +type StorageId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string + StorageName string +} + +// NewStorageID returns a new StorageId struct +func NewStorageID(subscriptionId string, resourceGroupName string, managedEnvironmentName string, storageName string) StorageId { + return StorageId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + StorageName: storageName, + } +} + +// ParseStorageID parses 'input' into a StorageId +func ParseStorageID(input string) (*StorageId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStorageIDInsensitively parses 'input' case-insensitively into a StorageId +// note: this method should only be used for API response data and not user input +func ParseStorageIDInsensitively(input string) (*StorageId, error) { + parser := resourceids.NewParserFromResourceIdType(&StorageId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StorageId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StorageId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + if id.StorageName, ok = input.Parsed["storageName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "storageName", input) + } + + return nil +} + +// ValidateStorageID checks that 'input' can be parsed as a Storage ID +func ValidateStorageID(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 := ParseStorageID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Storage ID +func (id StorageId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s/storages/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName, id.StorageName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Storage ID +func (id StorageId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + resourceids.StaticSegment("staticStorages", "storages", "storages"), + resourceids.UserSpecifiedSegment("storageName", "storageValue"), + } +} + +// String returns a human-readable description of this Storage ID +func (id StorageId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + fmt.Sprintf("Storage Name: %q", id.StorageName), + } + return fmt.Sprintf("Storage (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_storage_test.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_storage_test.go new file mode 100644 index 00000000000..e498cba7f19 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/id_storage_test.go @@ -0,0 +1,327 @@ +package managedenvironmentsstorages + +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 = &StorageId{} + +func TestNewStorageID(t *testing.T) { + id := NewStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "storageValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } + + if id.StorageName != "storageValue" { + t.Fatalf("Expected %q but got %q for Segment 'StorageName'", id.StorageName, "storageValue") + } +} + +func TestFormatStorageID(t *testing.T) { + actual := NewStorageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue", "storageValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/storages/storageValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStorageID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/storages", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/storages/storageValue", + Expected: &StorageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + StorageName: "storageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/storages/storageValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.StorageName != v.Expected.StorageName { + t.Fatalf("Expected %q but got %q for StorageName", v.Expected.StorageName, actual.StorageName) + } + + } +} + +func TestParseStorageIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StorageId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/storages", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/sToRaGeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/storages/storageValue", + Expected: &StorageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + StorageName: "storageValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/storages/storageValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/sToRaGeS/sToRaGeVaLuE", + Expected: &StorageId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + StorageName: "sToRaGeVaLuE", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/sToRaGeS/sToRaGeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStorageIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + if actual.StorageName != v.Expected.StorageName { + t.Fatalf("Expected %q but got %q for StorageName", v.Expected.StorageName, actual.StorageName) + } + + } +} + +func TestSegmentsForStorageId(t *testing.T) { + segments := StorageId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StorageId 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/containerapps/2024-03-01/managedenvironmentsstorages/method_createorupdate.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_createorupdate.go new file mode 100644 index 00000000000..3221f2c5162 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_createorupdate.go @@ -0,0 +1,58 @@ +package managedenvironmentsstorages + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedEnvironmentStorage +} + +// CreateOrUpdate ... +func (c ManagedEnvironmentsStoragesClient) CreateOrUpdate(ctx context.Context, id StorageId, input ManagedEnvironmentStorage) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedEnvironmentStorage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_delete.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_delete.go new file mode 100644 index 00000000000..46330ae42f3 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_delete.go @@ -0,0 +1,47 @@ +package managedenvironmentsstorages + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ManagedEnvironmentsStoragesClient) Delete(ctx context.Context, id StorageId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_get.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_get.go new file mode 100644 index 00000000000..dbb3feab7e8 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_get.go @@ -0,0 +1,54 @@ +package managedenvironmentsstorages + +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 *ManagedEnvironmentStorage +} + +// Get ... +func (c ManagedEnvironmentsStoragesClient) Get(ctx context.Context, id StorageId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedEnvironmentStorage + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_list.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_list.go new file mode 100644 index 00000000000..90f9fe55a5f --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/method_list.go @@ -0,0 +1,55 @@ +package managedenvironmentsstorages + +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 *ManagedEnvironmentStoragesCollection +} + +// List ... +func (c ManagedEnvironmentsStoragesClient) List(ctx context.Context, id ManagedEnvironmentId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/storages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedEnvironmentStoragesCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_azurefileproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_azurefileproperties.go new file mode 100644 index 00000000000..e7a33554e85 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_azurefileproperties.go @@ -0,0 +1,11 @@ +package managedenvironmentsstorages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileProperties struct { + AccessMode *AccessMode `json:"accessMode,omitempty"` + AccountKey *string `json:"accountKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + ShareName *string `json:"shareName,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorage.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorage.go new file mode 100644 index 00000000000..3bc1545fd92 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorage.go @@ -0,0 +1,16 @@ +package managedenvironmentsstorages + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentStorage struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedEnvironmentStorageProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorageproperties.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorageproperties.go new file mode 100644 index 00000000000..45fe17a07dc --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstorageproperties.go @@ -0,0 +1,8 @@ +package managedenvironmentsstorages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentStorageProperties struct { + AzureFile *AzureFileProperties `json:"azureFile,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstoragescollection.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstoragescollection.go new file mode 100644 index 00000000000..9e26cae077c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/model_managedenvironmentstoragescollection.go @@ -0,0 +1,8 @@ +package managedenvironmentsstorages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedEnvironmentStoragesCollection struct { + Value []ManagedEnvironmentStorage `json:"value"` +} diff --git a/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/version.go b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/version.go new file mode 100644 index 00000000000..33ca835175c --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/managedenvironmentsstorages/version.go @@ -0,0 +1,12 @@ +package managedenvironmentsstorages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedenvironmentsstorages/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/subscriptions/client.go b/resource-manager/containerapps/2024-03-01/subscriptions/client.go new file mode 100644 index 00000000000..09be7cb1cfb --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/subscriptions/client.go @@ -0,0 +1,26 @@ +package subscriptions + +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 SubscriptionsClient struct { + Client *resourcemanager.Client +} + +func NewSubscriptionsClientWithBaseURI(sdkApi sdkEnv.Api) (*SubscriptionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "subscriptions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SubscriptionsClient: %+v", err) + } + + return &SubscriptionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/subscriptions/method_getcustomdomainverificationid.go b/resource-manager/containerapps/2024-03-01/subscriptions/method_getcustomdomainverificationid.go new file mode 100644 index 00000000000..00e862b0909 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/subscriptions/method_getcustomdomainverificationid.go @@ -0,0 +1,56 @@ +package subscriptions + +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 GetCustomDomainVerificationIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetCustomDomainVerificationId ... +func (c SubscriptionsClient) GetCustomDomainVerificationId(ctx context.Context, id commonids.SubscriptionId) (result GetCustomDomainVerificationIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.App/getCustomDomainVerificationId", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerapps/2024-03-01/subscriptions/version.go b/resource-manager/containerapps/2024-03-01/subscriptions/version.go new file mode 100644 index 00000000000..81b23fe88f7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/subscriptions/version.go @@ -0,0 +1,12 @@ +package subscriptions + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/subscriptions/%s", defaultApiVersion) +} diff --git a/resource-manager/containerapps/2024-03-01/usages/README.md b/resource-manager/containerapps/2024-03-01/usages/README.md new file mode 100644 index 00000000000..101a4a90b45 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerapps/2024-03-01/usages` Documentation + +The `usages` SDK allows for interaction with the Azure Resource Manager Service `containerapps` (API Version `2024-03-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/containerapps/2024-03-01/usages" +``` + + +### Client Initialization + +```go +client := usages.NewUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `UsagesClient.List` + +```go +ctx := context.TODO() +id := usages.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// 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: `UsagesClient.ManagedEnvironmentUsagesList` + +```go +ctx := context.TODO() +id := usages.NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + +// alternatively `client.ManagedEnvironmentUsagesList(ctx, id)` can be used to do batched pagination +items, err := client.ManagedEnvironmentUsagesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerapps/2024-03-01/usages/client.go b/resource-manager/containerapps/2024-03-01/usages/client.go new file mode 100644 index 00000000000..772d6a5be35 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/client.go @@ -0,0 +1,26 @@ +package usages + +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 UsagesClient struct { + Client *resourcemanager.Client +} + +func NewUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*UsagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "usages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsagesClient: %+v", err) + } + + return &UsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerapps/2024-03-01/usages/constants.go b/resource-manager/containerapps/2024-03-01/usages/constants.go new file mode 100644 index 00000000000..0d8916ba5aa --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/constants.go @@ -0,0 +1,48 @@ +package usages + +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 UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +func PossibleValuesForUsageUnit() []string { + return []string{ + string(UsageUnitCount), + } +} + +func (s *UsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageUnit(input string) (*UsageUnit, error) { + vals := map[string]UsageUnit{ + "count": UsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageUnit(input) + return &out, nil +} diff --git a/resource-manager/containerapps/2024-03-01/usages/id_location.go b/resource-manager/containerapps/2024-03-01/usages/id_location.go new file mode 100644 index 00000000000..668b29aaeda --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/id_location.go @@ -0,0 +1,121 @@ +package usages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.App/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/usages/id_location_test.go b/resource-manager/containerapps/2024-03-01/usages/id_location_test.go new file mode 100644 index 00000000000..41dd27778c6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/id_location_test.go @@ -0,0 +1,237 @@ +package usages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.App/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.aPp/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerapps/2024-03-01/usages/id_managedenvironment.go b/resource-manager/containerapps/2024-03-01/usages/id_managedenvironment.go new file mode 100644 index 00000000000..05bd0ac8d64 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/id_managedenvironment.go @@ -0,0 +1,130 @@ +package usages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedEnvironmentId{}) +} + +var _ resourceids.ResourceId = &ManagedEnvironmentId{} + +// ManagedEnvironmentId is a struct representing the Resource ID for a Managed Environment +type ManagedEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + ManagedEnvironmentName string +} + +// NewManagedEnvironmentID returns a new ManagedEnvironmentId struct +func NewManagedEnvironmentID(subscriptionId string, resourceGroupName string, managedEnvironmentName string) ManagedEnvironmentId { + return ManagedEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedEnvironmentName: managedEnvironmentName, + } +} + +// ParseManagedEnvironmentID parses 'input' into a ManagedEnvironmentId +func ParseManagedEnvironmentID(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedEnvironmentIDInsensitively parses 'input' case-insensitively into a ManagedEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseManagedEnvironmentIDInsensitively(input string) (*ManagedEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedEnvironmentId) 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.ManagedEnvironmentName, ok = input.Parsed["managedEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedEnvironmentName", input) + } + + return nil +} + +// ValidateManagedEnvironmentID checks that 'input' can be parsed as a Managed Environment ID +func ValidateManagedEnvironmentID(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 := ParseManagedEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Environment ID +func (id ManagedEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.App/managedEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Environment ID +func (id ManagedEnvironmentId) 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("staticMicrosoftApp", "Microsoft.App", "Microsoft.App"), + resourceids.StaticSegment("staticManagedEnvironments", "managedEnvironments", "managedEnvironments"), + resourceids.UserSpecifiedSegment("managedEnvironmentName", "managedEnvironmentValue"), + } +} + +// String returns a human-readable description of this Managed Environment ID +func (id ManagedEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Environment Name: %q", id.ManagedEnvironmentName), + } + return fmt.Sprintf("Managed Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerapps/2024-03-01/usages/id_managedenvironment_test.go b/resource-manager/containerapps/2024-03-01/usages/id_managedenvironment_test.go new file mode 100644 index 00000000000..7939ad19415 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/id_managedenvironment_test.go @@ -0,0 +1,282 @@ +package usages + +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 = &ManagedEnvironmentId{} + +func TestNewManagedEnvironmentID(t *testing.T) { + id := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue") + + 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.ManagedEnvironmentName != "managedEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedEnvironmentName'", id.ManagedEnvironmentName, "managedEnvironmentValue") + } +} + +func TestFormatManagedEnvironmentID(t *testing.T) { + actual := NewManagedEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestParseManagedEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedEnvironmentId + }{ + { + // 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.App", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedEnvironmentName: "managedEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.App/managedEnvironments/managedEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe", + Expected: &ManagedEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedEnvironmentName: "mAnAgEdEnViRoNmEnTvAlUe", + }, + }, + { + // 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.aPp/mAnAgEdEnViRoNmEnTs/mAnAgEdEnViRoNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedEnvironmentName != v.Expected.ManagedEnvironmentName { + t.Fatalf("Expected %q but got %q for ManagedEnvironmentName", v.Expected.ManagedEnvironmentName, actual.ManagedEnvironmentName) + } + + } +} + +func TestSegmentsForManagedEnvironmentId(t *testing.T) { + segments := ManagedEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedEnvironmentId 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/containerapps/2024-03-01/usages/method_list.go b/resource-manager/containerapps/2024-03-01/usages/method_list.go new file mode 100644 index 00000000000..efe2516e27a --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/method_list.go @@ -0,0 +1,91 @@ +package usages + +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 *[]Usage +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +// List ... +func (c UsagesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `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 UsagesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UsagesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate UsageOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Usage, 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/containerapps/2024-03-01/usages/method_managedenvironmentusageslist.go b/resource-manager/containerapps/2024-03-01/usages/method_managedenvironmentusageslist.go new file mode 100644 index 00000000000..c9f8969f3d7 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/method_managedenvironmentusageslist.go @@ -0,0 +1,91 @@ +package usages + +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 ManagedEnvironmentUsagesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ManagedEnvironmentUsagesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +// ManagedEnvironmentUsagesList ... +func (c UsagesClient) ManagedEnvironmentUsagesList(ctx context.Context, id ManagedEnvironmentId) (result ManagedEnvironmentUsagesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagedEnvironmentUsagesListComplete retrieves all the results into a single object +func (c UsagesClient) ManagedEnvironmentUsagesListComplete(ctx context.Context, id ManagedEnvironmentId) (ManagedEnvironmentUsagesListCompleteResult, error) { + return c.ManagedEnvironmentUsagesListCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ManagedEnvironmentUsagesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UsagesClient) ManagedEnvironmentUsagesListCompleteMatchingPredicate(ctx context.Context, id ManagedEnvironmentId, predicate UsageOperationPredicate) (result ManagedEnvironmentUsagesListCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ManagedEnvironmentUsagesList(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 = ManagedEnvironmentUsagesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerapps/2024-03-01/usages/model_usage.go b/resource-manager/containerapps/2024-03-01/usages/model_usage.go new file mode 100644 index 00000000000..3505a296b40 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/model_usage.go @@ -0,0 +1,11 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + CurrentValue float64 `json:"currentValue"` + Limit float64 `json:"limit"` + Name UsageName `json:"name"` + Unit UsageUnit `json:"unit"` +} diff --git a/resource-manager/containerapps/2024-03-01/usages/model_usagename.go b/resource-manager/containerapps/2024-03-01/usages/model_usagename.go new file mode 100644 index 00000000000..ff2d9cbdd3e --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/model_usagename.go @@ -0,0 +1,9 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerapps/2024-03-01/usages/predicates.go b/resource-manager/containerapps/2024-03-01/usages/predicates.go new file mode 100644 index 00000000000..48590d8b9f6 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/predicates.go @@ -0,0 +1,22 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageOperationPredicate struct { + CurrentValue *float64 + Limit *float64 +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.CurrentValue != nil && *p.CurrentValue != input.CurrentValue { + return false + } + + if p.Limit != nil && *p.Limit != input.Limit { + return false + } + + return true +} diff --git a/resource-manager/containerapps/2024-03-01/usages/version.go b/resource-manager/containerapps/2024-03-01/usages/version.go new file mode 100644 index 00000000000..8065341ea18 --- /dev/null +++ b/resource-manager/containerapps/2024-03-01/usages/version.go @@ -0,0 +1,12 @@ +package usages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-03-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/usages/%s", defaultApiVersion) +} diff --git a/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go b/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go index 40046682a18..e17dc212836 100644 --- a/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go +++ b/resource-manager/datafactory/2018-06-01/credentials/model_managedidentitycredential.go @@ -11,7 +11,7 @@ import ( var _ Credential = ManagedIdentityCredential{} type ManagedIdentityCredential struct { - TypeProperties ManagedIdentityTypeProperties `json:"typeProperties"` + TypeProperties *ManagedIdentityTypeProperties `json:"typeProperties,omitempty"` // Fields inherited from Credential Annotations *[]interface{} `json:"annotations,omitempty"` diff --git a/resource-manager/datafactory/2018-06-01/pipelines/constants.go b/resource-manager/datafactory/2018-06-01/pipelines/constants.go index 8bb7c18bf2c..92e138572b5 100644 --- a/resource-manager/datafactory/2018-06-01/pipelines/constants.go +++ b/resource-manager/datafactory/2018-06-01/pipelines/constants.go @@ -1203,47 +1203,6 @@ func parseScriptActivityParameterType(input string) (*ScriptActivityParameterTyp return &out, nil } -type ScriptType string - -const ( - ScriptTypeNonQuery ScriptType = "NonQuery" - ScriptTypeQuery ScriptType = "Query" -) - -func PossibleValuesForScriptType() []string { - return []string{ - string(ScriptTypeNonQuery), - string(ScriptTypeQuery), - } -} - -func (s *ScriptType) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseScriptType(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseScriptType(input string) (*ScriptType, error) { - vals := map[string]ScriptType{ - "nonquery": ScriptTypeNonQuery, - "query": ScriptTypeQuery, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := ScriptType(input) - return &out, nil -} - type SparkConfigurationReferenceType string const ( diff --git a/resource-manager/datafactory/2018-06-01/pipelines/model_scriptactivityscriptblock.go b/resource-manager/datafactory/2018-06-01/pipelines/model_scriptactivityscriptblock.go index 96f83b7e211..7d0d211b08d 100644 --- a/resource-manager/datafactory/2018-06-01/pipelines/model_scriptactivityscriptblock.go +++ b/resource-manager/datafactory/2018-06-01/pipelines/model_scriptactivityscriptblock.go @@ -6,5 +6,5 @@ package pipelines type ScriptActivityScriptBlock struct { Parameters *[]ScriptActivityParameter `json:"parameters,omitempty"` Text interface{} `json:"text"` - Type ScriptType `json:"type"` + Type interface{} `json:"type"` } diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/README.md b/resource-manager/dataprotection/2024-04-01/azurebackupjob/README.md new file mode 100644 index 00000000000..4c8f6f8f127 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/README.md @@ -0,0 +1,64 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/azurebackupjob` Documentation + +The `azurebackupjob` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/azurebackupjob" +``` + + +### Client Initialization + +```go +client := azurebackupjob.NewAzureBackupJobClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AzureBackupJobClient.ExportJobsOperationResultGet` + +```go +ctx := context.TODO() +id := azurebackupjob.NewOperationIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "operationIdValue") + +read, err := client.ExportJobsOperationResultGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AzureBackupJobClient.ExportJobsTrigger` + +```go +ctx := context.TODO() +id := azurebackupjob.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +if err := client.ExportJobsTriggerThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AzureBackupJobClient.JobsGet` + +```go +ctx := context.TODO() +id := azurebackupjob.NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "jobIdValue") + +read, err := client.JobsGet(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/dataprotection/2024-04-01/azurebackupjob/client.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/client.go new file mode 100644 index 00000000000..11ba06b263b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/client.go @@ -0,0 +1,26 @@ +package azurebackupjob + +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 AzureBackupJobClient struct { + Client *resourcemanager.Client +} + +func NewAzureBackupJobClientWithBaseURI(sdkApi sdkEnv.Api) (*AzureBackupJobClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "azurebackupjob", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AzureBackupJobClient: %+v", err) + } + + return &AzureBackupJobClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob.go new file mode 100644 index 00000000000..1089c3fd6d4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob.go @@ -0,0 +1,139 @@ +package azurebackupjob + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupJobId{}) +} + +var _ resourceids.ResourceId = &BackupJobId{} + +// BackupJobId is a struct representing the Resource ID for a Backup Job +type BackupJobId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + JobId string +} + +// NewBackupJobID returns a new BackupJobId struct +func NewBackupJobID(subscriptionId string, resourceGroupName string, backupVaultName string, jobId string) BackupJobId { + return BackupJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + JobId: jobId, + } +} + +// ParseBackupJobID parses 'input' into a BackupJobId +func ParseBackupJobID(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupJobIDInsensitively parses 'input' case-insensitively into a BackupJobId +// note: this method should only be used for API response data and not user input +func ParseBackupJobIDInsensitively(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.JobId, ok = input.Parsed["jobId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobId", input) + } + + return nil +} + +// ValidateBackupJobID checks that 'input' can be parsed as a Backup Job ID +func ValidateBackupJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Job ID +func (id BackupJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.JobId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Job ID +func (id BackupJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.UserSpecifiedSegment("jobId", "jobIdValue"), + } +} + +// String returns a human-readable description of this Backup Job ID +func (id BackupJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Job: %q", id.JobId), + } + return fmt.Sprintf("Backup Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob_test.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob_test.go new file mode 100644 index 00000000000..9c7c959d6a9 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupjob_test.go @@ -0,0 +1,327 @@ +package azurebackupjob + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupJobId{} + +func TestNewBackupJobID(t *testing.T) { + id := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "jobIdValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.JobId != "jobIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'JobId'", id.JobId, "jobIdValue") + } +} + +func TestFormatBackupJobID(t *testing.T) { + actual := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "jobIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/jobIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/jobIdValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + JobId: "jobIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/jobIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.JobId != v.Expected.JobId { + t.Fatalf("Expected %q but got %q for JobId", v.Expected.JobId, actual.JobId) + } + + } +} + +func TestParseBackupJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/jobIdValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + JobId: "jobIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/jobIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPjObS/jObIdVaLuE", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + JobId: "jObIdVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPjObS/jObIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.JobId != v.Expected.JobId { + t.Fatalf("Expected %q but got %q for JobId", v.Expected.JobId, actual.JobId) + } + + } +} + +func TestSegmentsForBackupJobId(t *testing.T) { + segments := BackupJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault.go new file mode 100644 index 00000000000..d0675f57728 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault.go @@ -0,0 +1,130 @@ +package azurebackupjob + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault_test.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault_test.go new file mode 100644 index 00000000000..0caa9458465 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_backupvault_test.go @@ -0,0 +1,282 @@ +package azurebackupjob + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/dataprotection/2024-04-01/azurebackupjob/id_operationid.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_operationid.go new file mode 100644 index 00000000000..bed20827391 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_operationid.go @@ -0,0 +1,140 @@ +package azurebackupjob + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&OperationIdId{}) +} + +var _ resourceids.ResourceId = &OperationIdId{} + +// OperationIdId is a struct representing the Resource ID for a Operation Id +type OperationIdId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + OperationId string +} + +// NewOperationIdID returns a new OperationIdId struct +func NewOperationIdID(subscriptionId string, resourceGroupName string, backupVaultName string, operationId string) OperationIdId { + return OperationIdId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + OperationId: operationId, + } +} + +// ParseOperationIdID parses 'input' into a OperationIdId +func ParseOperationIdID(input string) (*OperationIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&OperationIdId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OperationIdId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOperationIdIDInsensitively parses 'input' case-insensitively into a OperationIdId +// note: this method should only be used for API response data and not user input +func ParseOperationIdIDInsensitively(input string) (*OperationIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&OperationIdId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OperationIdId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OperationIdId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateOperationIdID checks that 'input' can be parsed as a Operation Id ID +func ValidateOperationIdID(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 := ParseOperationIdID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Operation Id ID +func (id OperationIdId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupJobs/operations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Operation Id ID +func (id OperationIdId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.StaticSegment("staticOperations", "operations", "operations"), + resourceids.UserSpecifiedSegment("operationId", "operationIdValue"), + } +} + +// String returns a human-readable description of this Operation Id ID +func (id OperationIdId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Operation Id (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_operationid_test.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_operationid_test.go new file mode 100644 index 00000000000..3b4d903efd0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/id_operationid_test.go @@ -0,0 +1,342 @@ +package azurebackupjob + +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 = &OperationIdId{} + +func TestNewOperationIdID(t *testing.T) { + id := NewOperationIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "operationIdValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.OperationId != "operationIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationIdValue") + } +} + +func TestFormatOperationIdID(t *testing.T) { + actual := NewOperationIdID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "operationIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/operations/operationIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOperationIdID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OperationIdId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/operations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/operations/operationIdValue", + Expected: &OperationIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/operations/operationIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOperationIdID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseOperationIdIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OperationIdId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPjObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/operations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPjObS/oPeRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/operations/operationIdValue", + Expected: &OperationIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupJobs/operations/operationIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPjObS/oPeRaTiOnS/oPeRaTiOnIdVaLuE", + Expected: &OperationIdId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + OperationId: "oPeRaTiOnIdVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPjObS/oPeRaTiOnS/oPeRaTiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOperationIdIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForOperationIdId(t *testing.T) { + segments := OperationIdId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OperationIdId 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/dataprotection/2024-04-01/azurebackupjob/method_exportjobsoperationresultget.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_exportjobsoperationresultget.go new file mode 100644 index 00000000000..9f61784cc45 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_exportjobsoperationresultget.go @@ -0,0 +1,55 @@ +package azurebackupjob + +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 ExportJobsOperationResultGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExportJobsResult +} + +// ExportJobsOperationResultGet ... +func (c AzureBackupJobClient) ExportJobsOperationResultGet(ctx context.Context, id OperationIdId) (result ExportJobsOperationResultGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExportJobsResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_exportjobstrigger.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_exportjobstrigger.go new file mode 100644 index 00000000000..bd466398f8f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_exportjobstrigger.go @@ -0,0 +1,70 @@ +package azurebackupjob + +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 ExportJobsTriggerOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ExportJobsTrigger ... +func (c AzureBackupJobClient) ExportJobsTrigger(ctx context.Context, id BackupVaultId) (result ExportJobsTriggerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/exportBackupJobs", 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 +} + +// ExportJobsTriggerThenPoll performs ExportJobsTrigger then polls until it's completed +func (c AzureBackupJobClient) ExportJobsTriggerThenPoll(ctx context.Context, id BackupVaultId) error { + result, err := c.ExportJobsTrigger(ctx, id) + if err != nil { + return fmt.Errorf("performing ExportJobsTrigger: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExportJobsTrigger: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_jobsget.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_jobsget.go new file mode 100644 index 00000000000..d895ee2d205 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/method_jobsget.go @@ -0,0 +1,54 @@ +package azurebackupjob + +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 JobsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureBackupJobResource +} + +// JobsGet ... +func (c AzureBackupJobClient) JobsGet(ctx context.Context, id BackupJobId) (result JobsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureBackupJobResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjob.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjob.go new file mode 100644 index 00000000000..cdd1d824b08 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjob.go @@ -0,0 +1,65 @@ +package azurebackupjob + +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 AzureBackupJob struct { + ActivityID string `json:"activityID"` + BackupInstanceFriendlyName string `json:"backupInstanceFriendlyName"` + BackupInstanceId *string `json:"backupInstanceId,omitempty"` + DataSourceId string `json:"dataSourceId"` + DataSourceLocation string `json:"dataSourceLocation"` + DataSourceName string `json:"dataSourceName"` + DataSourceSetName *string `json:"dataSourceSetName,omitempty"` + DataSourceType string `json:"dataSourceType"` + DestinationDataStoreName *string `json:"destinationDataStoreName,omitempty"` + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ErrorDetails *[]UserFacingError `json:"errorDetails,omitempty"` + Etag *string `json:"etag,omitempty"` + ExtendedInfo *JobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered bool `json:"isUserTriggered"` + Operation string `json:"operation"` + OperationCategory string `json:"operationCategory"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ProgressEnabled bool `json:"progressEnabled"` + ProgressUrl *string `json:"progressUrl,omitempty"` + RehydrationPriority *string `json:"rehydrationPriority,omitempty"` + RestoreType *string `json:"restoreType,omitempty"` + SourceDataStoreName *string `json:"sourceDataStoreName,omitempty"` + SourceResourceGroup string `json:"sourceResourceGroup"` + SourceSubscriptionID string `json:"sourceSubscriptionID"` + StartTime string `json:"startTime"` + Status string `json:"status"` + SubscriptionId string `json:"subscriptionId"` + SupportedActions []string `json:"supportedActions"` + VaultName string `json:"vaultName"` +} + +func (o *AzureBackupJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureBackupJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureBackupJob) GetStartTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureBackupJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjobresource.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjobresource.go new file mode 100644 index 00000000000..45faef86221 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_azurebackupjobresource.go @@ -0,0 +1,16 @@ +package azurebackupjob + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupJobResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureBackupJob `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_exportjobsresult.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_exportjobsresult.go new file mode 100644 index 00000000000..75c7ef5aad4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_exportjobsresult.go @@ -0,0 +1,11 @@ +package azurebackupjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExportJobsResult struct { + BlobSasKey *string `json:"blobSasKey,omitempty"` + BlobUrl *string `json:"blobUrl,omitempty"` + ExcelFileBlobSasKey *string `json:"excelFileBlobSasKey,omitempty"` + ExcelFileBlobUrl *string `json:"excelFileBlobUrl,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_innererror.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_innererror.go new file mode 100644 index 00000000000..a44d4bdfa57 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_innererror.go @@ -0,0 +1,10 @@ +package azurebackupjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InnerError struct { + AdditionalInfo *map[string]string `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + EmbeddedInnerError *InnerError `json:"embeddedInnerError,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobextendedinfo.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobextendedinfo.go new file mode 100644 index 00000000000..9c0edd02f99 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobextendedinfo.go @@ -0,0 +1,15 @@ +package azurebackupjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobExtendedInfo struct { + AdditionalDetails *map[string]string `json:"additionalDetails,omitempty"` + BackupInstanceState *string `json:"backupInstanceState,omitempty"` + DataTransferredInBytes *float64 `json:"dataTransferredInBytes,omitempty"` + RecoveryDestination *string `json:"recoveryDestination,omitempty"` + SourceRecoverPoint *RestoreJobRecoveryPointDetails `json:"sourceRecoverPoint,omitempty"` + SubTasks *[]JobSubTask `json:"subTasks,omitempty"` + TargetRecoverPoint *RestoreJobRecoveryPointDetails `json:"targetRecoverPoint,omitempty"` + WarningDetails *[]UserFacingWarningDetail `json:"warningDetails,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobsubtask.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobsubtask.go new file mode 100644 index 00000000000..9d4f15e734d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_jobsubtask.go @@ -0,0 +1,12 @@ +package azurebackupjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobSubTask struct { + AdditionalDetails *map[string]string `json:"additionalDetails,omitempty"` + TaskId int64 `json:"taskId"` + TaskName string `json:"taskName"` + TaskProgress *string `json:"taskProgress,omitempty"` + TaskStatus string `json:"taskStatus"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_restorejobrecoverypointdetails.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_restorejobrecoverypointdetails.go new file mode 100644 index 00000000000..3737e75b44e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_restorejobrecoverypointdetails.go @@ -0,0 +1,27 @@ +package azurebackupjob + +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 RestoreJobRecoveryPointDetails struct { + RecoveryPointID *string `json:"recoveryPointID,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` +} + +func (o *RestoreJobRecoveryPointDetails) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoreJobRecoveryPointDetails) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingerror.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingerror.go new file mode 100644 index 00000000000..0358f4179da --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingerror.go @@ -0,0 +1,16 @@ +package azurebackupjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingError struct { + Code *string `json:"code,omitempty"` + Details *[]UserFacingError `json:"details,omitempty"` + InnerError *InnerError `json:"innerError,omitempty"` + IsRetryable *bool `json:"isRetryable,omitempty"` + IsUserError *bool `json:"isUserError,omitempty"` + Message *string `json:"message,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + RecommendedAction *[]string `json:"recommendedAction,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingwarningdetail.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingwarningdetail.go new file mode 100644 index 00000000000..f943b79da1d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/model_userfacingwarningdetail.go @@ -0,0 +1,9 @@ +package azurebackupjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingWarningDetail struct { + ResourceName *string `json:"resourceName,omitempty"` + Warning UserFacingError `json:"warning"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjob/version.go b/resource-manager/dataprotection/2024-04-01/azurebackupjob/version.go new file mode 100644 index 00000000000..755d4df5bdb --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjob/version.go @@ -0,0 +1,12 @@ +package azurebackupjob + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/azurebackupjob/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/README.md b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/README.md new file mode 100644 index 00000000000..b4b8013b214 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/azurebackupjobs` Documentation + +The `azurebackupjobs` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/azurebackupjobs" +``` + + +### Client Initialization + +```go +client := azurebackupjobs.NewAzureBackupJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AzureBackupJobsClient.JobsList` + +```go +ctx := context.TODO() +id := azurebackupjobs.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +// alternatively `client.JobsList(ctx, id)` can be used to do batched pagination +items, err := client.JobsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/client.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/client.go new file mode 100644 index 00000000000..9cb5bb85556 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/client.go @@ -0,0 +1,26 @@ +package azurebackupjobs + +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 AzureBackupJobsClient struct { + Client *resourcemanager.Client +} + +func NewAzureBackupJobsClientWithBaseURI(sdkApi sdkEnv.Api) (*AzureBackupJobsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "azurebackupjobs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AzureBackupJobsClient: %+v", err) + } + + return &AzureBackupJobsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault.go new file mode 100644 index 00000000000..3d797b731f7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault.go @@ -0,0 +1,130 @@ +package azurebackupjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault_test.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault_test.go new file mode 100644 index 00000000000..91bb4424318 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/id_backupvault_test.go @@ -0,0 +1,282 @@ +package azurebackupjobs + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/dataprotection/2024-04-01/azurebackupjobs/method_jobslist.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/method_jobslist.go new file mode 100644 index 00000000000..095d72f8837 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/method_jobslist.go @@ -0,0 +1,91 @@ +package azurebackupjobs + +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 JobsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureBackupJobResource +} + +type JobsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AzureBackupJobResource +} + +// JobsList ... +func (c AzureBackupJobsClient) JobsList(ctx context.Context, id BackupVaultId) (result JobsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backupJobs", 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 *[]AzureBackupJobResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// JobsListComplete retrieves all the results into a single object +func (c AzureBackupJobsClient) JobsListComplete(ctx context.Context, id BackupVaultId) (JobsListCompleteResult, error) { + return c.JobsListCompleteMatchingPredicate(ctx, id, AzureBackupJobResourceOperationPredicate{}) +} + +// JobsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AzureBackupJobsClient) JobsListCompleteMatchingPredicate(ctx context.Context, id BackupVaultId, predicate AzureBackupJobResourceOperationPredicate) (result JobsListCompleteResult, err error) { + items := make([]AzureBackupJobResource, 0) + + resp, err := c.JobsList(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 = JobsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjob.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjob.go new file mode 100644 index 00000000000..c92a5895788 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjob.go @@ -0,0 +1,65 @@ +package azurebackupjobs + +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 AzureBackupJob struct { + ActivityID string `json:"activityID"` + BackupInstanceFriendlyName string `json:"backupInstanceFriendlyName"` + BackupInstanceId *string `json:"backupInstanceId,omitempty"` + DataSourceId string `json:"dataSourceId"` + DataSourceLocation string `json:"dataSourceLocation"` + DataSourceName string `json:"dataSourceName"` + DataSourceSetName *string `json:"dataSourceSetName,omitempty"` + DataSourceType string `json:"dataSourceType"` + DestinationDataStoreName *string `json:"destinationDataStoreName,omitempty"` + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ErrorDetails *[]UserFacingError `json:"errorDetails,omitempty"` + Etag *string `json:"etag,omitempty"` + ExtendedInfo *JobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered bool `json:"isUserTriggered"` + Operation string `json:"operation"` + OperationCategory string `json:"operationCategory"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ProgressEnabled bool `json:"progressEnabled"` + ProgressUrl *string `json:"progressUrl,omitempty"` + RehydrationPriority *string `json:"rehydrationPriority,omitempty"` + RestoreType *string `json:"restoreType,omitempty"` + SourceDataStoreName *string `json:"sourceDataStoreName,omitempty"` + SourceResourceGroup string `json:"sourceResourceGroup"` + SourceSubscriptionID string `json:"sourceSubscriptionID"` + StartTime string `json:"startTime"` + Status string `json:"status"` + SubscriptionId string `json:"subscriptionId"` + SupportedActions []string `json:"supportedActions"` + VaultName string `json:"vaultName"` +} + +func (o *AzureBackupJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureBackupJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureBackupJob) GetStartTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureBackupJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjobresource.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjobresource.go new file mode 100644 index 00000000000..17c72e55e47 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_azurebackupjobresource.go @@ -0,0 +1,16 @@ +package azurebackupjobs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupJobResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureBackupJob `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_innererror.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_innererror.go new file mode 100644 index 00000000000..323f65bc431 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_innererror.go @@ -0,0 +1,10 @@ +package azurebackupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InnerError struct { + AdditionalInfo *map[string]string `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + EmbeddedInnerError *InnerError `json:"embeddedInnerError,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobextendedinfo.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobextendedinfo.go new file mode 100644 index 00000000000..2b210b62683 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobextendedinfo.go @@ -0,0 +1,15 @@ +package azurebackupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobExtendedInfo struct { + AdditionalDetails *map[string]string `json:"additionalDetails,omitempty"` + BackupInstanceState *string `json:"backupInstanceState,omitempty"` + DataTransferredInBytes *float64 `json:"dataTransferredInBytes,omitempty"` + RecoveryDestination *string `json:"recoveryDestination,omitempty"` + SourceRecoverPoint *RestoreJobRecoveryPointDetails `json:"sourceRecoverPoint,omitempty"` + SubTasks *[]JobSubTask `json:"subTasks,omitempty"` + TargetRecoverPoint *RestoreJobRecoveryPointDetails `json:"targetRecoverPoint,omitempty"` + WarningDetails *[]UserFacingWarningDetail `json:"warningDetails,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobsubtask.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobsubtask.go new file mode 100644 index 00000000000..0f42da0bc24 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_jobsubtask.go @@ -0,0 +1,12 @@ +package azurebackupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobSubTask struct { + AdditionalDetails *map[string]string `json:"additionalDetails,omitempty"` + TaskId int64 `json:"taskId"` + TaskName string `json:"taskName"` + TaskProgress *string `json:"taskProgress,omitempty"` + TaskStatus string `json:"taskStatus"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_restorejobrecoverypointdetails.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_restorejobrecoverypointdetails.go new file mode 100644 index 00000000000..569a995bb39 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_restorejobrecoverypointdetails.go @@ -0,0 +1,27 @@ +package azurebackupjobs + +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 RestoreJobRecoveryPointDetails struct { + RecoveryPointID *string `json:"recoveryPointID,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` +} + +func (o *RestoreJobRecoveryPointDetails) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoreJobRecoveryPointDetails) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingerror.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingerror.go new file mode 100644 index 00000000000..562e9fe4e79 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingerror.go @@ -0,0 +1,16 @@ +package azurebackupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingError struct { + Code *string `json:"code,omitempty"` + Details *[]UserFacingError `json:"details,omitempty"` + InnerError *InnerError `json:"innerError,omitempty"` + IsRetryable *bool `json:"isRetryable,omitempty"` + IsUserError *bool `json:"isUserError,omitempty"` + Message *string `json:"message,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + RecommendedAction *[]string `json:"recommendedAction,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingwarningdetail.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingwarningdetail.go new file mode 100644 index 00000000000..5fdf9d22cc7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/model_userfacingwarningdetail.go @@ -0,0 +1,9 @@ +package azurebackupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingWarningDetail struct { + ResourceName *string `json:"resourceName,omitempty"` + Warning UserFacingError `json:"warning"` +} diff --git a/resource-manager/dataprotection/2024-04-01/azurebackupjobs/predicates.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/predicates.go new file mode 100644 index 00000000000..5f79648ba7d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/predicates.go @@ -0,0 +1,27 @@ +package azurebackupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupJobResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AzureBackupJobResourceOperationPredicate) Matches(input AzureBackupJobResource) 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/dataprotection/2024-04-01/azurebackupjobs/version.go b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/version.go new file mode 100644 index 00000000000..382479f7221 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/azurebackupjobs/version.go @@ -0,0 +1,12 @@ +package azurebackupjobs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/azurebackupjobs/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/README.md b/resource-manager/dataprotection/2024-04-01/backupinstances/README.md new file mode 100644 index 00000000000..4601327dcd8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/README.md @@ -0,0 +1,276 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backupinstances` Documentation + +The `backupinstances` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/backupinstances" +``` + + +### Client Initialization + +```go +client := backupinstances.NewBackupInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupInstancesClient.AdhocBackup` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.TriggerBackupRequest{ + // ... +} + + +if err := client.AdhocBackupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.BackupInstanceResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, backupinstances.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.Delete` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +if err := client.DeleteThenPoll(ctx, id, backupinstances.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.Get` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +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: `BackupInstancesClient.List` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +// 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: `BackupInstancesClient.ResumeBackups` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +if err := client.ResumeBackupsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.ResumeProtection` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +if err := client.ResumeProtectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.StopProtection` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.StopProtectionRequest{ + // ... +} + + +if err := client.StopProtectionThenPoll(ctx, id, payload, backupinstances.DefaultStopProtectionOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.SuspendBackups` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.SuspendBackupRequest{ + // ... +} + + +if err := client.SuspendBackupsThenPoll(ctx, id, payload, backupinstances.DefaultSuspendBackupsOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.SyncBackupInstance` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.SyncBackupInstanceRequest{ + // ... +} + + +if err := client.SyncBackupInstanceThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.TriggerCrossRegionRestore` + +```go +ctx := context.TODO() +id := backupinstances.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +payload := backupinstances.CrossRegionRestoreRequestObject{ + // ... +} + + +if err := client.TriggerCrossRegionRestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.TriggerRehydrate` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.AzureBackupRehydrationRequest{ + // ... +} + + +if err := client.TriggerRehydrateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.TriggerRestore` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.AzureBackupRestoreRequest{ + // ... +} + + +if err := client.TriggerRestoreThenPoll(ctx, id, payload, backupinstances.DefaultTriggerRestoreOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.ValidateCrossRegionRestore` + +```go +ctx := context.TODO() +id := backupinstances.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +payload := backupinstances.ValidateCrossRegionRestoreRequestObject{ + // ... +} + + +if err := client.ValidateCrossRegionRestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.ValidateForBackup` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +payload := backupinstances.ValidateForBackupRequest{ + // ... +} + + +if err := client.ValidateForBackupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupInstancesClient.ValidateForRestore` + +```go +ctx := context.TODO() +id := backupinstances.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := backupinstances.ValidateRestoreRequestObject{ + // ... +} + + +if err := client.ValidateForRestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/client.go b/resource-manager/dataprotection/2024-04-01/backupinstances/client.go new file mode 100644 index 00000000000..9e37fa3fed5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/client.go @@ -0,0 +1,26 @@ +package backupinstances + +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 BackupInstancesClient struct { + Client *resourcemanager.Client +} + +func NewBackupInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupInstancesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "backupinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupInstancesClient: %+v", err) + } + + return &BackupInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/constants.go b/resource-manager/dataprotection/2024-04-01/backupinstances/constants.go new file mode 100644 index 00000000000..6ea153cb952 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/constants.go @@ -0,0 +1,594 @@ +package backupinstances + +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 CurrentProtectionState string + +const ( + CurrentProtectionStateBackupSchedulesSuspended CurrentProtectionState = "BackupSchedulesSuspended" + CurrentProtectionStateConfiguringProtection CurrentProtectionState = "ConfiguringProtection" + CurrentProtectionStateConfiguringProtectionFailed CurrentProtectionState = "ConfiguringProtectionFailed" + CurrentProtectionStateInvalid CurrentProtectionState = "Invalid" + CurrentProtectionStateNotProtected CurrentProtectionState = "NotProtected" + CurrentProtectionStateProtectionConfigured CurrentProtectionState = "ProtectionConfigured" + CurrentProtectionStateProtectionError CurrentProtectionState = "ProtectionError" + CurrentProtectionStateProtectionStopped CurrentProtectionState = "ProtectionStopped" + CurrentProtectionStateRetentionSchedulesSuspended CurrentProtectionState = "RetentionSchedulesSuspended" + CurrentProtectionStateSoftDeleted CurrentProtectionState = "SoftDeleted" + CurrentProtectionStateSoftDeleting CurrentProtectionState = "SoftDeleting" + CurrentProtectionStateUpdatingProtection CurrentProtectionState = "UpdatingProtection" +) + +func PossibleValuesForCurrentProtectionState() []string { + return []string{ + string(CurrentProtectionStateBackupSchedulesSuspended), + string(CurrentProtectionStateConfiguringProtection), + string(CurrentProtectionStateConfiguringProtectionFailed), + string(CurrentProtectionStateInvalid), + string(CurrentProtectionStateNotProtected), + string(CurrentProtectionStateProtectionConfigured), + string(CurrentProtectionStateProtectionError), + string(CurrentProtectionStateProtectionStopped), + string(CurrentProtectionStateRetentionSchedulesSuspended), + string(CurrentProtectionStateSoftDeleted), + string(CurrentProtectionStateSoftDeleting), + string(CurrentProtectionStateUpdatingProtection), + } +} + +func (s *CurrentProtectionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCurrentProtectionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCurrentProtectionState(input string) (*CurrentProtectionState, error) { + vals := map[string]CurrentProtectionState{ + "backupschedulessuspended": CurrentProtectionStateBackupSchedulesSuspended, + "configuringprotection": CurrentProtectionStateConfiguringProtection, + "configuringprotectionfailed": CurrentProtectionStateConfiguringProtectionFailed, + "invalid": CurrentProtectionStateInvalid, + "notprotected": CurrentProtectionStateNotProtected, + "protectionconfigured": CurrentProtectionStateProtectionConfigured, + "protectionerror": CurrentProtectionStateProtectionError, + "protectionstopped": CurrentProtectionStateProtectionStopped, + "retentionschedulessuspended": CurrentProtectionStateRetentionSchedulesSuspended, + "softdeleted": CurrentProtectionStateSoftDeleted, + "softdeleting": CurrentProtectionStateSoftDeleting, + "updatingprotection": CurrentProtectionStateUpdatingProtection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CurrentProtectionState(input) + return &out, nil +} + +type DataStoreTypes string + +const ( + DataStoreTypesArchiveStore DataStoreTypes = "ArchiveStore" + DataStoreTypesOperationalStore DataStoreTypes = "OperationalStore" + DataStoreTypesVaultStore DataStoreTypes = "VaultStore" +) + +func PossibleValuesForDataStoreTypes() []string { + return []string{ + string(DataStoreTypesArchiveStore), + string(DataStoreTypesOperationalStore), + string(DataStoreTypesVaultStore), + } +} + +func (s *DataStoreTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataStoreTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataStoreTypes(input string) (*DataStoreTypes, error) { + vals := map[string]DataStoreTypes{ + "archivestore": DataStoreTypesArchiveStore, + "operationalstore": DataStoreTypesOperationalStore, + "vaultstore": DataStoreTypesVaultStore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataStoreTypes(input) + return &out, nil +} + +type ExistingResourcePolicy string + +const ( + ExistingResourcePolicyPatch ExistingResourcePolicy = "Patch" + ExistingResourcePolicySkip ExistingResourcePolicy = "Skip" +) + +func PossibleValuesForExistingResourcePolicy() []string { + return []string{ + string(ExistingResourcePolicyPatch), + string(ExistingResourcePolicySkip), + } +} + +func (s *ExistingResourcePolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExistingResourcePolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExistingResourcePolicy(input string) (*ExistingResourcePolicy, error) { + vals := map[string]ExistingResourcePolicy{ + "patch": ExistingResourcePolicyPatch, + "skip": ExistingResourcePolicySkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExistingResourcePolicy(input) + return &out, nil +} + +type PersistentVolumeRestoreMode string + +const ( + PersistentVolumeRestoreModeRestoreWithVolumeData PersistentVolumeRestoreMode = "RestoreWithVolumeData" + PersistentVolumeRestoreModeRestoreWithoutVolumeData PersistentVolumeRestoreMode = "RestoreWithoutVolumeData" +) + +func PossibleValuesForPersistentVolumeRestoreMode() []string { + return []string{ + string(PersistentVolumeRestoreModeRestoreWithVolumeData), + string(PersistentVolumeRestoreModeRestoreWithoutVolumeData), + } +} + +func (s *PersistentVolumeRestoreMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePersistentVolumeRestoreMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePersistentVolumeRestoreMode(input string) (*PersistentVolumeRestoreMode, error) { + vals := map[string]PersistentVolumeRestoreMode{ + "restorewithvolumedata": PersistentVolumeRestoreModeRestoreWithVolumeData, + "restorewithoutvolumedata": PersistentVolumeRestoreModeRestoreWithoutVolumeData, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PersistentVolumeRestoreMode(input) + return &out, nil +} + +type RecoveryOption string + +const ( + RecoveryOptionFailIfExists RecoveryOption = "FailIfExists" +) + +func PossibleValuesForRecoveryOption() []string { + return []string{ + string(RecoveryOptionFailIfExists), + } +} + +func (s *RecoveryOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryOption(input string) (*RecoveryOption, error) { + vals := map[string]RecoveryOption{ + "failifexists": RecoveryOptionFailIfExists, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryOption(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityInvalid RehydrationPriority = "Invalid" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityInvalid), + string(RehydrationPriorityStandard), + } +} + +func (s *RehydrationPriority) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRehydrationPriority(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "invalid": RehydrationPriorityInvalid, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} + +type ResourcePropertiesObjectType string + +const ( + ResourcePropertiesObjectTypeDefaultResourceProperties ResourcePropertiesObjectType = "DefaultResourceProperties" +) + +func PossibleValuesForResourcePropertiesObjectType() []string { + return []string{ + string(ResourcePropertiesObjectTypeDefaultResourceProperties), + } +} + +func (s *ResourcePropertiesObjectType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourcePropertiesObjectType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourcePropertiesObjectType(input string) (*ResourcePropertiesObjectType, error) { + vals := map[string]ResourcePropertiesObjectType{ + "defaultresourceproperties": ResourcePropertiesObjectTypeDefaultResourceProperties, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourcePropertiesObjectType(input) + return &out, nil +} + +type RestoreTargetLocationType string + +const ( + RestoreTargetLocationTypeAzureBlobs RestoreTargetLocationType = "AzureBlobs" + RestoreTargetLocationTypeAzureFiles RestoreTargetLocationType = "AzureFiles" + RestoreTargetLocationTypeInvalid RestoreTargetLocationType = "Invalid" +) + +func PossibleValuesForRestoreTargetLocationType() []string { + return []string{ + string(RestoreTargetLocationTypeAzureBlobs), + string(RestoreTargetLocationTypeAzureFiles), + string(RestoreTargetLocationTypeInvalid), + } +} + +func (s *RestoreTargetLocationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRestoreTargetLocationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRestoreTargetLocationType(input string) (*RestoreTargetLocationType, error) { + vals := map[string]RestoreTargetLocationType{ + "azureblobs": RestoreTargetLocationTypeAzureBlobs, + "azurefiles": RestoreTargetLocationTypeAzureFiles, + "invalid": RestoreTargetLocationTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreTargetLocationType(input) + return &out, nil +} + +type SecretStoreType string + +const ( + SecretStoreTypeAzureKeyVault SecretStoreType = "AzureKeyVault" + SecretStoreTypeInvalid SecretStoreType = "Invalid" +) + +func PossibleValuesForSecretStoreType() []string { + return []string{ + string(SecretStoreTypeAzureKeyVault), + string(SecretStoreTypeInvalid), + } +} + +func (s *SecretStoreType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecretStoreType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecretStoreType(input string) (*SecretStoreType, error) { + vals := map[string]SecretStoreType{ + "azurekeyvault": SecretStoreTypeAzureKeyVault, + "invalid": SecretStoreTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecretStoreType(input) + return &out, nil +} + +type SourceDataStoreType string + +const ( + SourceDataStoreTypeArchiveStore SourceDataStoreType = "ArchiveStore" + SourceDataStoreTypeOperationalStore SourceDataStoreType = "OperationalStore" + SourceDataStoreTypeSnapshotStore SourceDataStoreType = "SnapshotStore" + SourceDataStoreTypeVaultStore SourceDataStoreType = "VaultStore" +) + +func PossibleValuesForSourceDataStoreType() []string { + return []string{ + string(SourceDataStoreTypeArchiveStore), + string(SourceDataStoreTypeOperationalStore), + string(SourceDataStoreTypeSnapshotStore), + string(SourceDataStoreTypeVaultStore), + } +} + +func (s *SourceDataStoreType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceDataStoreType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceDataStoreType(input string) (*SourceDataStoreType, error) { + vals := map[string]SourceDataStoreType{ + "archivestore": SourceDataStoreTypeArchiveStore, + "operationalstore": SourceDataStoreTypeOperationalStore, + "snapshotstore": SourceDataStoreTypeSnapshotStore, + "vaultstore": SourceDataStoreTypeVaultStore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceDataStoreType(input) + return &out, nil +} + +type Status string + +const ( + StatusConfiguringProtection Status = "ConfiguringProtection" + StatusConfiguringProtectionFailed Status = "ConfiguringProtectionFailed" + StatusProtectionConfigured Status = "ProtectionConfigured" + StatusProtectionStopped Status = "ProtectionStopped" + StatusSoftDeleted Status = "SoftDeleted" + StatusSoftDeleting Status = "SoftDeleting" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusConfiguringProtection), + string(StatusConfiguringProtectionFailed), + string(StatusProtectionConfigured), + string(StatusProtectionStopped), + string(StatusSoftDeleted), + string(StatusSoftDeleting), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "configuringprotection": StatusConfiguringProtection, + "configuringprotectionfailed": StatusConfiguringProtectionFailed, + "protectionconfigured": StatusProtectionConfigured, + "protectionstopped": StatusProtectionStopped, + "softdeleted": StatusSoftDeleted, + "softdeleting": StatusSoftDeleting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} + +type SyncType string + +const ( + SyncTypeDefault SyncType = "Default" + SyncTypeForceResync SyncType = "ForceResync" +) + +func PossibleValuesForSyncType() []string { + return []string{ + string(SyncTypeDefault), + string(SyncTypeForceResync), + } +} + +func (s *SyncType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncType(input string) (*SyncType, error) { + vals := map[string]SyncType{ + "default": SyncTypeDefault, + "forceresync": SyncTypeForceResync, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncType(input) + return &out, nil +} + +type ValidationType string + +const ( + ValidationTypeDeepValidation ValidationType = "DeepValidation" + ValidationTypeShallowValidation ValidationType = "ShallowValidation" +) + +func PossibleValuesForValidationType() []string { + return []string{ + string(ValidationTypeDeepValidation), + string(ValidationTypeShallowValidation), + } +} + +func (s *ValidationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationType(input string) (*ValidationType, error) { + vals := map[string]ValidationType{ + "deepvalidation": ValidationTypeDeepValidation, + "shallowvalidation": ValidationTypeShallowValidation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationType(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance.go b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance.go new file mode 100644 index 00000000000..9120ff5c7b9 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance.go @@ -0,0 +1,139 @@ +package backupinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupInstanceId{}) +} + +var _ resourceids.ResourceId = &BackupInstanceId{} + +// BackupInstanceId is a struct representing the Resource ID for a Backup Instance +type BackupInstanceId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + BackupInstanceName string +} + +// NewBackupInstanceID returns a new BackupInstanceId struct +func NewBackupInstanceID(subscriptionId string, resourceGroupName string, backupVaultName string, backupInstanceName string) BackupInstanceId { + return BackupInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + BackupInstanceName: backupInstanceName, + } +} + +// ParseBackupInstanceID parses 'input' into a BackupInstanceId +func ParseBackupInstanceID(input string) (*BackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupInstanceIDInsensitively parses 'input' case-insensitively into a BackupInstanceId +// note: this method should only be used for API response data and not user input +func ParseBackupInstanceIDInsensitively(input string) (*BackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupInstanceId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.BackupInstanceName, ok = input.Parsed["backupInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupInstanceName", input) + } + + return nil +} + +// ValidateBackupInstanceID checks that 'input' can be parsed as a Backup Instance ID +func ValidateBackupInstanceID(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 := ParseBackupInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Instance ID +func (id BackupInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.BackupInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Instance ID +func (id BackupInstanceId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupInstances", "backupInstances", "backupInstances"), + resourceids.UserSpecifiedSegment("backupInstanceName", "backupInstanceValue"), + } +} + +// String returns a human-readable description of this Backup Instance ID +func (id BackupInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Backup Instance Name: %q", id.BackupInstanceName), + } + return fmt.Sprintf("Backup Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance_test.go b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance_test.go new file mode 100644 index 00000000000..96e082428e0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupinstance_test.go @@ -0,0 +1,327 @@ +package backupinstances + +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 = &BackupInstanceId{} + +func TestNewBackupInstanceID(t *testing.T) { + id := NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.BackupInstanceName != "backupInstanceValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupInstanceName'", id.BackupInstanceName, "backupInstanceValue") + } +} + +func TestFormatBackupInstanceID(t *testing.T) { + actual := NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + } +} + +func TestParseBackupInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + BackupInstanceName: "bAcKuPiNsTaNcEvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + } +} + +func TestSegmentsForBackupInstanceId(t *testing.T) { + segments := BackupInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupInstanceId 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/dataprotection/2024-04-01/backupinstances/id_backupvault.go b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupvault.go new file mode 100644 index 00000000000..3e2cc254429 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupvault.go @@ -0,0 +1,130 @@ +package backupinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupvault_test.go b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupvault_test.go new file mode 100644 index 00000000000..e1e44a13ba2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/id_backupvault_test.go @@ -0,0 +1,282 @@ +package backupinstances + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/dataprotection/2024-04-01/backupinstances/id_providerlocation.go b/resource-manager/dataprotection/2024-04-01/backupinstances/id_providerlocation.go new file mode 100644 index 00000000000..41446698550 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/id_providerlocation.go @@ -0,0 +1,130 @@ +package backupinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/id_providerlocation_test.go b/resource-manager/dataprotection/2024-04-01/backupinstances/id_providerlocation_test.go new file mode 100644 index 00000000000..db4acc43e43 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package backupinstances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_adhocbackup.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_adhocbackup.go new file mode 100644 index 00000000000..e9b23922bd5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_adhocbackup.go @@ -0,0 +1,75 @@ +package backupinstances + +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 AdhocBackupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationJobExtendedInfo +} + +// AdhocBackup ... +func (c BackupInstancesClient) AdhocBackup(ctx context.Context, id BackupInstanceId, input TriggerBackupRequest) (result AdhocBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", 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 +} + +// AdhocBackupThenPoll performs AdhocBackup then polls until it's completed +func (c BackupInstancesClient) AdhocBackupThenPoll(ctx context.Context, id BackupInstanceId, input TriggerBackupRequest) error { + result, err := c.AdhocBackup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing AdhocBackup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AdhocBackup: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_createorupdate.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_createorupdate.go new file mode 100644 index 00000000000..8c49d6a1b1d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_createorupdate.go @@ -0,0 +1,104 @@ +package backupinstances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupInstanceResource +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c BackupInstancesClient) CreateOrUpdate(ctx context.Context, id BackupInstanceId, input BackupInstanceResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c BackupInstancesClient) CreateOrUpdateThenPoll(ctx context.Context, id BackupInstanceId, input BackupInstanceResource, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_delete.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_delete.go new file mode 100644 index 00000000000..9505a3d9cf7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_delete.go @@ -0,0 +1,99 @@ +package backupinstances + +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 { + XMsAuthorizationAuxiliary *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c BackupInstancesClient) Delete(ctx context.Context, id BackupInstanceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 BackupInstancesClient) DeleteThenPoll(ctx context.Context, id BackupInstanceId, 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/dataprotection/2024-04-01/backupinstances/method_get.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_get.go new file mode 100644 index 00000000000..dc268db7fc1 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_get.go @@ -0,0 +1,54 @@ +package backupinstances + +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 *BackupInstanceResource +} + +// Get ... +func (c BackupInstancesClient) Get(ctx context.Context, id BackupInstanceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupInstanceResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_list.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_list.go new file mode 100644 index 00000000000..a0bc66781f3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_list.go @@ -0,0 +1,91 @@ +package backupinstances + +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 *[]BackupInstanceResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupInstanceResource +} + +// List ... +func (c BackupInstancesClient) List(ctx context.Context, id BackupVaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backupInstances", 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 *[]BackupInstanceResource `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 BackupInstancesClient) ListComplete(ctx context.Context, id BackupVaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, BackupInstanceResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id BackupVaultId, predicate BackupInstanceResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BackupInstanceResource, 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/dataprotection/2024-04-01/backupinstances/method_resumebackups.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_resumebackups.go new file mode 100644 index 00000000000..afecf4c1dbc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_resumebackups.go @@ -0,0 +1,70 @@ +package backupinstances + +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 ResumeBackupsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResumeBackups ... +func (c BackupInstancesClient) ResumeBackups(ctx context.Context, id BackupInstanceId) (result ResumeBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resumeBackups", 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 +} + +// ResumeBackupsThenPoll performs ResumeBackups then polls until it's completed +func (c BackupInstancesClient) ResumeBackupsThenPoll(ctx context.Context, id BackupInstanceId) error { + result, err := c.ResumeBackups(ctx, id) + if err != nil { + return fmt.Errorf("performing ResumeBackups: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResumeBackups: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_resumeprotection.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_resumeprotection.go new file mode 100644 index 00000000000..5903e05788c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_resumeprotection.go @@ -0,0 +1,70 @@ +package backupinstances + +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 ResumeProtectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResumeProtection ... +func (c BackupInstancesClient) ResumeProtection(ctx context.Context, id BackupInstanceId) (result ResumeProtectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resumeProtection", 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 +} + +// ResumeProtectionThenPoll performs ResumeProtection then polls until it's completed +func (c BackupInstancesClient) ResumeProtectionThenPoll(ctx context.Context, id BackupInstanceId) error { + result, err := c.ResumeProtection(ctx, id) + if err != nil { + return fmt.Errorf("performing ResumeProtection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResumeProtection: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_stopprotection.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_stopprotection.go new file mode 100644 index 00000000000..b2ab8a26310 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_stopprotection.go @@ -0,0 +1,102 @@ +package backupinstances + +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 StopProtectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type StopProtectionOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultStopProtectionOperationOptions() StopProtectionOperationOptions { + return StopProtectionOperationOptions{} +} + +func (o StopProtectionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o StopProtectionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StopProtectionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// StopProtection ... +func (c BackupInstancesClient) StopProtection(ctx context.Context, id BackupInstanceId, input StopProtectionRequest, options StopProtectionOperationOptions) (result StopProtectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopProtection", id.ID()), + OptionsObject: options, + } + + 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 +} + +// StopProtectionThenPoll performs StopProtection then polls until it's completed +func (c BackupInstancesClient) StopProtectionThenPoll(ctx context.Context, id BackupInstanceId, input StopProtectionRequest, options StopProtectionOperationOptions) error { + result, err := c.StopProtection(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing StopProtection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopProtection: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_suspendbackups.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_suspendbackups.go new file mode 100644 index 00000000000..8d8f1b7d43d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_suspendbackups.go @@ -0,0 +1,102 @@ +package backupinstances + +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 SuspendBackupsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type SuspendBackupsOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultSuspendBackupsOperationOptions() SuspendBackupsOperationOptions { + return SuspendBackupsOperationOptions{} +} + +func (o SuspendBackupsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o SuspendBackupsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o SuspendBackupsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// SuspendBackups ... +func (c BackupInstancesClient) SuspendBackups(ctx context.Context, id BackupInstanceId, input SuspendBackupRequest, options SuspendBackupsOperationOptions) (result SuspendBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/suspendBackups", id.ID()), + OptionsObject: options, + } + + 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 +} + +// SuspendBackupsThenPoll performs SuspendBackups then polls until it's completed +func (c BackupInstancesClient) SuspendBackupsThenPoll(ctx context.Context, id BackupInstanceId, input SuspendBackupRequest, options SuspendBackupsOperationOptions) error { + result, err := c.SuspendBackups(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing SuspendBackups: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SuspendBackups: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_syncbackupinstance.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_syncbackupinstance.go new file mode 100644 index 00000000000..b91587d0462 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_syncbackupinstance.go @@ -0,0 +1,74 @@ +package backupinstances + +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 SyncBackupInstanceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SyncBackupInstance ... +func (c BackupInstancesClient) SyncBackupInstance(ctx context.Context, id BackupInstanceId, input SyncBackupInstanceRequest) (result SyncBackupInstanceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", 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 +} + +// SyncBackupInstanceThenPoll performs SyncBackupInstance then polls until it's completed +func (c BackupInstancesClient) SyncBackupInstanceThenPoll(ctx context.Context, id BackupInstanceId, input SyncBackupInstanceRequest) error { + result, err := c.SyncBackupInstance(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SyncBackupInstance: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SyncBackupInstance: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggercrossregionrestore.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggercrossregionrestore.go new file mode 100644 index 00000000000..081a04a7e83 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggercrossregionrestore.go @@ -0,0 +1,75 @@ +package backupinstances + +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 TriggerCrossRegionRestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationJobExtendedInfo +} + +// TriggerCrossRegionRestore ... +func (c BackupInstancesClient) TriggerCrossRegionRestore(ctx context.Context, id ProviderLocationId, input CrossRegionRestoreRequestObject) (result TriggerCrossRegionRestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/crossRegionRestore", 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 +} + +// TriggerCrossRegionRestoreThenPoll performs TriggerCrossRegionRestore then polls until it's completed +func (c BackupInstancesClient) TriggerCrossRegionRestoreThenPoll(ctx context.Context, id ProviderLocationId, input CrossRegionRestoreRequestObject) error { + result, err := c.TriggerCrossRegionRestore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TriggerCrossRegionRestore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TriggerCrossRegionRestore: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrehydrate.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrehydrate.go new file mode 100644 index 00000000000..0daeeff100f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrehydrate.go @@ -0,0 +1,74 @@ +package backupinstances + +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 TriggerRehydrateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// TriggerRehydrate ... +func (c BackupInstancesClient) TriggerRehydrate(ctx context.Context, id BackupInstanceId, input AzureBackupRehydrationRequest) (result TriggerRehydrateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/rehydrate", 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 +} + +// TriggerRehydrateThenPoll performs TriggerRehydrate then polls until it's completed +func (c BackupInstancesClient) TriggerRehydrateThenPoll(ctx context.Context, id BackupInstanceId, input AzureBackupRehydrationRequest) error { + result, err := c.TriggerRehydrate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing TriggerRehydrate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TriggerRehydrate: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrestore.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrestore.go new file mode 100644 index 00000000000..cce24bd0d8d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_triggerrestore.go @@ -0,0 +1,103 @@ +package backupinstances + +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 TriggerRestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationJobExtendedInfo +} + +type TriggerRestoreOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultTriggerRestoreOperationOptions() TriggerRestoreOperationOptions { + return TriggerRestoreOperationOptions{} +} + +func (o TriggerRestoreOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o TriggerRestoreOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o TriggerRestoreOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// TriggerRestore ... +func (c BackupInstancesClient) TriggerRestore(ctx context.Context, id BackupInstanceId, input AzureBackupRestoreRequest, options TriggerRestoreOperationOptions) (result TriggerRestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", id.ID()), + OptionsObject: options, + } + + 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 +} + +// TriggerRestoreThenPoll performs TriggerRestore then polls until it's completed +func (c BackupInstancesClient) TriggerRestoreThenPoll(ctx context.Context, id BackupInstanceId, input AzureBackupRestoreRequest, options TriggerRestoreOperationOptions) error { + result, err := c.TriggerRestore(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing TriggerRestore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after TriggerRestore: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_validatecrossregionrestore.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_validatecrossregionrestore.go new file mode 100644 index 00000000000..f3492da21b7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_validatecrossregionrestore.go @@ -0,0 +1,75 @@ +package backupinstances + +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 ValidateCrossRegionRestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationJobExtendedInfo +} + +// ValidateCrossRegionRestore ... +func (c BackupInstancesClient) ValidateCrossRegionRestore(ctx context.Context, id ProviderLocationId, input ValidateCrossRegionRestoreRequestObject) (result ValidateCrossRegionRestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateCrossRegionRestore", 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 +} + +// ValidateCrossRegionRestoreThenPoll performs ValidateCrossRegionRestore then polls until it's completed +func (c BackupInstancesClient) ValidateCrossRegionRestoreThenPoll(ctx context.Context, id ProviderLocationId, input ValidateCrossRegionRestoreRequestObject) error { + result, err := c.ValidateCrossRegionRestore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateCrossRegionRestore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateCrossRegionRestore: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforbackup.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforbackup.go new file mode 100644 index 00000000000..b2f9beb384e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforbackup.go @@ -0,0 +1,75 @@ +package backupinstances + +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 ValidateForBackupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationJobExtendedInfo +} + +// ValidateForBackup ... +func (c BackupInstancesClient) ValidateForBackup(ctx context.Context, id BackupVaultId, input ValidateForBackupRequest) (result ValidateForBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateForBackup", 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 +} + +// ValidateForBackupThenPoll performs ValidateForBackup then polls until it's completed +func (c BackupInstancesClient) ValidateForBackupThenPoll(ctx context.Context, id BackupVaultId, input ValidateForBackupRequest) error { + result, err := c.ValidateForBackup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateForBackup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateForBackup: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforrestore.go b/resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforrestore.go new file mode 100644 index 00000000000..2a4adedbdea --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/method_validateforrestore.go @@ -0,0 +1,75 @@ +package backupinstances + +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 ValidateForRestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OperationJobExtendedInfo +} + +// ValidateForRestore ... +func (c BackupInstancesClient) ValidateForRestore(ctx context.Context, id BackupInstanceId, input ValidateRestoreRequestObject) (result ValidateForRestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateRestore", 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 +} + +// ValidateForRestoreThenPoll performs ValidateForRestore then polls until it's completed +func (c BackupInstancesClient) ValidateForRestoreThenPoll(ctx context.Context, id BackupInstanceId, input ValidateRestoreRequestObject) error { + result, err := c.ValidateForRestore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateForRestore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateForRestore: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackupruleoptions.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackupruleoptions.go new file mode 100644 index 00000000000..6c6e86388b8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackupruleoptions.go @@ -0,0 +1,9 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdHocBackupRuleOptions struct { + RuleName string `json:"ruleName"` + TriggerOption AdhocBackupTriggerOption `json:"triggerOption"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackuptriggeroption.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackuptriggeroption.go new file mode 100644 index 00000000000..3ce1a004123 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_adhocbackuptriggeroption.go @@ -0,0 +1,8 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdhocBackupTriggerOption struct { + RetentionTagOverride *string `json:"retentionTagOverride,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_authcredentials.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_authcredentials.go new file mode 100644 index 00000000000..8be823b957b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_authcredentials.go @@ -0,0 +1,53 @@ +package backupinstances + +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 AuthCredentials interface { +} + +// RawAuthCredentialsImpl 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 RawAuthCredentialsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAuthCredentialsImplementation(input []byte) (AuthCredentials, 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 AuthCredentials into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "SecretStoreBasedAuthCredentials") { + var out SecretStoreBasedAuthCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SecretStoreBasedAuthCredentials: %+v", err) + } + return out, nil + } + + out := RawAuthCredentialsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverypointbasedrestorerequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverypointbasedrestorerequest.go new file mode 100644 index 00000000000..cccd7deb636 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverypointbasedrestorerequest.go @@ -0,0 +1,76 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AzureBackupRestoreRequest = AzureBackupRecoveryPointBasedRestoreRequest{} + +type AzureBackupRecoveryPointBasedRestoreRequest struct { + RecoveryPointId string `json:"recoveryPointId"` + + // Fields inherited from AzureBackupRestoreRequest + IdentityDetails *IdentityDetails `json:"identityDetails,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + RestoreTargetInfo RestoreTargetInfoBase `json:"restoreTargetInfo"` + SourceDataStoreType SourceDataStoreType `json:"sourceDataStoreType"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureBackupRecoveryPointBasedRestoreRequest{} + +func (s AzureBackupRecoveryPointBasedRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupRecoveryPointBasedRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupRecoveryPointBasedRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupRecoveryPointBasedRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureBackupRecoveryPointBasedRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupRecoveryPointBasedRestoreRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureBackupRecoveryPointBasedRestoreRequest{} + +func (s *AzureBackupRecoveryPointBasedRestoreRequest) UnmarshalJSON(bytes []byte) error { + type alias AzureBackupRecoveryPointBasedRestoreRequest + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureBackupRecoveryPointBasedRestoreRequest: %+v", err) + } + + s.IdentityDetails = decoded.IdentityDetails + s.RecoveryPointId = decoded.RecoveryPointId + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.SourceDataStoreType = decoded.SourceDataStoreType + s.SourceResourceId = decoded.SourceResourceId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureBackupRecoveryPointBasedRestoreRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreTargetInfo"]; ok { + impl, err := unmarshalRestoreTargetInfoBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreTargetInfo' for 'AzureBackupRecoveryPointBasedRestoreRequest': %+v", err) + } + s.RestoreTargetInfo = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverytimebasedrestorerequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverytimebasedrestorerequest.go new file mode 100644 index 00000000000..6527462cb94 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprecoverytimebasedrestorerequest.go @@ -0,0 +1,76 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AzureBackupRestoreRequest = AzureBackupRecoveryTimeBasedRestoreRequest{} + +type AzureBackupRecoveryTimeBasedRestoreRequest struct { + RecoveryPointTime string `json:"recoveryPointTime"` + + // Fields inherited from AzureBackupRestoreRequest + IdentityDetails *IdentityDetails `json:"identityDetails,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + RestoreTargetInfo RestoreTargetInfoBase `json:"restoreTargetInfo"` + SourceDataStoreType SourceDataStoreType `json:"sourceDataStoreType"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureBackupRecoveryTimeBasedRestoreRequest{} + +func (s AzureBackupRecoveryTimeBasedRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupRecoveryTimeBasedRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupRecoveryTimeBasedRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupRecoveryTimeBasedRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureBackupRecoveryTimeBasedRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupRecoveryTimeBasedRestoreRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureBackupRecoveryTimeBasedRestoreRequest{} + +func (s *AzureBackupRecoveryTimeBasedRestoreRequest) UnmarshalJSON(bytes []byte) error { + type alias AzureBackupRecoveryTimeBasedRestoreRequest + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureBackupRecoveryTimeBasedRestoreRequest: %+v", err) + } + + s.IdentityDetails = decoded.IdentityDetails + s.RecoveryPointTime = decoded.RecoveryPointTime + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.SourceDataStoreType = decoded.SourceDataStoreType + s.SourceResourceId = decoded.SourceResourceId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureBackupRecoveryTimeBasedRestoreRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreTargetInfo"]; ok { + impl, err := unmarshalRestoreTargetInfoBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreTargetInfo' for 'AzureBackupRecoveryTimeBasedRestoreRequest': %+v", err) + } + s.RestoreTargetInfo = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprehydrationrequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprehydrationrequest.go new file mode 100644 index 00000000000..b78ded8adb1 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprehydrationrequest.go @@ -0,0 +1,10 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupRehydrationRequest struct { + RecoveryPointId string `json:"recoveryPointId"` + RehydrationPriority *RehydrationPriority `json:"rehydrationPriority,omitempty"` + RehydrationRetentionDuration string `json:"rehydrationRetentionDuration"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorerequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorerequest.go new file mode 100644 index 00000000000..3b5348e6cdf --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorerequest.go @@ -0,0 +1,69 @@ +package backupinstances + +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 AzureBackupRestoreRequest interface { +} + +// RawAzureBackupRestoreRequestImpl 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 RawAzureBackupRestoreRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAzureBackupRestoreRequestImplementation(input []byte) (AzureBackupRestoreRequest, 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 AzureBackupRestoreRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupRecoveryPointBasedRestoreRequest") { + var out AzureBackupRecoveryPointBasedRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupRecoveryPointBasedRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureBackupRecoveryTimeBasedRestoreRequest") { + var out AzureBackupRecoveryTimeBasedRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupRecoveryTimeBasedRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureBackupRestoreWithRehydrationRequest") { + var out AzureBackupRestoreWithRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupRestoreWithRehydrationRequest: %+v", err) + } + return out, nil + } + + out := RawAzureBackupRestoreRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorewithrehydrationrequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorewithrehydrationrequest.go new file mode 100644 index 00000000000..effe6125322 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azurebackuprestorewithrehydrationrequest.go @@ -0,0 +1,80 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AzureBackupRestoreRequest = AzureBackupRestoreWithRehydrationRequest{} + +type AzureBackupRestoreWithRehydrationRequest struct { + RecoveryPointId string `json:"recoveryPointId"` + RehydrationPriority RehydrationPriority `json:"rehydrationPriority"` + RehydrationRetentionDuration string `json:"rehydrationRetentionDuration"` + + // Fields inherited from AzureBackupRestoreRequest + IdentityDetails *IdentityDetails `json:"identityDetails,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + RestoreTargetInfo RestoreTargetInfoBase `json:"restoreTargetInfo"` + SourceDataStoreType SourceDataStoreType `json:"sourceDataStoreType"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureBackupRestoreWithRehydrationRequest{} + +func (s AzureBackupRestoreWithRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupRestoreWithRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupRestoreWithRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupRestoreWithRehydrationRequest: %+v", err) + } + decoded["objectType"] = "AzureBackupRestoreWithRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupRestoreWithRehydrationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureBackupRestoreWithRehydrationRequest{} + +func (s *AzureBackupRestoreWithRehydrationRequest) UnmarshalJSON(bytes []byte) error { + type alias AzureBackupRestoreWithRehydrationRequest + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureBackupRestoreWithRehydrationRequest: %+v", err) + } + + s.IdentityDetails = decoded.IdentityDetails + s.RecoveryPointId = decoded.RecoveryPointId + s.RehydrationPriority = decoded.RehydrationPriority + s.RehydrationRetentionDuration = decoded.RehydrationRetentionDuration + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.SourceDataStoreType = decoded.SourceDataStoreType + s.SourceResourceId = decoded.SourceResourceId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureBackupRestoreWithRehydrationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreTargetInfo"]; ok { + impl, err := unmarshalRestoreTargetInfoBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreTargetInfo' for 'AzureBackupRestoreWithRehydrationRequest': %+v", err) + } + s.RestoreTargetInfo = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_azureoperationalstoreparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azureoperationalstoreparameters.go new file mode 100644 index 00000000000..f7daf43fe3e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_azureoperationalstoreparameters.go @@ -0,0 +1,42 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataStoreParameters = AzureOperationalStoreParameters{} + +type AzureOperationalStoreParameters struct { + ResourceGroupId *string `json:"resourceGroupId,omitempty"` + + // Fields inherited from DataStoreParameters + DataStoreType DataStoreTypes `json:"dataStoreType"` +} + +var _ json.Marshaler = AzureOperationalStoreParameters{} + +func (s AzureOperationalStoreParameters) MarshalJSON() ([]byte, error) { + type wrapper AzureOperationalStoreParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureOperationalStoreParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureOperationalStoreParameters: %+v", err) + } + decoded["objectType"] = "AzureOperationalStoreParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureOperationalStoreParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupdatasourceparameters.go new file mode 100644 index 00000000000..035cc0633ac --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupdatasourceparameters.go @@ -0,0 +1,61 @@ +package backupinstances + +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 BackupDatasourceParameters interface { +} + +// RawBackupDatasourceParametersImpl 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 RawBackupDatasourceParametersImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBackupDatasourceParametersImplementation(input []byte) (BackupDatasourceParameters, 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 BackupDatasourceParameters into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "BlobBackupDatasourceParameters") { + var out BlobBackupDatasourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BlobBackupDatasourceParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KubernetesClusterBackupDatasourceParameters") { + var out KubernetesClusterBackupDatasourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesClusterBackupDatasourceParameters: %+v", err) + } + return out, nil + } + + out := RawBackupDatasourceParametersImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstance.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstance.go new file mode 100644 index 00000000000..ca616f380e7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstance.go @@ -0,0 +1,62 @@ +package backupinstances + +import ( + "encoding/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 BackupInstance struct { + CurrentProtectionState *CurrentProtectionState `json:"currentProtectionState,omitempty"` + DataSourceInfo Datasource `json:"dataSourceInfo"` + DataSourceSetInfo *DatasourceSet `json:"dataSourceSetInfo,omitempty"` + DatasourceAuthCredentials AuthCredentials `json:"datasourceAuthCredentials"` + FriendlyName *string `json:"friendlyName,omitempty"` + IdentityDetails *IdentityDetails `json:"identityDetails,omitempty"` + ObjectType string `json:"objectType"` + PolicyInfo PolicyInfo `json:"policyInfo"` + ProtectionErrorDetails *UserFacingError `json:"protectionErrorDetails,omitempty"` + ProtectionStatus *ProtectionStatusDetails `json:"protectionStatus,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ValidationType *ValidationType `json:"validationType,omitempty"` +} + +var _ json.Unmarshaler = &BackupInstance{} + +func (s *BackupInstance) UnmarshalJSON(bytes []byte) error { + type alias BackupInstance + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BackupInstance: %+v", err) + } + + s.CurrentProtectionState = decoded.CurrentProtectionState + s.DataSourceInfo = decoded.DataSourceInfo + s.DataSourceSetInfo = decoded.DataSourceSetInfo + s.FriendlyName = decoded.FriendlyName + s.IdentityDetails = decoded.IdentityDetails + s.ObjectType = decoded.ObjectType + s.PolicyInfo = decoded.PolicyInfo + s.ProtectionErrorDetails = decoded.ProtectionErrorDetails + s.ProtectionStatus = decoded.ProtectionStatus + s.ProvisioningState = decoded.ProvisioningState + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.ValidationType = decoded.ValidationType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BackupInstance into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["datasourceAuthCredentials"]; ok { + impl, err := unmarshalAuthCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'DatasourceAuthCredentials' for 'BackupInstance': %+v", err) + } + s.DatasourceAuthCredentials = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstanceresource.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstanceresource.go new file mode 100644 index 00000000000..ca92f651ec6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_backupinstanceresource.go @@ -0,0 +1,17 @@ +package backupinstances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupInstanceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupInstance `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_baseresourceproperties.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_baseresourceproperties.go new file mode 100644 index 00000000000..fcf07932382 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_baseresourceproperties.go @@ -0,0 +1,53 @@ +package backupinstances + +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 BaseResourceProperties interface { +} + +// RawBaseResourcePropertiesImpl 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 RawBaseResourcePropertiesImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBaseResourcePropertiesImplementation(input []byte) (BaseResourceProperties, 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 BaseResourceProperties into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "DefaultResourceProperties") { + var out DefaultResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DefaultResourceProperties: %+v", err) + } + return out, nil + } + + out := RawBaseResourcePropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_blobbackupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_blobbackupdatasourceparameters.go new file mode 100644 index 00000000000..84f49ead22c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_blobbackupdatasourceparameters.go @@ -0,0 +1,41 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupDatasourceParameters = BlobBackupDatasourceParameters{} + +type BlobBackupDatasourceParameters struct { + ContainersList []string `json:"containersList"` + + // Fields inherited from BackupDatasourceParameters +} + +var _ json.Marshaler = BlobBackupDatasourceParameters{} + +func (s BlobBackupDatasourceParameters) MarshalJSON() ([]byte, error) { + type wrapper BlobBackupDatasourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BlobBackupDatasourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BlobBackupDatasourceParameters: %+v", err) + } + decoded["objectType"] = "BlobBackupDatasourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BlobBackupDatasourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestoredetails.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestoredetails.go new file mode 100644 index 00000000000..edbe7ac454b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestoredetails.go @@ -0,0 +1,9 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossRegionRestoreDetails struct { + SourceBackupInstanceId string `json:"sourceBackupInstanceId"` + SourceRegion string `json:"sourceRegion"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestorerequestobject.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestorerequestobject.go new file mode 100644 index 00000000000..d958127a0de --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_crossregionrestorerequestobject.go @@ -0,0 +1,40 @@ +package backupinstances + +import ( + "encoding/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 CrossRegionRestoreRequestObject struct { + CrossRegionRestoreDetails CrossRegionRestoreDetails `json:"crossRegionRestoreDetails"` + RestoreRequestObject AzureBackupRestoreRequest `json:"restoreRequestObject"` +} + +var _ json.Unmarshaler = &CrossRegionRestoreRequestObject{} + +func (s *CrossRegionRestoreRequestObject) UnmarshalJSON(bytes []byte) error { + type alias CrossRegionRestoreRequestObject + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into CrossRegionRestoreRequestObject: %+v", err) + } + + s.CrossRegionRestoreDetails = decoded.CrossRegionRestoreDetails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CrossRegionRestoreRequestObject into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequestObject"]; ok { + impl, err := unmarshalAzureBackupRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequestObject' for 'CrossRegionRestoreRequestObject': %+v", err) + } + s.RestoreRequestObject = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_datasource.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_datasource.go new file mode 100644 index 00000000000..a8e07a37117 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_datasource.go @@ -0,0 +1,52 @@ +package backupinstances + +import ( + "encoding/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 Datasource struct { + DatasourceType *string `json:"datasourceType,omitempty"` + ObjectType *string `json:"objectType,omitempty"` + ResourceID string `json:"resourceID"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceProperties BaseResourceProperties `json:"resourceProperties"` + ResourceType *string `json:"resourceType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} + +var _ json.Unmarshaler = &Datasource{} + +func (s *Datasource) UnmarshalJSON(bytes []byte) error { + type alias Datasource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into Datasource: %+v", err) + } + + s.DatasourceType = decoded.DatasourceType + s.ObjectType = decoded.ObjectType + s.ResourceID = decoded.ResourceID + s.ResourceLocation = decoded.ResourceLocation + s.ResourceName = decoded.ResourceName + s.ResourceType = decoded.ResourceType + s.ResourceUri = decoded.ResourceUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Datasource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourceProperties"]; ok { + impl, err := unmarshalBaseResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourceProperties' for 'Datasource': %+v", err) + } + s.ResourceProperties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_datasourceset.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_datasourceset.go new file mode 100644 index 00000000000..537af263c0b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_datasourceset.go @@ -0,0 +1,52 @@ +package backupinstances + +import ( + "encoding/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 DatasourceSet struct { + DatasourceType *string `json:"datasourceType,omitempty"` + ObjectType *string `json:"objectType,omitempty"` + ResourceID string `json:"resourceID"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceProperties BaseResourceProperties `json:"resourceProperties"` + ResourceType *string `json:"resourceType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} + +var _ json.Unmarshaler = &DatasourceSet{} + +func (s *DatasourceSet) UnmarshalJSON(bytes []byte) error { + type alias DatasourceSet + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into DatasourceSet: %+v", err) + } + + s.DatasourceType = decoded.DatasourceType + s.ObjectType = decoded.ObjectType + s.ResourceID = decoded.ResourceID + s.ResourceLocation = decoded.ResourceLocation + s.ResourceName = decoded.ResourceName + s.ResourceType = decoded.ResourceType + s.ResourceUri = decoded.ResourceUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DatasourceSet into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourceProperties"]; ok { + impl, err := unmarshalBaseResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourceProperties' for 'DatasourceSet': %+v", err) + } + s.ResourceProperties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_datastoreparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_datastoreparameters.go new file mode 100644 index 00000000000..ee57cd90fa3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_datastoreparameters.go @@ -0,0 +1,53 @@ +package backupinstances + +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 DataStoreParameters interface { +} + +// RawDataStoreParametersImpl 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 RawDataStoreParametersImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalDataStoreParametersImplementation(input []byte) (DataStoreParameters, 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 DataStoreParameters into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureOperationalStoreParameters") { + var out AzureOperationalStoreParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureOperationalStoreParameters: %+v", err) + } + return out, nil + } + + out := RawDataStoreParametersImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_defaultresourceproperties.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_defaultresourceproperties.go new file mode 100644 index 00000000000..adac6099d8b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_defaultresourceproperties.go @@ -0,0 +1,40 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BaseResourceProperties = DefaultResourceProperties{} + +type DefaultResourceProperties struct { + + // Fields inherited from BaseResourceProperties +} + +var _ json.Marshaler = DefaultResourceProperties{} + +func (s DefaultResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DefaultResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DefaultResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DefaultResourceProperties: %+v", err) + } + decoded["objectType"] = "DefaultResourceProperties" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DefaultResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_identitydetails.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_identitydetails.go new file mode 100644 index 00000000000..60ba2542236 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_identitydetails.go @@ -0,0 +1,9 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityDetails struct { + UseSystemAssignedIdentity *bool `json:"useSystemAssignedIdentity,omitempty"` + UserAssignedIdentityArmUrl *string `json:"userAssignedIdentityArmUrl,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_innererror.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_innererror.go new file mode 100644 index 00000000000..15fc997eebd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_innererror.go @@ -0,0 +1,10 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InnerError struct { + AdditionalInfo *map[string]string `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + EmbeddedInnerError *InnerError `json:"embeddedInnerError,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestorecriteria.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestorecriteria.go new file mode 100644 index 00000000000..5c1b5326ced --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestorecriteria.go @@ -0,0 +1,93 @@ +package backupinstances + +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 ItemLevelRestoreCriteria interface { +} + +// RawItemLevelRestoreCriteriaImpl 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 RawItemLevelRestoreCriteriaImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalItemLevelRestoreCriteriaImplementation(input []byte) (ItemLevelRestoreCriteria, 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 ItemLevelRestoreCriteria into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "ItemPathBasedRestoreCriteria") { + var out ItemPathBasedRestoreCriteria + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ItemPathBasedRestoreCriteria: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KubernetesClusterRestoreCriteria") { + var out KubernetesClusterRestoreCriteria + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesClusterRestoreCriteria: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KubernetesClusterVaultTierRestoreCriteria") { + var out KubernetesClusterVaultTierRestoreCriteria + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesClusterVaultTierRestoreCriteria: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KubernetesPVRestoreCriteria") { + var out KubernetesPVRestoreCriteria + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesPVRestoreCriteria: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KubernetesStorageClassRestoreCriteria") { + var out KubernetesStorageClassRestoreCriteria + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesStorageClassRestoreCriteria: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RangeBasedItemLevelRestoreCriteria") { + var out RangeBasedItemLevelRestoreCriteria + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RangeBasedItemLevelRestoreCriteria: %+v", err) + } + return out, nil + } + + out := RawItemLevelRestoreCriteriaImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestoretargetinfo.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestoretargetinfo.go new file mode 100644 index 00000000000..475d8764212 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_itemlevelrestoretargetinfo.go @@ -0,0 +1,92 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreTargetInfoBase = ItemLevelRestoreTargetInfo{} + +type ItemLevelRestoreTargetInfo struct { + DatasourceAuthCredentials AuthCredentials `json:"datasourceAuthCredentials"` + DatasourceInfo Datasource `json:"datasourceInfo"` + DatasourceSetInfo *DatasourceSet `json:"datasourceSetInfo,omitempty"` + RestoreCriteria []ItemLevelRestoreCriteria `json:"restoreCriteria"` + + // Fields inherited from RestoreTargetInfoBase + RecoveryOption RecoveryOption `json:"recoveryOption"` + RestoreLocation *string `json:"restoreLocation,omitempty"` +} + +var _ json.Marshaler = ItemLevelRestoreTargetInfo{} + +func (s ItemLevelRestoreTargetInfo) MarshalJSON() ([]byte, error) { + type wrapper ItemLevelRestoreTargetInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ItemLevelRestoreTargetInfo: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ItemLevelRestoreTargetInfo: %+v", err) + } + decoded["objectType"] = "ItemLevelRestoreTargetInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ItemLevelRestoreTargetInfo: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ItemLevelRestoreTargetInfo{} + +func (s *ItemLevelRestoreTargetInfo) UnmarshalJSON(bytes []byte) error { + type alias ItemLevelRestoreTargetInfo + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ItemLevelRestoreTargetInfo: %+v", err) + } + + s.DatasourceInfo = decoded.DatasourceInfo + s.DatasourceSetInfo = decoded.DatasourceSetInfo + s.RecoveryOption = decoded.RecoveryOption + s.RestoreLocation = decoded.RestoreLocation + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ItemLevelRestoreTargetInfo into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["datasourceAuthCredentials"]; ok { + impl, err := unmarshalAuthCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'DatasourceAuthCredentials' for 'ItemLevelRestoreTargetInfo': %+v", err) + } + s.DatasourceAuthCredentials = impl + } + + if v, ok := temp["restoreCriteria"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling RestoreCriteria into list []json.RawMessage: %+v", err) + } + + output := make([]ItemLevelRestoreCriteria, 0) + for i, val := range listTemp { + impl, err := unmarshalItemLevelRestoreCriteriaImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'RestoreCriteria' for 'ItemLevelRestoreTargetInfo': %+v", i, err) + } + output = append(output, impl) + } + s.RestoreCriteria = output + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_itempathbasedrestorecriteria.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_itempathbasedrestorecriteria.go new file mode 100644 index 00000000000..bd6640be142 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_itempathbasedrestorecriteria.go @@ -0,0 +1,43 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ItemLevelRestoreCriteria = ItemPathBasedRestoreCriteria{} + +type ItemPathBasedRestoreCriteria struct { + IsPathRelativeToBackupItem bool `json:"isPathRelativeToBackupItem"` + ItemPath string `json:"itemPath"` + SubItemPathPrefix *[]string `json:"subItemPathPrefix,omitempty"` + + // Fields inherited from ItemLevelRestoreCriteria +} + +var _ json.Marshaler = ItemPathBasedRestoreCriteria{} + +func (s ItemPathBasedRestoreCriteria) MarshalJSON() ([]byte, error) { + type wrapper ItemPathBasedRestoreCriteria + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ItemPathBasedRestoreCriteria: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ItemPathBasedRestoreCriteria: %+v", err) + } + decoded["objectType"] = "ItemPathBasedRestoreCriteria" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ItemPathBasedRestoreCriteria: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterbackupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterbackupdatasourceparameters.go new file mode 100644 index 00000000000..021230e39ac --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterbackupdatasourceparameters.go @@ -0,0 +1,48 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupDatasourceParameters = KubernetesClusterBackupDatasourceParameters{} + +type KubernetesClusterBackupDatasourceParameters struct { + BackupHookReferences *[]NamespacedNameResource `json:"backupHookReferences,omitempty"` + ExcludedNamespaces *[]string `json:"excludedNamespaces,omitempty"` + ExcludedResourceTypes *[]string `json:"excludedResourceTypes,omitempty"` + IncludeClusterScopeResources bool `json:"includeClusterScopeResources"` + IncludedNamespaces *[]string `json:"includedNamespaces,omitempty"` + IncludedResourceTypes *[]string `json:"includedResourceTypes,omitempty"` + LabelSelectors *[]string `json:"labelSelectors,omitempty"` + SnapshotVolumes bool `json:"snapshotVolumes"` + + // Fields inherited from BackupDatasourceParameters +} + +var _ json.Marshaler = KubernetesClusterBackupDatasourceParameters{} + +func (s KubernetesClusterBackupDatasourceParameters) MarshalJSON() ([]byte, error) { + type wrapper KubernetesClusterBackupDatasourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + decoded["objectType"] = "KubernetesClusterBackupDatasourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterrestorecriteria.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterrestorecriteria.go new file mode 100644 index 00000000000..ab7478006ae --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclusterrestorecriteria.go @@ -0,0 +1,51 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ItemLevelRestoreCriteria = KubernetesClusterRestoreCriteria{} + +type KubernetesClusterRestoreCriteria struct { + ConflictPolicy *ExistingResourcePolicy `json:"conflictPolicy,omitempty"` + ExcludedNamespaces *[]string `json:"excludedNamespaces,omitempty"` + ExcludedResourceTypes *[]string `json:"excludedResourceTypes,omitempty"` + IncludeClusterScopeResources bool `json:"includeClusterScopeResources"` + IncludedNamespaces *[]string `json:"includedNamespaces,omitempty"` + IncludedResourceTypes *[]string `json:"includedResourceTypes,omitempty"` + LabelSelectors *[]string `json:"labelSelectors,omitempty"` + NamespaceMappings *map[string]string `json:"namespaceMappings,omitempty"` + PersistentVolumeRestoreMode *PersistentVolumeRestoreMode `json:"persistentVolumeRestoreMode,omitempty"` + ResourceModifierReference *NamespacedNameResource `json:"resourceModifierReference,omitempty"` + RestoreHookReferences *[]NamespacedNameResource `json:"restoreHookReferences,omitempty"` + + // Fields inherited from ItemLevelRestoreCriteria +} + +var _ json.Marshaler = KubernetesClusterRestoreCriteria{} + +func (s KubernetesClusterRestoreCriteria) MarshalJSON() ([]byte, error) { + type wrapper KubernetesClusterRestoreCriteria + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesClusterRestoreCriteria: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesClusterRestoreCriteria: %+v", err) + } + decoded["objectType"] = "KubernetesClusterRestoreCriteria" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesClusterRestoreCriteria: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclustervaulttierrestorecriteria.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclustervaulttierrestorecriteria.go new file mode 100644 index 00000000000..b172d3bed60 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesclustervaulttierrestorecriteria.go @@ -0,0 +1,53 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ItemLevelRestoreCriteria = KubernetesClusterVaultTierRestoreCriteria{} + +type KubernetesClusterVaultTierRestoreCriteria struct { + ConflictPolicy *ExistingResourcePolicy `json:"conflictPolicy,omitempty"` + ExcludedNamespaces *[]string `json:"excludedNamespaces,omitempty"` + ExcludedResourceTypes *[]string `json:"excludedResourceTypes,omitempty"` + IncludeClusterScopeResources bool `json:"includeClusterScopeResources"` + IncludedNamespaces *[]string `json:"includedNamespaces,omitempty"` + IncludedResourceTypes *[]string `json:"includedResourceTypes,omitempty"` + LabelSelectors *[]string `json:"labelSelectors,omitempty"` + NamespaceMappings *map[string]string `json:"namespaceMappings,omitempty"` + PersistentVolumeRestoreMode *PersistentVolumeRestoreMode `json:"persistentVolumeRestoreMode,omitempty"` + ResourceModifierReference *NamespacedNameResource `json:"resourceModifierReference,omitempty"` + RestoreHookReferences *[]NamespacedNameResource `json:"restoreHookReferences,omitempty"` + StagingResourceGroupId *string `json:"stagingResourceGroupId,omitempty"` + StagingStorageAccountId *string `json:"stagingStorageAccountId,omitempty"` + + // Fields inherited from ItemLevelRestoreCriteria +} + +var _ json.Marshaler = KubernetesClusterVaultTierRestoreCriteria{} + +func (s KubernetesClusterVaultTierRestoreCriteria) MarshalJSON() ([]byte, error) { + type wrapper KubernetesClusterVaultTierRestoreCriteria + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesClusterVaultTierRestoreCriteria: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesClusterVaultTierRestoreCriteria: %+v", err) + } + decoded["objectType"] = "KubernetesClusterVaultTierRestoreCriteria" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesClusterVaultTierRestoreCriteria: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetespvrestorecriteria.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetespvrestorecriteria.go new file mode 100644 index 00000000000..0f3d56cbfeb --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetespvrestorecriteria.go @@ -0,0 +1,42 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ItemLevelRestoreCriteria = KubernetesPVRestoreCriteria{} + +type KubernetesPVRestoreCriteria struct { + Name *string `json:"name,omitempty"` + StorageClassName *string `json:"storageClassName,omitempty"` + + // Fields inherited from ItemLevelRestoreCriteria +} + +var _ json.Marshaler = KubernetesPVRestoreCriteria{} + +func (s KubernetesPVRestoreCriteria) MarshalJSON() ([]byte, error) { + type wrapper KubernetesPVRestoreCriteria + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesPVRestoreCriteria: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesPVRestoreCriteria: %+v", err) + } + decoded["objectType"] = "KubernetesPVRestoreCriteria" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesPVRestoreCriteria: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesstorageclassrestorecriteria.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesstorageclassrestorecriteria.go new file mode 100644 index 00000000000..d4b08aa1e6f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_kubernetesstorageclassrestorecriteria.go @@ -0,0 +1,42 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ItemLevelRestoreCriteria = KubernetesStorageClassRestoreCriteria{} + +type KubernetesStorageClassRestoreCriteria struct { + Provisioner *string `json:"provisioner,omitempty"` + SelectedStorageClassName *string `json:"selectedStorageClassName,omitempty"` + + // Fields inherited from ItemLevelRestoreCriteria +} + +var _ json.Marshaler = KubernetesStorageClassRestoreCriteria{} + +func (s KubernetesStorageClassRestoreCriteria) MarshalJSON() ([]byte, error) { + type wrapper KubernetesStorageClassRestoreCriteria + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesStorageClassRestoreCriteria: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesStorageClassRestoreCriteria: %+v", err) + } + decoded["objectType"] = "KubernetesStorageClassRestoreCriteria" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesStorageClassRestoreCriteria: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_namespacednameresource.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_namespacednameresource.go new file mode 100644 index 00000000000..f0c6e7a847c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_namespacednameresource.go @@ -0,0 +1,9 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacedNameResource struct { + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_operationextendedinfo.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_operationextendedinfo.go new file mode 100644 index 00000000000..53581d9a9e1 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_operationextendedinfo.go @@ -0,0 +1,53 @@ +package backupinstances + +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 OperationExtendedInfo interface { +} + +// RawOperationExtendedInfoImpl 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 RawOperationExtendedInfoImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalOperationExtendedInfoImplementation(input []byte) (OperationExtendedInfo, 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 OperationExtendedInfo into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "OperationJobExtendedInfo") { + var out OperationJobExtendedInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OperationJobExtendedInfo: %+v", err) + } + return out, nil + } + + out := RawOperationExtendedInfoImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_operationjobextendedinfo.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_operationjobextendedinfo.go new file mode 100644 index 00000000000..59cd3f9ddf6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_operationjobextendedinfo.go @@ -0,0 +1,41 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OperationExtendedInfo = OperationJobExtendedInfo{} + +type OperationJobExtendedInfo struct { + JobId *string `json:"jobId,omitempty"` + + // Fields inherited from OperationExtendedInfo +} + +var _ json.Marshaler = OperationJobExtendedInfo{} + +func (s OperationJobExtendedInfo) MarshalJSON() ([]byte, error) { + type wrapper OperationJobExtendedInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OperationJobExtendedInfo: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OperationJobExtendedInfo: %+v", err) + } + decoded["objectType"] = "OperationJobExtendedInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OperationJobExtendedInfo: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_policyinfo.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_policyinfo.go new file mode 100644 index 00000000000..41646c6341d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_policyinfo.go @@ -0,0 +1,10 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyInfo struct { + PolicyId string `json:"policyId"` + PolicyParameters *PolicyParameters `json:"policyParameters,omitempty"` + PolicyVersion *string `json:"policyVersion,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_policyparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_policyparameters.go new file mode 100644 index 00000000000..ba00f440ca8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_policyparameters.go @@ -0,0 +1,59 @@ +package backupinstances + +import ( + "encoding/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 PolicyParameters struct { + BackupDatasourceParametersList *[]BackupDatasourceParameters `json:"backupDatasourceParametersList,omitempty"` + DataStoreParametersList *[]DataStoreParameters `json:"dataStoreParametersList,omitempty"` +} + +var _ json.Unmarshaler = &PolicyParameters{} + +func (s *PolicyParameters) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PolicyParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["backupDatasourceParametersList"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling BackupDatasourceParametersList into list []json.RawMessage: %+v", err) + } + + output := make([]BackupDatasourceParameters, 0) + for i, val := range listTemp { + impl, err := unmarshalBackupDatasourceParametersImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'BackupDatasourceParametersList' for 'PolicyParameters': %+v", i, err) + } + output = append(output, impl) + } + s.BackupDatasourceParametersList = &output + } + + if v, ok := temp["dataStoreParametersList"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling DataStoreParametersList into list []json.RawMessage: %+v", err) + } + + output := make([]DataStoreParameters, 0) + for i, val := range listTemp { + impl, err := unmarshalDataStoreParametersImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'DataStoreParametersList' for 'PolicyParameters': %+v", i, err) + } + output = append(output, impl) + } + s.DataStoreParametersList = &output + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_protectionstatusdetails.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_protectionstatusdetails.go new file mode 100644 index 00000000000..47607ca70da --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_protectionstatusdetails.go @@ -0,0 +1,9 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionStatusDetails struct { + ErrorDetails *UserFacingError `json:"errorDetails,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_rangebaseditemlevelrestorecriteria.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_rangebaseditemlevelrestorecriteria.go new file mode 100644 index 00000000000..c7df0c52c2b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_rangebaseditemlevelrestorecriteria.go @@ -0,0 +1,42 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ItemLevelRestoreCriteria = RangeBasedItemLevelRestoreCriteria{} + +type RangeBasedItemLevelRestoreCriteria struct { + MaxMatchingValue *string `json:"maxMatchingValue,omitempty"` + MinMatchingValue *string `json:"minMatchingValue,omitempty"` + + // Fields inherited from ItemLevelRestoreCriteria +} + +var _ json.Marshaler = RangeBasedItemLevelRestoreCriteria{} + +func (s RangeBasedItemLevelRestoreCriteria) MarshalJSON() ([]byte, error) { + type wrapper RangeBasedItemLevelRestoreCriteria + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RangeBasedItemLevelRestoreCriteria: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RangeBasedItemLevelRestoreCriteria: %+v", err) + } + decoded["objectType"] = "RangeBasedItemLevelRestoreCriteria" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RangeBasedItemLevelRestoreCriteria: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_restorefilestargetinfo.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_restorefilestargetinfo.go new file mode 100644 index 00000000000..04fe194025c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_restorefilestargetinfo.go @@ -0,0 +1,43 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreTargetInfoBase = RestoreFilesTargetInfo{} + +type RestoreFilesTargetInfo struct { + TargetDetails TargetDetails `json:"targetDetails"` + + // Fields inherited from RestoreTargetInfoBase + RecoveryOption RecoveryOption `json:"recoveryOption"` + RestoreLocation *string `json:"restoreLocation,omitempty"` +} + +var _ json.Marshaler = RestoreFilesTargetInfo{} + +func (s RestoreFilesTargetInfo) MarshalJSON() ([]byte, error) { + type wrapper RestoreFilesTargetInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RestoreFilesTargetInfo: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RestoreFilesTargetInfo: %+v", err) + } + decoded["objectType"] = "RestoreFilesTargetInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RestoreFilesTargetInfo: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfo.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfo.go new file mode 100644 index 00000000000..23f512f2c31 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfo.go @@ -0,0 +1,74 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreTargetInfoBase = RestoreTargetInfo{} + +type RestoreTargetInfo struct { + DatasourceAuthCredentials AuthCredentials `json:"datasourceAuthCredentials"` + DatasourceInfo Datasource `json:"datasourceInfo"` + DatasourceSetInfo *DatasourceSet `json:"datasourceSetInfo,omitempty"` + + // Fields inherited from RestoreTargetInfoBase + RecoveryOption RecoveryOption `json:"recoveryOption"` + RestoreLocation *string `json:"restoreLocation,omitempty"` +} + +var _ json.Marshaler = RestoreTargetInfo{} + +func (s RestoreTargetInfo) MarshalJSON() ([]byte, error) { + type wrapper RestoreTargetInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RestoreTargetInfo: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RestoreTargetInfo: %+v", err) + } + decoded["objectType"] = "RestoreTargetInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RestoreTargetInfo: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &RestoreTargetInfo{} + +func (s *RestoreTargetInfo) UnmarshalJSON(bytes []byte) error { + type alias RestoreTargetInfo + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RestoreTargetInfo: %+v", err) + } + + s.DatasourceInfo = decoded.DatasourceInfo + s.DatasourceSetInfo = decoded.DatasourceSetInfo + s.RecoveryOption = decoded.RecoveryOption + s.RestoreLocation = decoded.RestoreLocation + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RestoreTargetInfo into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["datasourceAuthCredentials"]; ok { + impl, err := unmarshalAuthCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'DatasourceAuthCredentials' for 'RestoreTargetInfo': %+v", err) + } + s.DatasourceAuthCredentials = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfobase.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfobase.go new file mode 100644 index 00000000000..ce31702dc78 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_restoretargetinfobase.go @@ -0,0 +1,69 @@ +package backupinstances + +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 RestoreTargetInfoBase interface { +} + +// RawRestoreTargetInfoBaseImpl 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 RawRestoreTargetInfoBaseImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRestoreTargetInfoBaseImplementation(input []byte) (RestoreTargetInfoBase, 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 RestoreTargetInfoBase into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "ItemLevelRestoreTargetInfo") { + var out ItemLevelRestoreTargetInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ItemLevelRestoreTargetInfo: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RestoreFilesTargetInfo") { + var out RestoreFilesTargetInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RestoreFilesTargetInfo: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RestoreTargetInfo") { + var out RestoreTargetInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RestoreTargetInfo: %+v", err) + } + return out, nil + } + + out := RawRestoreTargetInfoBaseImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstorebasedauthcredentials.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstorebasedauthcredentials.go new file mode 100644 index 00000000000..76f2af98598 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstorebasedauthcredentials.go @@ -0,0 +1,41 @@ +package backupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AuthCredentials = SecretStoreBasedAuthCredentials{} + +type SecretStoreBasedAuthCredentials struct { + SecretStoreResource *SecretStoreResource `json:"secretStoreResource,omitempty"` + + // Fields inherited from AuthCredentials +} + +var _ json.Marshaler = SecretStoreBasedAuthCredentials{} + +func (s SecretStoreBasedAuthCredentials) MarshalJSON() ([]byte, error) { + type wrapper SecretStoreBasedAuthCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SecretStoreBasedAuthCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SecretStoreBasedAuthCredentials: %+v", err) + } + decoded["objectType"] = "SecretStoreBasedAuthCredentials" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SecretStoreBasedAuthCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstoreresource.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstoreresource.go new file mode 100644 index 00000000000..ee1d6fb0bd9 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_secretstoreresource.go @@ -0,0 +1,10 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretStoreResource struct { + SecretStoreType SecretStoreType `json:"secretStoreType"` + Uri *string `json:"uri,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_stopprotectionrequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_stopprotectionrequest.go new file mode 100644 index 00000000000..f435ab8a767 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_stopprotectionrequest.go @@ -0,0 +1,8 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopProtectionRequest struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_suspendbackuprequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_suspendbackuprequest.go new file mode 100644 index 00000000000..c4234efa63b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_suspendbackuprequest.go @@ -0,0 +1,8 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SuspendBackupRequest struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_syncbackupinstancerequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_syncbackupinstancerequest.go new file mode 100644 index 00000000000..ce2412fb5e5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_syncbackupinstancerequest.go @@ -0,0 +1,8 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SyncBackupInstanceRequest struct { + SyncType *SyncType `json:"syncType,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_targetdetails.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_targetdetails.go new file mode 100644 index 00000000000..321cf422bff --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_targetdetails.go @@ -0,0 +1,11 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetDetails struct { + FilePrefix string `json:"filePrefix"` + RestoreTargetLocationType RestoreTargetLocationType `json:"restoreTargetLocationType"` + TargetResourceArmId *string `json:"targetResourceArmId,omitempty"` + Url string `json:"url"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_triggerbackuprequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_triggerbackuprequest.go new file mode 100644 index 00000000000..ffe844c6e4a --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_triggerbackuprequest.go @@ -0,0 +1,8 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerBackupRequest struct { + BackupRuleOptions AdHocBackupRuleOptions `json:"backupRuleOptions"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_userfacingerror.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_userfacingerror.go new file mode 100644 index 00000000000..e3afc757301 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_userfacingerror.go @@ -0,0 +1,16 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingError struct { + Code *string `json:"code,omitempty"` + Details *[]UserFacingError `json:"details,omitempty"` + InnerError *InnerError `json:"innerError,omitempty"` + IsRetryable *bool `json:"isRetryable,omitempty"` + IsUserError *bool `json:"isUserError,omitempty"` + Message *string `json:"message,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + RecommendedAction *[]string `json:"recommendedAction,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_validatecrossregionrestorerequestobject.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_validatecrossregionrestorerequestobject.go new file mode 100644 index 00000000000..64c70ca0be3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_validatecrossregionrestorerequestobject.go @@ -0,0 +1,40 @@ +package backupinstances + +import ( + "encoding/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 ValidateCrossRegionRestoreRequestObject struct { + CrossRegionRestoreDetails CrossRegionRestoreDetails `json:"crossRegionRestoreDetails"` + RestoreRequestObject AzureBackupRestoreRequest `json:"restoreRequestObject"` +} + +var _ json.Unmarshaler = &ValidateCrossRegionRestoreRequestObject{} + +func (s *ValidateCrossRegionRestoreRequestObject) UnmarshalJSON(bytes []byte) error { + type alias ValidateCrossRegionRestoreRequestObject + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ValidateCrossRegionRestoreRequestObject: %+v", err) + } + + s.CrossRegionRestoreDetails = decoded.CrossRegionRestoreDetails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateCrossRegionRestoreRequestObject into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequestObject"]; ok { + impl, err := unmarshalAzureBackupRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequestObject' for 'ValidateCrossRegionRestoreRequestObject': %+v", err) + } + s.RestoreRequestObject = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_validateforbackuprequest.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_validateforbackuprequest.go new file mode 100644 index 00000000000..92af8c34ee0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_validateforbackuprequest.go @@ -0,0 +1,8 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateForBackupRequest struct { + BackupInstance BackupInstance `json:"backupInstance"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/model_validaterestorerequestobject.go b/resource-manager/dataprotection/2024-04-01/backupinstances/model_validaterestorerequestobject.go new file mode 100644 index 00000000000..e59fe83da41 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/model_validaterestorerequestobject.go @@ -0,0 +1,32 @@ +package backupinstances + +import ( + "encoding/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 ValidateRestoreRequestObject struct { + RestoreRequestObject AzureBackupRestoreRequest `json:"restoreRequestObject"` +} + +var _ json.Unmarshaler = &ValidateRestoreRequestObject{} + +func (s *ValidateRestoreRequestObject) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateRestoreRequestObject into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequestObject"]; ok { + impl, err := unmarshalAzureBackupRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequestObject' for 'ValidateRestoreRequestObject': %+v", err) + } + s.RestoreRequestObject = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstances/predicates.go b/resource-manager/dataprotection/2024-04-01/backupinstances/predicates.go new file mode 100644 index 00000000000..c734a2fe8ca --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/predicates.go @@ -0,0 +1,27 @@ +package backupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupInstanceResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p BackupInstanceResourceOperationPredicate) Matches(input BackupInstanceResource) 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/dataprotection/2024-04-01/backupinstances/version.go b/resource-manager/dataprotection/2024-04-01/backupinstances/version.go new file mode 100644 index 00000000000..eada6fa8b12 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstances/version.go @@ -0,0 +1,12 @@ +package backupinstances + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupinstances/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/README.md b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/README.md new file mode 100644 index 00000000000..6543d1329d4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting` Documentation + +The `backupinstancesextensionrouting` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/backupinstancesextensionrouting" +``` + + +### Client Initialization + +```go +client := backupinstancesextensionrouting.NewBackupInstancesExtensionRoutingClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupInstancesExtensionRoutingClient.List` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-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/dataprotection/2024-04-01/backupinstancesextensionrouting/client.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/client.go new file mode 100644 index 00000000000..4f36c1f1bdc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/client.go @@ -0,0 +1,26 @@ +package backupinstancesextensionrouting + +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 BackupInstancesExtensionRoutingClient struct { + Client *resourcemanager.Client +} + +func NewBackupInstancesExtensionRoutingClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupInstancesExtensionRoutingClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "backupinstancesextensionrouting", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupInstancesExtensionRoutingClient: %+v", err) + } + + return &BackupInstancesExtensionRoutingClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/constants.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/constants.go new file mode 100644 index 00000000000..91c77193c93 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/constants.go @@ -0,0 +1,298 @@ +package backupinstancesextensionrouting + +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 CurrentProtectionState string + +const ( + CurrentProtectionStateBackupSchedulesSuspended CurrentProtectionState = "BackupSchedulesSuspended" + CurrentProtectionStateConfiguringProtection CurrentProtectionState = "ConfiguringProtection" + CurrentProtectionStateConfiguringProtectionFailed CurrentProtectionState = "ConfiguringProtectionFailed" + CurrentProtectionStateInvalid CurrentProtectionState = "Invalid" + CurrentProtectionStateNotProtected CurrentProtectionState = "NotProtected" + CurrentProtectionStateProtectionConfigured CurrentProtectionState = "ProtectionConfigured" + CurrentProtectionStateProtectionError CurrentProtectionState = "ProtectionError" + CurrentProtectionStateProtectionStopped CurrentProtectionState = "ProtectionStopped" + CurrentProtectionStateRetentionSchedulesSuspended CurrentProtectionState = "RetentionSchedulesSuspended" + CurrentProtectionStateSoftDeleted CurrentProtectionState = "SoftDeleted" + CurrentProtectionStateSoftDeleting CurrentProtectionState = "SoftDeleting" + CurrentProtectionStateUpdatingProtection CurrentProtectionState = "UpdatingProtection" +) + +func PossibleValuesForCurrentProtectionState() []string { + return []string{ + string(CurrentProtectionStateBackupSchedulesSuspended), + string(CurrentProtectionStateConfiguringProtection), + string(CurrentProtectionStateConfiguringProtectionFailed), + string(CurrentProtectionStateInvalid), + string(CurrentProtectionStateNotProtected), + string(CurrentProtectionStateProtectionConfigured), + string(CurrentProtectionStateProtectionError), + string(CurrentProtectionStateProtectionStopped), + string(CurrentProtectionStateRetentionSchedulesSuspended), + string(CurrentProtectionStateSoftDeleted), + string(CurrentProtectionStateSoftDeleting), + string(CurrentProtectionStateUpdatingProtection), + } +} + +func (s *CurrentProtectionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCurrentProtectionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCurrentProtectionState(input string) (*CurrentProtectionState, error) { + vals := map[string]CurrentProtectionState{ + "backupschedulessuspended": CurrentProtectionStateBackupSchedulesSuspended, + "configuringprotection": CurrentProtectionStateConfiguringProtection, + "configuringprotectionfailed": CurrentProtectionStateConfiguringProtectionFailed, + "invalid": CurrentProtectionStateInvalid, + "notprotected": CurrentProtectionStateNotProtected, + "protectionconfigured": CurrentProtectionStateProtectionConfigured, + "protectionerror": CurrentProtectionStateProtectionError, + "protectionstopped": CurrentProtectionStateProtectionStopped, + "retentionschedulessuspended": CurrentProtectionStateRetentionSchedulesSuspended, + "softdeleted": CurrentProtectionStateSoftDeleted, + "softdeleting": CurrentProtectionStateSoftDeleting, + "updatingprotection": CurrentProtectionStateUpdatingProtection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CurrentProtectionState(input) + return &out, nil +} + +type DataStoreTypes string + +const ( + DataStoreTypesArchiveStore DataStoreTypes = "ArchiveStore" + DataStoreTypesOperationalStore DataStoreTypes = "OperationalStore" + DataStoreTypesVaultStore DataStoreTypes = "VaultStore" +) + +func PossibleValuesForDataStoreTypes() []string { + return []string{ + string(DataStoreTypesArchiveStore), + string(DataStoreTypesOperationalStore), + string(DataStoreTypesVaultStore), + } +} + +func (s *DataStoreTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataStoreTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataStoreTypes(input string) (*DataStoreTypes, error) { + vals := map[string]DataStoreTypes{ + "archivestore": DataStoreTypesArchiveStore, + "operationalstore": DataStoreTypesOperationalStore, + "vaultstore": DataStoreTypesVaultStore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataStoreTypes(input) + return &out, nil +} + +type ResourcePropertiesObjectType string + +const ( + ResourcePropertiesObjectTypeDefaultResourceProperties ResourcePropertiesObjectType = "DefaultResourceProperties" +) + +func PossibleValuesForResourcePropertiesObjectType() []string { + return []string{ + string(ResourcePropertiesObjectTypeDefaultResourceProperties), + } +} + +func (s *ResourcePropertiesObjectType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourcePropertiesObjectType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourcePropertiesObjectType(input string) (*ResourcePropertiesObjectType, error) { + vals := map[string]ResourcePropertiesObjectType{ + "defaultresourceproperties": ResourcePropertiesObjectTypeDefaultResourceProperties, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourcePropertiesObjectType(input) + return &out, nil +} + +type SecretStoreType string + +const ( + SecretStoreTypeAzureKeyVault SecretStoreType = "AzureKeyVault" + SecretStoreTypeInvalid SecretStoreType = "Invalid" +) + +func PossibleValuesForSecretStoreType() []string { + return []string{ + string(SecretStoreTypeAzureKeyVault), + string(SecretStoreTypeInvalid), + } +} + +func (s *SecretStoreType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecretStoreType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecretStoreType(input string) (*SecretStoreType, error) { + vals := map[string]SecretStoreType{ + "azurekeyvault": SecretStoreTypeAzureKeyVault, + "invalid": SecretStoreTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecretStoreType(input) + return &out, nil +} + +type Status string + +const ( + StatusConfiguringProtection Status = "ConfiguringProtection" + StatusConfiguringProtectionFailed Status = "ConfiguringProtectionFailed" + StatusProtectionConfigured Status = "ProtectionConfigured" + StatusProtectionStopped Status = "ProtectionStopped" + StatusSoftDeleted Status = "SoftDeleted" + StatusSoftDeleting Status = "SoftDeleting" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusConfiguringProtection), + string(StatusConfiguringProtectionFailed), + string(StatusProtectionConfigured), + string(StatusProtectionStopped), + string(StatusSoftDeleted), + string(StatusSoftDeleting), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "configuringprotection": StatusConfiguringProtection, + "configuringprotectionfailed": StatusConfiguringProtectionFailed, + "protectionconfigured": StatusProtectionConfigured, + "protectionstopped": StatusProtectionStopped, + "softdeleted": StatusSoftDeleted, + "softdeleting": StatusSoftDeleting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} + +type ValidationType string + +const ( + ValidationTypeDeepValidation ValidationType = "DeepValidation" + ValidationTypeShallowValidation ValidationType = "ShallowValidation" +) + +func PossibleValuesForValidationType() []string { + return []string{ + string(ValidationTypeDeepValidation), + string(ValidationTypeShallowValidation), + } +} + +func (s *ValidationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationType(input string) (*ValidationType, error) { + vals := map[string]ValidationType{ + "deepvalidation": ValidationTypeDeepValidation, + "shallowvalidation": ValidationTypeShallowValidation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationType(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/method_list.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/method_list.go new file mode 100644 index 00000000000..633748840d4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/method_list.go @@ -0,0 +1,92 @@ +package backupinstancesextensionrouting + +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 *[]BackupInstanceResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupInstanceResource +} + +// List ... +func (c BackupInstancesExtensionRoutingClient) List(ctx context.Context, id commonids.ScopeId) (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.DataProtection/backupInstances", 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 *[]BackupInstanceResource `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 BackupInstancesExtensionRoutingClient) ListComplete(ctx context.Context, id commonids.ScopeId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, BackupInstanceResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupInstancesExtensionRoutingClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, predicate BackupInstanceResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BackupInstanceResource, 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/dataprotection/2024-04-01/backupinstancesextensionrouting/model_authcredentials.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_authcredentials.go new file mode 100644 index 00000000000..8044111951b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_authcredentials.go @@ -0,0 +1,53 @@ +package backupinstancesextensionrouting + +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 AuthCredentials interface { +} + +// RawAuthCredentialsImpl 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 RawAuthCredentialsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAuthCredentialsImplementation(input []byte) (AuthCredentials, 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 AuthCredentials into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "SecretStoreBasedAuthCredentials") { + var out SecretStoreBasedAuthCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SecretStoreBasedAuthCredentials: %+v", err) + } + return out, nil + } + + out := RawAuthCredentialsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_azureoperationalstoreparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_azureoperationalstoreparameters.go new file mode 100644 index 00000000000..512747be67d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_azureoperationalstoreparameters.go @@ -0,0 +1,42 @@ +package backupinstancesextensionrouting + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataStoreParameters = AzureOperationalStoreParameters{} + +type AzureOperationalStoreParameters struct { + ResourceGroupId *string `json:"resourceGroupId,omitempty"` + + // Fields inherited from DataStoreParameters + DataStoreType DataStoreTypes `json:"dataStoreType"` +} + +var _ json.Marshaler = AzureOperationalStoreParameters{} + +func (s AzureOperationalStoreParameters) MarshalJSON() ([]byte, error) { + type wrapper AzureOperationalStoreParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureOperationalStoreParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureOperationalStoreParameters: %+v", err) + } + decoded["objectType"] = "AzureOperationalStoreParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureOperationalStoreParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupdatasourceparameters.go new file mode 100644 index 00000000000..8b65bb33421 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupdatasourceparameters.go @@ -0,0 +1,61 @@ +package backupinstancesextensionrouting + +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 BackupDatasourceParameters interface { +} + +// RawBackupDatasourceParametersImpl 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 RawBackupDatasourceParametersImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBackupDatasourceParametersImplementation(input []byte) (BackupDatasourceParameters, 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 BackupDatasourceParameters into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "BlobBackupDatasourceParameters") { + var out BlobBackupDatasourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BlobBackupDatasourceParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KubernetesClusterBackupDatasourceParameters") { + var out KubernetesClusterBackupDatasourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesClusterBackupDatasourceParameters: %+v", err) + } + return out, nil + } + + out := RawBackupDatasourceParametersImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstance.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstance.go new file mode 100644 index 00000000000..7e28f6f3528 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstance.go @@ -0,0 +1,62 @@ +package backupinstancesextensionrouting + +import ( + "encoding/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 BackupInstance struct { + CurrentProtectionState *CurrentProtectionState `json:"currentProtectionState,omitempty"` + DataSourceInfo Datasource `json:"dataSourceInfo"` + DataSourceSetInfo *DatasourceSet `json:"dataSourceSetInfo,omitempty"` + DatasourceAuthCredentials AuthCredentials `json:"datasourceAuthCredentials"` + FriendlyName *string `json:"friendlyName,omitempty"` + IdentityDetails *IdentityDetails `json:"identityDetails,omitempty"` + ObjectType string `json:"objectType"` + PolicyInfo PolicyInfo `json:"policyInfo"` + ProtectionErrorDetails *UserFacingError `json:"protectionErrorDetails,omitempty"` + ProtectionStatus *ProtectionStatusDetails `json:"protectionStatus,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ValidationType *ValidationType `json:"validationType,omitempty"` +} + +var _ json.Unmarshaler = &BackupInstance{} + +func (s *BackupInstance) UnmarshalJSON(bytes []byte) error { + type alias BackupInstance + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BackupInstance: %+v", err) + } + + s.CurrentProtectionState = decoded.CurrentProtectionState + s.DataSourceInfo = decoded.DataSourceInfo + s.DataSourceSetInfo = decoded.DataSourceSetInfo + s.FriendlyName = decoded.FriendlyName + s.IdentityDetails = decoded.IdentityDetails + s.ObjectType = decoded.ObjectType + s.PolicyInfo = decoded.PolicyInfo + s.ProtectionErrorDetails = decoded.ProtectionErrorDetails + s.ProtectionStatus = decoded.ProtectionStatus + s.ProvisioningState = decoded.ProvisioningState + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.ValidationType = decoded.ValidationType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BackupInstance into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["datasourceAuthCredentials"]; ok { + impl, err := unmarshalAuthCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'DatasourceAuthCredentials' for 'BackupInstance': %+v", err) + } + s.DatasourceAuthCredentials = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstanceresource.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstanceresource.go new file mode 100644 index 00000000000..2475f000f75 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_backupinstanceresource.go @@ -0,0 +1,17 @@ +package backupinstancesextensionrouting + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupInstanceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupInstance `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_baseresourceproperties.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_baseresourceproperties.go new file mode 100644 index 00000000000..9be644502dc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_baseresourceproperties.go @@ -0,0 +1,53 @@ +package backupinstancesextensionrouting + +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 BaseResourceProperties interface { +} + +// RawBaseResourcePropertiesImpl 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 RawBaseResourcePropertiesImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBaseResourcePropertiesImplementation(input []byte) (BaseResourceProperties, 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 BaseResourceProperties into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "DefaultResourceProperties") { + var out DefaultResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DefaultResourceProperties: %+v", err) + } + return out, nil + } + + out := RawBaseResourcePropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_blobbackupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_blobbackupdatasourceparameters.go new file mode 100644 index 00000000000..d865da90ac5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_blobbackupdatasourceparameters.go @@ -0,0 +1,41 @@ +package backupinstancesextensionrouting + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupDatasourceParameters = BlobBackupDatasourceParameters{} + +type BlobBackupDatasourceParameters struct { + ContainersList []string `json:"containersList"` + + // Fields inherited from BackupDatasourceParameters +} + +var _ json.Marshaler = BlobBackupDatasourceParameters{} + +func (s BlobBackupDatasourceParameters) MarshalJSON() ([]byte, error) { + type wrapper BlobBackupDatasourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BlobBackupDatasourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BlobBackupDatasourceParameters: %+v", err) + } + decoded["objectType"] = "BlobBackupDatasourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BlobBackupDatasourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasource.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasource.go new file mode 100644 index 00000000000..417ab5d0d0e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasource.go @@ -0,0 +1,52 @@ +package backupinstancesextensionrouting + +import ( + "encoding/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 Datasource struct { + DatasourceType *string `json:"datasourceType,omitempty"` + ObjectType *string `json:"objectType,omitempty"` + ResourceID string `json:"resourceID"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceProperties BaseResourceProperties `json:"resourceProperties"` + ResourceType *string `json:"resourceType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} + +var _ json.Unmarshaler = &Datasource{} + +func (s *Datasource) UnmarshalJSON(bytes []byte) error { + type alias Datasource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into Datasource: %+v", err) + } + + s.DatasourceType = decoded.DatasourceType + s.ObjectType = decoded.ObjectType + s.ResourceID = decoded.ResourceID + s.ResourceLocation = decoded.ResourceLocation + s.ResourceName = decoded.ResourceName + s.ResourceType = decoded.ResourceType + s.ResourceUri = decoded.ResourceUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Datasource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourceProperties"]; ok { + impl, err := unmarshalBaseResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourceProperties' for 'Datasource': %+v", err) + } + s.ResourceProperties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasourceset.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasourceset.go new file mode 100644 index 00000000000..ba4a143ead5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datasourceset.go @@ -0,0 +1,52 @@ +package backupinstancesextensionrouting + +import ( + "encoding/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 DatasourceSet struct { + DatasourceType *string `json:"datasourceType,omitempty"` + ObjectType *string `json:"objectType,omitempty"` + ResourceID string `json:"resourceID"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceProperties BaseResourceProperties `json:"resourceProperties"` + ResourceType *string `json:"resourceType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} + +var _ json.Unmarshaler = &DatasourceSet{} + +func (s *DatasourceSet) UnmarshalJSON(bytes []byte) error { + type alias DatasourceSet + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into DatasourceSet: %+v", err) + } + + s.DatasourceType = decoded.DatasourceType + s.ObjectType = decoded.ObjectType + s.ResourceID = decoded.ResourceID + s.ResourceLocation = decoded.ResourceLocation + s.ResourceName = decoded.ResourceName + s.ResourceType = decoded.ResourceType + s.ResourceUri = decoded.ResourceUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DatasourceSet into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourceProperties"]; ok { + impl, err := unmarshalBaseResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourceProperties' for 'DatasourceSet': %+v", err) + } + s.ResourceProperties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datastoreparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datastoreparameters.go new file mode 100644 index 00000000000..2bb312ac887 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_datastoreparameters.go @@ -0,0 +1,53 @@ +package backupinstancesextensionrouting + +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 DataStoreParameters interface { +} + +// RawDataStoreParametersImpl 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 RawDataStoreParametersImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalDataStoreParametersImplementation(input []byte) (DataStoreParameters, 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 DataStoreParameters into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureOperationalStoreParameters") { + var out AzureOperationalStoreParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureOperationalStoreParameters: %+v", err) + } + return out, nil + } + + out := RawDataStoreParametersImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_defaultresourceproperties.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_defaultresourceproperties.go new file mode 100644 index 00000000000..d86bee5be3e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_defaultresourceproperties.go @@ -0,0 +1,40 @@ +package backupinstancesextensionrouting + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BaseResourceProperties = DefaultResourceProperties{} + +type DefaultResourceProperties struct { + + // Fields inherited from BaseResourceProperties +} + +var _ json.Marshaler = DefaultResourceProperties{} + +func (s DefaultResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DefaultResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DefaultResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DefaultResourceProperties: %+v", err) + } + decoded["objectType"] = "DefaultResourceProperties" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DefaultResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_identitydetails.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_identitydetails.go new file mode 100644 index 00000000000..9d42f3fdf28 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_identitydetails.go @@ -0,0 +1,9 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityDetails struct { + UseSystemAssignedIdentity *bool `json:"useSystemAssignedIdentity,omitempty"` + UserAssignedIdentityArmUrl *string `json:"userAssignedIdentityArmUrl,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_innererror.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_innererror.go new file mode 100644 index 00000000000..cbb4bed7fc2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_innererror.go @@ -0,0 +1,10 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InnerError struct { + AdditionalInfo *map[string]string `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + EmbeddedInnerError *InnerError `json:"embeddedInnerError,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_kubernetesclusterbackupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_kubernetesclusterbackupdatasourceparameters.go new file mode 100644 index 00000000000..767ca36bde8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_kubernetesclusterbackupdatasourceparameters.go @@ -0,0 +1,48 @@ +package backupinstancesextensionrouting + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupDatasourceParameters = KubernetesClusterBackupDatasourceParameters{} + +type KubernetesClusterBackupDatasourceParameters struct { + BackupHookReferences *[]NamespacedNameResource `json:"backupHookReferences,omitempty"` + ExcludedNamespaces *[]string `json:"excludedNamespaces,omitempty"` + ExcludedResourceTypes *[]string `json:"excludedResourceTypes,omitempty"` + IncludeClusterScopeResources bool `json:"includeClusterScopeResources"` + IncludedNamespaces *[]string `json:"includedNamespaces,omitempty"` + IncludedResourceTypes *[]string `json:"includedResourceTypes,omitempty"` + LabelSelectors *[]string `json:"labelSelectors,omitempty"` + SnapshotVolumes bool `json:"snapshotVolumes"` + + // Fields inherited from BackupDatasourceParameters +} + +var _ json.Marshaler = KubernetesClusterBackupDatasourceParameters{} + +func (s KubernetesClusterBackupDatasourceParameters) MarshalJSON() ([]byte, error) { + type wrapper KubernetesClusterBackupDatasourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + decoded["objectType"] = "KubernetesClusterBackupDatasourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_namespacednameresource.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_namespacednameresource.go new file mode 100644 index 00000000000..f5eebec8f11 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_namespacednameresource.go @@ -0,0 +1,9 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacedNameResource struct { + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyinfo.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyinfo.go new file mode 100644 index 00000000000..3bf2c011486 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyinfo.go @@ -0,0 +1,10 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyInfo struct { + PolicyId string `json:"policyId"` + PolicyParameters *PolicyParameters `json:"policyParameters,omitempty"` + PolicyVersion *string `json:"policyVersion,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyparameters.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyparameters.go new file mode 100644 index 00000000000..7d6c28ba39e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_policyparameters.go @@ -0,0 +1,59 @@ +package backupinstancesextensionrouting + +import ( + "encoding/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 PolicyParameters struct { + BackupDatasourceParametersList *[]BackupDatasourceParameters `json:"backupDatasourceParametersList,omitempty"` + DataStoreParametersList *[]DataStoreParameters `json:"dataStoreParametersList,omitempty"` +} + +var _ json.Unmarshaler = &PolicyParameters{} + +func (s *PolicyParameters) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PolicyParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["backupDatasourceParametersList"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling BackupDatasourceParametersList into list []json.RawMessage: %+v", err) + } + + output := make([]BackupDatasourceParameters, 0) + for i, val := range listTemp { + impl, err := unmarshalBackupDatasourceParametersImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'BackupDatasourceParametersList' for 'PolicyParameters': %+v", i, err) + } + output = append(output, impl) + } + s.BackupDatasourceParametersList = &output + } + + if v, ok := temp["dataStoreParametersList"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling DataStoreParametersList into list []json.RawMessage: %+v", err) + } + + output := make([]DataStoreParameters, 0) + for i, val := range listTemp { + impl, err := unmarshalDataStoreParametersImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'DataStoreParametersList' for 'PolicyParameters': %+v", i, err) + } + output = append(output, impl) + } + s.DataStoreParametersList = &output + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_protectionstatusdetails.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_protectionstatusdetails.go new file mode 100644 index 00000000000..021103e85bc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_protectionstatusdetails.go @@ -0,0 +1,9 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionStatusDetails struct { + ErrorDetails *UserFacingError `json:"errorDetails,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstorebasedauthcredentials.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstorebasedauthcredentials.go new file mode 100644 index 00000000000..6ab1e305537 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstorebasedauthcredentials.go @@ -0,0 +1,41 @@ +package backupinstancesextensionrouting + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AuthCredentials = SecretStoreBasedAuthCredentials{} + +type SecretStoreBasedAuthCredentials struct { + SecretStoreResource *SecretStoreResource `json:"secretStoreResource,omitempty"` + + // Fields inherited from AuthCredentials +} + +var _ json.Marshaler = SecretStoreBasedAuthCredentials{} + +func (s SecretStoreBasedAuthCredentials) MarshalJSON() ([]byte, error) { + type wrapper SecretStoreBasedAuthCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SecretStoreBasedAuthCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SecretStoreBasedAuthCredentials: %+v", err) + } + decoded["objectType"] = "SecretStoreBasedAuthCredentials" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SecretStoreBasedAuthCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstoreresource.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstoreresource.go new file mode 100644 index 00000000000..46c758dc426 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_secretstoreresource.go @@ -0,0 +1,10 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretStoreResource struct { + SecretStoreType SecretStoreType `json:"secretStoreType"` + Uri *string `json:"uri,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_userfacingerror.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_userfacingerror.go new file mode 100644 index 00000000000..20efdbfdb58 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/model_userfacingerror.go @@ -0,0 +1,16 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingError struct { + Code *string `json:"code,omitempty"` + Details *[]UserFacingError `json:"details,omitempty"` + InnerError *InnerError `json:"innerError,omitempty"` + IsRetryable *bool `json:"isRetryable,omitempty"` + IsUserError *bool `json:"isUserError,omitempty"` + Message *string `json:"message,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + RecommendedAction *[]string `json:"recommendedAction,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/predicates.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/predicates.go new file mode 100644 index 00000000000..a524820a860 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/predicates.go @@ -0,0 +1,27 @@ +package backupinstancesextensionrouting + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupInstanceResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p BackupInstanceResourceOperationPredicate) Matches(input BackupInstanceResource) 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/dataprotection/2024-04-01/backupinstancesextensionrouting/version.go b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/version.go new file mode 100644 index 00000000000..2b728e2111b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting/version.go @@ -0,0 +1,12 @@ +package backupinstancesextensionrouting + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupinstancesextensionrouting/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/README.md b/resource-manager/dataprotection/2024-04-01/backuppolicies/README.md new file mode 100644 index 00000000000..61af8f9f833 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backuppolicies` Documentation + +The `backuppolicies` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/backuppolicies" +``` + + +### Client Initialization + +```go +client := backuppolicies.NewBackupPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := backuppolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupPolicyValue") + +payload := backuppolicies.BaseBackupPolicyResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := backuppolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupPolicyValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupPoliciesClient.Get` + +```go +ctx := context.TODO() +id := backuppolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupPolicyValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupPoliciesClient.List` + +```go +ctx := context.TODO() +id := backuppolicies.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +// 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/dataprotection/2024-04-01/backuppolicies/client.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/client.go new file mode 100644 index 00000000000..7867fb217cc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/client.go @@ -0,0 +1,26 @@ +package backuppolicies + +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 BackupPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewBackupPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupPoliciesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "backuppolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupPoliciesClient: %+v", err) + } + + return &BackupPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/constants.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/constants.go new file mode 100644 index 00000000000..0a08f75af9b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/constants.go @@ -0,0 +1,281 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AbsoluteMarker string + +const ( + AbsoluteMarkerAllBackup AbsoluteMarker = "AllBackup" + AbsoluteMarkerFirstOfDay AbsoluteMarker = "FirstOfDay" + AbsoluteMarkerFirstOfMonth AbsoluteMarker = "FirstOfMonth" + AbsoluteMarkerFirstOfWeek AbsoluteMarker = "FirstOfWeek" + AbsoluteMarkerFirstOfYear AbsoluteMarker = "FirstOfYear" +) + +func PossibleValuesForAbsoluteMarker() []string { + return []string{ + string(AbsoluteMarkerAllBackup), + string(AbsoluteMarkerFirstOfDay), + string(AbsoluteMarkerFirstOfMonth), + string(AbsoluteMarkerFirstOfWeek), + string(AbsoluteMarkerFirstOfYear), + } +} + +func (s *AbsoluteMarker) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAbsoluteMarker(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAbsoluteMarker(input string) (*AbsoluteMarker, error) { + vals := map[string]AbsoluteMarker{ + "allbackup": AbsoluteMarkerAllBackup, + "firstofday": AbsoluteMarkerFirstOfDay, + "firstofmonth": AbsoluteMarkerFirstOfMonth, + "firstofweek": AbsoluteMarkerFirstOfWeek, + "firstofyear": AbsoluteMarkerFirstOfYear, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AbsoluteMarker(input) + return &out, nil +} + +type DataStoreTypes string + +const ( + DataStoreTypesArchiveStore DataStoreTypes = "ArchiveStore" + DataStoreTypesOperationalStore DataStoreTypes = "OperationalStore" + DataStoreTypesVaultStore DataStoreTypes = "VaultStore" +) + +func PossibleValuesForDataStoreTypes() []string { + return []string{ + string(DataStoreTypesArchiveStore), + string(DataStoreTypesOperationalStore), + string(DataStoreTypesVaultStore), + } +} + +func (s *DataStoreTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataStoreTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataStoreTypes(input string) (*DataStoreTypes, error) { + vals := map[string]DataStoreTypes{ + "archivestore": DataStoreTypesArchiveStore, + "operationalstore": DataStoreTypesOperationalStore, + "vaultstore": DataStoreTypesVaultStore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataStoreTypes(input) + return &out, nil +} + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type Month string + +const ( + MonthApril Month = "April" + MonthAugust Month = "August" + MonthDecember Month = "December" + MonthFebruary Month = "February" + MonthJanuary Month = "January" + MonthJuly Month = "July" + MonthJune Month = "June" + MonthMarch Month = "March" + MonthMay Month = "May" + MonthNovember Month = "November" + MonthOctober Month = "October" + MonthSeptember Month = "September" +) + +func PossibleValuesForMonth() []string { + return []string{ + string(MonthApril), + string(MonthAugust), + string(MonthDecember), + string(MonthFebruary), + string(MonthJanuary), + string(MonthJuly), + string(MonthJune), + string(MonthMarch), + string(MonthMay), + string(MonthNovember), + string(MonthOctober), + string(MonthSeptember), + } +} + +func (s *Month) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonth(input string) (*Month, error) { + vals := map[string]Month{ + "april": MonthApril, + "august": MonthAugust, + "december": MonthDecember, + "february": MonthFebruary, + "january": MonthJanuary, + "july": MonthJuly, + "june": MonthJune, + "march": MonthMarch, + "may": MonthMay, + "november": MonthNovember, + "october": MonthOctober, + "september": MonthSeptember, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Month(input) + return &out, nil +} + +type WeekNumber string + +const ( + WeekNumberFirst WeekNumber = "First" + WeekNumberFourth WeekNumber = "Fourth" + WeekNumberLast WeekNumber = "Last" + WeekNumberSecond WeekNumber = "Second" + WeekNumberThird WeekNumber = "Third" +) + +func PossibleValuesForWeekNumber() []string { + return []string{ + string(WeekNumberFirst), + string(WeekNumberFourth), + string(WeekNumberLast), + string(WeekNumberSecond), + string(WeekNumberThird), + } +} + +func (s *WeekNumber) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWeekNumber(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWeekNumber(input string) (*WeekNumber, error) { + vals := map[string]WeekNumber{ + "first": WeekNumberFirst, + "fourth": WeekNumberFourth, + "last": WeekNumberLast, + "second": WeekNumberSecond, + "third": WeekNumberThird, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WeekNumber(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy.go new file mode 100644 index 00000000000..567587f55bd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy.go @@ -0,0 +1,139 @@ +package backuppolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupPolicyId{}) +} + +var _ resourceids.ResourceId = &BackupPolicyId{} + +// BackupPolicyId is a struct representing the Resource ID for a Backup Policy +type BackupPolicyId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + BackupPolicyName string +} + +// NewBackupPolicyID returns a new BackupPolicyId struct +func NewBackupPolicyID(subscriptionId string, resourceGroupName string, backupVaultName string, backupPolicyName string) BackupPolicyId { + return BackupPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + BackupPolicyName: backupPolicyName, + } +} + +// ParseBackupPolicyID parses 'input' into a BackupPolicyId +func ParseBackupPolicyID(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupPolicyIDInsensitively parses 'input' case-insensitively into a BackupPolicyId +// note: this method should only be used for API response data and not user input +func ParseBackupPolicyIDInsensitively(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.BackupPolicyName, ok = input.Parsed["backupPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupPolicyName", input) + } + + return nil +} + +// ValidateBackupPolicyID checks that 'input' can be parsed as a Backup Policy ID +func ValidateBackupPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Policy ID +func (id BackupPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.BackupPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Policy ID +func (id BackupPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupPolicies", "backupPolicies", "backupPolicies"), + resourceids.UserSpecifiedSegment("backupPolicyName", "backupPolicyValue"), + } +} + +// String returns a human-readable description of this Backup Policy ID +func (id BackupPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Backup Policy Name: %q", id.BackupPolicyName), + } + return fmt.Sprintf("Backup Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy_test.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy_test.go new file mode 100644 index 00000000000..061bc66c82e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backuppolicy_test.go @@ -0,0 +1,327 @@ +package backuppolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupPolicyId{} + +func TestNewBackupPolicyID(t *testing.T) { + id := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupPolicyValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.BackupPolicyName != "backupPolicyValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupPolicyName'", id.BackupPolicyName, "backupPolicyValue") + } +} + +func TestFormatBackupPolicyID(t *testing.T) { + actual := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupPolicyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupPolicies/backupPolicyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupPolicies/backupPolicyValue", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupPolicyName: "backupPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupPolicies/backupPolicyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestParseBackupPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupPolicies/backupPolicyValue", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupPolicyName: "backupPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupPolicies/backupPolicyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPpOlIcIeS/bAcKuPpOlIcYvAlUe", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + BackupPolicyName: "bAcKuPpOlIcYvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPpOlIcIeS/bAcKuPpOlIcYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestSegmentsForBackupPolicyId(t *testing.T) { + segments := BackupPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault.go new file mode 100644 index 00000000000..630fbdb1a15 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault.go @@ -0,0 +1,130 @@ +package backuppolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault_test.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault_test.go new file mode 100644 index 00000000000..3f065e5447a --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/id_backupvault_test.go @@ -0,0 +1,282 @@ +package backuppolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/dataprotection/2024-04-01/backuppolicies/method_createorupdate.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_createorupdate.go new file mode 100644 index 00000000000..fbea2f083fb --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_createorupdate.go @@ -0,0 +1,58 @@ +package backuppolicies + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BaseBackupPolicyResource +} + +// CreateOrUpdate ... +func (c BackupPoliciesClient) CreateOrUpdate(ctx context.Context, id BackupPolicyId, input BaseBackupPolicyResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BaseBackupPolicyResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/method_delete.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_delete.go new file mode 100644 index 00000000000..8b9659f79fa --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_delete.go @@ -0,0 +1,47 @@ +package backuppolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c BackupPoliciesClient) Delete(ctx context.Context, id BackupPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/method_get.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_get.go new file mode 100644 index 00000000000..2275adb94b5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_get.go @@ -0,0 +1,54 @@ +package backuppolicies + +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 *BaseBackupPolicyResource +} + +// Get ... +func (c BackupPoliciesClient) Get(ctx context.Context, id BackupPolicyId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BaseBackupPolicyResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/method_list.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_list.go new file mode 100644 index 00000000000..182944deb5e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/method_list.go @@ -0,0 +1,91 @@ +package backuppolicies + +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 *[]BaseBackupPolicyResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BaseBackupPolicyResource +} + +// List ... +func (c BackupPoliciesClient) List(ctx context.Context, id BackupVaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backupPolicies", 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 *[]BaseBackupPolicyResource `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 BackupPoliciesClient) ListComplete(ctx context.Context, id BackupVaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, BaseBackupPolicyResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id BackupVaultId, predicate BaseBackupPolicyResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BaseBackupPolicyResource, 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/dataprotection/2024-04-01/backuppolicies/model_absolutedeleteoption.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_absolutedeleteoption.go new file mode 100644 index 00000000000..a9aaf47dcb7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_absolutedeleteoption.go @@ -0,0 +1,41 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DeleteOption = AbsoluteDeleteOption{} + +type AbsoluteDeleteOption struct { + + // Fields inherited from DeleteOption + Duration string `json:"duration"` +} + +var _ json.Marshaler = AbsoluteDeleteOption{} + +func (s AbsoluteDeleteOption) MarshalJSON() ([]byte, error) { + type wrapper AbsoluteDeleteOption + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AbsoluteDeleteOption: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AbsoluteDeleteOption: %+v", err) + } + decoded["objectType"] = "AbsoluteDeleteOption" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AbsoluteDeleteOption: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtaggingcriteria.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtaggingcriteria.go new file mode 100644 index 00000000000..e74b150de31 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtaggingcriteria.go @@ -0,0 +1,8 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdhocBasedTaggingCriteria struct { + TagInfo *RetentionTag `json:"tagInfo,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtriggercontext.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtriggercontext.go new file mode 100644 index 00000000000..5505a40b8a6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_adhocbasedtriggercontext.go @@ -0,0 +1,41 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TriggerContext = AdhocBasedTriggerContext{} + +type AdhocBasedTriggerContext struct { + TaggingCriteria AdhocBasedTaggingCriteria `json:"taggingCriteria"` + + // Fields inherited from TriggerContext +} + +var _ json.Marshaler = AdhocBasedTriggerContext{} + +func (s AdhocBasedTriggerContext) MarshalJSON() ([]byte, error) { + type wrapper AdhocBasedTriggerContext + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AdhocBasedTriggerContext: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AdhocBasedTriggerContext: %+v", err) + } + decoded["objectType"] = "AdhocBasedTriggerContext" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AdhocBasedTriggerContext: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackupparams.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackupparams.go new file mode 100644 index 00000000000..024401c3d86 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackupparams.go @@ -0,0 +1,41 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupParameters = AzureBackupParams{} + +type AzureBackupParams struct { + BackupType string `json:"backupType"` + + // Fields inherited from BackupParameters +} + +var _ json.Marshaler = AzureBackupParams{} + +func (s AzureBackupParams) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupParams + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupParams: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupParams: %+v", err) + } + decoded["objectType"] = "AzureBackupParams" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupParams: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackuprule.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackuprule.go new file mode 100644 index 00000000000..884536bf720 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azurebackuprule.go @@ -0,0 +1,79 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BasePolicyRule = AzureBackupRule{} + +type AzureBackupRule struct { + BackupParameters BackupParameters `json:"backupParameters"` + DataStore DataStoreInfoBase `json:"dataStore"` + Trigger TriggerContext `json:"trigger"` + + // Fields inherited from BasePolicyRule + Name string `json:"name"` +} + +var _ json.Marshaler = AzureBackupRule{} + +func (s AzureBackupRule) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupRule: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupRule: %+v", err) + } + decoded["objectType"] = "AzureBackupRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupRule: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureBackupRule{} + +func (s *AzureBackupRule) UnmarshalJSON(bytes []byte) error { + type alias AzureBackupRule + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureBackupRule: %+v", err) + } + + s.DataStore = decoded.DataStore + s.Name = decoded.Name + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureBackupRule into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["backupParameters"]; ok { + impl, err := unmarshalBackupParametersImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'BackupParameters' for 'AzureBackupRule': %+v", err) + } + s.BackupParameters = impl + } + + if v, ok := temp["trigger"]; ok { + impl, err := unmarshalTriggerContextImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Trigger' for 'AzureBackupRule': %+v", err) + } + s.Trigger = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azureretentionrule.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azureretentionrule.go new file mode 100644 index 00000000000..1362ef8628d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_azureretentionrule.go @@ -0,0 +1,43 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BasePolicyRule = AzureRetentionRule{} + +type AzureRetentionRule struct { + IsDefault *bool `json:"isDefault,omitempty"` + Lifecycles []SourceLifeCycle `json:"lifecycles"` + + // Fields inherited from BasePolicyRule + Name string `json:"name"` +} + +var _ json.Marshaler = AzureRetentionRule{} + +func (s AzureRetentionRule) MarshalJSON() ([]byte, error) { + type wrapper AzureRetentionRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureRetentionRule: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureRetentionRule: %+v", err) + } + decoded["objectType"] = "AzureRetentionRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureRetentionRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupcriteria.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupcriteria.go new file mode 100644 index 00000000000..ae5e3acf7f9 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupcriteria.go @@ -0,0 +1,53 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupCriteria interface { +} + +// RawBackupCriteriaImpl 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 RawBackupCriteriaImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBackupCriteriaImplementation(input []byte) (BackupCriteria, 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 BackupCriteria into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "ScheduleBasedBackupCriteria") { + var out ScheduleBasedBackupCriteria + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ScheduleBasedBackupCriteria: %+v", err) + } + return out, nil + } + + out := RawBackupCriteriaImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupparameters.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupparameters.go new file mode 100644 index 00000000000..2cd46e5bbe7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupparameters.go @@ -0,0 +1,53 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupParameters interface { +} + +// RawBackupParametersImpl 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 RawBackupParametersImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBackupParametersImplementation(input []byte) (BackupParameters, 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 BackupParameters into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupParams") { + var out AzureBackupParams + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupParams: %+v", err) + } + return out, nil + } + + out := RawBackupParametersImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backuppolicy.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backuppolicy.go new file mode 100644 index 00000000000..5b770c9a733 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backuppolicy.go @@ -0,0 +1,77 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BaseBackupPolicy = BackupPolicy{} + +type BackupPolicy struct { + PolicyRules []BasePolicyRule `json:"policyRules"` + + // Fields inherited from BaseBackupPolicy + DatasourceTypes []string `json:"datasourceTypes"` +} + +var _ json.Marshaler = BackupPolicy{} + +func (s BackupPolicy) MarshalJSON() ([]byte, error) { + type wrapper BackupPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BackupPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BackupPolicy: %+v", err) + } + decoded["objectType"] = "BackupPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BackupPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &BackupPolicy{} + +func (s *BackupPolicy) UnmarshalJSON(bytes []byte) error { + type alias BackupPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BackupPolicy: %+v", err) + } + + s.DatasourceTypes = decoded.DatasourceTypes + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BackupPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["policyRules"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling PolicyRules into list []json.RawMessage: %+v", err) + } + + output := make([]BasePolicyRule, 0) + for i, val := range listTemp { + impl, err := unmarshalBasePolicyRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'PolicyRules' for 'BackupPolicy': %+v", i, err) + } + output = append(output, impl) + } + s.PolicyRules = output + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupschedule.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupschedule.go new file mode 100644 index 00000000000..47d41f51d4c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_backupschedule.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupSchedule struct { + RepeatingTimeIntervals []string `json:"repeatingTimeIntervals"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicy.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicy.go new file mode 100644 index 00000000000..5da7096ec0c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicy.go @@ -0,0 +1,53 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseBackupPolicy interface { +} + +// RawBaseBackupPolicyImpl 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 RawBaseBackupPolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBaseBackupPolicyImplementation(input []byte) (BaseBackupPolicy, 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 BaseBackupPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "BackupPolicy") { + var out BackupPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BackupPolicy: %+v", err) + } + return out, nil + } + + out := RawBaseBackupPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicyresource.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicyresource.go new file mode 100644 index 00000000000..dbc62cc6103 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basebackuppolicyresource.go @@ -0,0 +1,48 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseBackupPolicyResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties BaseBackupPolicy `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &BaseBackupPolicyResource{} + +func (s *BaseBackupPolicyResource) UnmarshalJSON(bytes []byte) error { + type alias BaseBackupPolicyResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BaseBackupPolicyResource: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BaseBackupPolicyResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalBaseBackupPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'BaseBackupPolicyResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basepolicyrule.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basepolicyrule.go new file mode 100644 index 00000000000..2434dc31521 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_basepolicyrule.go @@ -0,0 +1,61 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BasePolicyRule interface { +} + +// RawBasePolicyRuleImpl 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 RawBasePolicyRuleImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBasePolicyRuleImplementation(input []byte) (BasePolicyRule, 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 BasePolicyRule into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupRule") { + var out AzureBackupRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureRetentionRule") { + var out AzureRetentionRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureRetentionRule: %+v", err) + } + return out, nil + } + + out := RawBasePolicyRuleImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyonexpiryoption.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyonexpiryoption.go new file mode 100644 index 00000000000..38c92a43d50 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyonexpiryoption.go @@ -0,0 +1,40 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CopyOption = CopyOnExpiryOption{} + +type CopyOnExpiryOption struct { + + // Fields inherited from CopyOption +} + +var _ json.Marshaler = CopyOnExpiryOption{} + +func (s CopyOnExpiryOption) MarshalJSON() ([]byte, error) { + type wrapper CopyOnExpiryOption + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CopyOnExpiryOption: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CopyOnExpiryOption: %+v", err) + } + decoded["objectType"] = "CopyOnExpiryOption" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CopyOnExpiryOption: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyoption.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyoption.go new file mode 100644 index 00000000000..8015dcb6bfd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_copyoption.go @@ -0,0 +1,69 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CopyOption interface { +} + +// RawCopyOptionImpl 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 RawCopyOptionImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalCopyOptionImplementation(input []byte) (CopyOption, 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 CopyOption into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "CopyOnExpiryOption") { + var out CopyOnExpiryOption + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CopyOnExpiryOption: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "CustomCopyOption") { + var out CustomCopyOption + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomCopyOption: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImmediateCopyOption") { + var out ImmediateCopyOption + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImmediateCopyOption: %+v", err) + } + return out, nil + } + + out := RawCopyOptionImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_customcopyoption.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_customcopyoption.go new file mode 100644 index 00000000000..f450054e89a --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_customcopyoption.go @@ -0,0 +1,41 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CopyOption = CustomCopyOption{} + +type CustomCopyOption struct { + Duration *string `json:"duration,omitempty"` + + // Fields inherited from CopyOption +} + +var _ json.Marshaler = CustomCopyOption{} + +func (s CustomCopyOption) MarshalJSON() ([]byte, error) { + type wrapper CustomCopyOption + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomCopyOption: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomCopyOption: %+v", err) + } + decoded["objectType"] = "CustomCopyOption" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomCopyOption: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_datastoreinfobase.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_datastoreinfobase.go new file mode 100644 index 00000000000..d462ed4c6f6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_datastoreinfobase.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataStoreInfoBase struct { + DataStoreType DataStoreTypes `json:"dataStoreType"` + ObjectType string `json:"objectType"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_day.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_day.go new file mode 100644 index 00000000000..c46c7f57129 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_day.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Day struct { + Date *int64 `json:"date,omitempty"` + IsLast *bool `json:"isLast,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_deleteoption.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_deleteoption.go new file mode 100644 index 00000000000..d8ac5dc7882 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_deleteoption.go @@ -0,0 +1,53 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOption interface { +} + +// RawDeleteOptionImpl 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 RawDeleteOptionImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalDeleteOptionImplementation(input []byte) (DeleteOption, 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 DeleteOption into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AbsoluteDeleteOption") { + var out AbsoluteDeleteOption + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AbsoluteDeleteOption: %+v", err) + } + return out, nil + } + + out := RawDeleteOptionImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_immediatecopyoption.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_immediatecopyoption.go new file mode 100644 index 00000000000..a8e54686cc9 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_immediatecopyoption.go @@ -0,0 +1,40 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ CopyOption = ImmediateCopyOption{} + +type ImmediateCopyOption struct { + + // Fields inherited from CopyOption +} + +var _ json.Marshaler = ImmediateCopyOption{} + +func (s ImmediateCopyOption) MarshalJSON() ([]byte, error) { + type wrapper ImmediateCopyOption + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImmediateCopyOption: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImmediateCopyOption: %+v", err) + } + decoded["objectType"] = "ImmediateCopyOption" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImmediateCopyOption: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_retentiontag.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_retentiontag.go new file mode 100644 index 00000000000..f9a6dff3e17 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_retentiontag.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionTag struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + TagName string `json:"tagName"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedbackupcriteria.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedbackupcriteria.go new file mode 100644 index 00000000000..6e2c614f630 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedbackupcriteria.go @@ -0,0 +1,46 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupCriteria = ScheduleBasedBackupCriteria{} + +type ScheduleBasedBackupCriteria struct { + AbsoluteCriteria *[]AbsoluteMarker `json:"absoluteCriteria,omitempty"` + DaysOfMonth *[]Day `json:"daysOfMonth,omitempty"` + DaysOfTheWeek *[]DayOfWeek `json:"daysOfTheWeek,omitempty"` + MonthsOfYear *[]Month `json:"monthsOfYear,omitempty"` + ScheduleTimes *[]string `json:"scheduleTimes,omitempty"` + WeeksOfTheMonth *[]WeekNumber `json:"weeksOfTheMonth,omitempty"` + + // Fields inherited from BackupCriteria +} + +var _ json.Marshaler = ScheduleBasedBackupCriteria{} + +func (s ScheduleBasedBackupCriteria) MarshalJSON() ([]byte, error) { + type wrapper ScheduleBasedBackupCriteria + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ScheduleBasedBackupCriteria: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ScheduleBasedBackupCriteria: %+v", err) + } + decoded["objectType"] = "ScheduleBasedBackupCriteria" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ScheduleBasedBackupCriteria: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedtriggercontext.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedtriggercontext.go new file mode 100644 index 00000000000..c7f96a85c13 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_schedulebasedtriggercontext.go @@ -0,0 +1,42 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TriggerContext = ScheduleBasedTriggerContext{} + +type ScheduleBasedTriggerContext struct { + Schedule BackupSchedule `json:"schedule"` + TaggingCriteria []TaggingCriteria `json:"taggingCriteria"` + + // Fields inherited from TriggerContext +} + +var _ json.Marshaler = ScheduleBasedTriggerContext{} + +func (s ScheduleBasedTriggerContext) MarshalJSON() ([]byte, error) { + type wrapper ScheduleBasedTriggerContext + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ScheduleBasedTriggerContext: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ScheduleBasedTriggerContext: %+v", err) + } + decoded["objectType"] = "ScheduleBasedTriggerContext" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ScheduleBasedTriggerContext: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_sourcelifecycle.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_sourcelifecycle.go new file mode 100644 index 00000000000..7538681c1b2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_sourcelifecycle.go @@ -0,0 +1,42 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceLifeCycle struct { + DeleteAfter DeleteOption `json:"deleteAfter"` + SourceDataStore DataStoreInfoBase `json:"sourceDataStore"` + TargetDataStoreCopySettings *[]TargetCopySetting `json:"targetDataStoreCopySettings,omitempty"` +} + +var _ json.Unmarshaler = &SourceLifeCycle{} + +func (s *SourceLifeCycle) UnmarshalJSON(bytes []byte) error { + type alias SourceLifeCycle + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SourceLifeCycle: %+v", err) + } + + s.SourceDataStore = decoded.SourceDataStore + s.TargetDataStoreCopySettings = decoded.TargetDataStoreCopySettings + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SourceLifeCycle into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["deleteAfter"]; ok { + impl, err := unmarshalDeleteOptionImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'DeleteAfter' for 'SourceLifeCycle': %+v", err) + } + s.DeleteAfter = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_taggingcriteria.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_taggingcriteria.go new file mode 100644 index 00000000000..71c094c4d32 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_taggingcriteria.go @@ -0,0 +1,53 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TaggingCriteria struct { + Criteria *[]BackupCriteria `json:"criteria,omitempty"` + IsDefault bool `json:"isDefault"` + TagInfo RetentionTag `json:"tagInfo"` + TaggingPriority int64 `json:"taggingPriority"` +} + +var _ json.Unmarshaler = &TaggingCriteria{} + +func (s *TaggingCriteria) UnmarshalJSON(bytes []byte) error { + type alias TaggingCriteria + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into TaggingCriteria: %+v", err) + } + + s.IsDefault = decoded.IsDefault + s.TagInfo = decoded.TagInfo + s.TaggingPriority = decoded.TaggingPriority + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TaggingCriteria into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["criteria"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Criteria into list []json.RawMessage: %+v", err) + } + + output := make([]BackupCriteria, 0) + for i, val := range listTemp { + impl, err := unmarshalBackupCriteriaImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Criteria' for 'TaggingCriteria': %+v", i, err) + } + output = append(output, impl) + } + s.Criteria = &output + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_targetcopysetting.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_targetcopysetting.go new file mode 100644 index 00000000000..2c3e72d496e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_targetcopysetting.go @@ -0,0 +1,40 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetCopySetting struct { + CopyAfter CopyOption `json:"copyAfter"` + DataStore DataStoreInfoBase `json:"dataStore"` +} + +var _ json.Unmarshaler = &TargetCopySetting{} + +func (s *TargetCopySetting) UnmarshalJSON(bytes []byte) error { + type alias TargetCopySetting + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into TargetCopySetting: %+v", err) + } + + s.DataStore = decoded.DataStore + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TargetCopySetting into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["copyAfter"]; ok { + impl, err := unmarshalCopyOptionImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'CopyAfter' for 'TargetCopySetting': %+v", err) + } + s.CopyAfter = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/model_triggercontext.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_triggercontext.go new file mode 100644 index 00000000000..866643b9b21 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/model_triggercontext.go @@ -0,0 +1,61 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerContext interface { +} + +// RawTriggerContextImpl 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 RawTriggerContextImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalTriggerContextImplementation(input []byte) (TriggerContext, 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 TriggerContext into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AdhocBasedTriggerContext") { + var out AdhocBasedTriggerContext + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AdhocBasedTriggerContext: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScheduleBasedTriggerContext") { + var out ScheduleBasedTriggerContext + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ScheduleBasedTriggerContext: %+v", err) + } + return out, nil + } + + out := RawTriggerContextImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/backuppolicies/predicates.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/predicates.go new file mode 100644 index 00000000000..e53bb0c1ed4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/predicates.go @@ -0,0 +1,27 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseBackupPolicyResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p BaseBackupPolicyResourceOperationPredicate) Matches(input BaseBackupPolicyResource) 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/dataprotection/2024-04-01/backuppolicies/version.go b/resource-manager/dataprotection/2024-04-01/backuppolicies/version.go new file mode 100644 index 00000000000..30df912a279 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backuppolicies/version.go @@ -0,0 +1,12 @@ +package backuppolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backuppolicies/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/README.md b/resource-manager/dataprotection/2024-04-01/backupvaults/README.md new file mode 100644 index 00000000000..7e3162863e6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/README.md @@ -0,0 +1,138 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backupvaults` Documentation + +The `backupvaults` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/backupvaults" +``` + + +### Client Initialization + +```go +client := backupvaults.NewBackupVaultsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupVaultsClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := backupvaults.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +payload := backupvaults.CheckNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupVaultsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +payload := backupvaults.BackupVaultResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, backupvaults.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupVaultsClient.Delete` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BackupVaultsClient.Get` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +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: `BackupVaultsClient.GetInResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.GetInResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.GetInResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BackupVaultsClient.GetInSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.GetInSubscription(ctx, id)` can be used to do batched pagination +items, err := client.GetInSubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BackupVaultsClient.Update` + +```go +ctx := context.TODO() +id := backupvaults.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +payload := backupvaults.PatchResourceRequestInput{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload, backupvaults.DefaultUpdateOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/client.go b/resource-manager/dataprotection/2024-04-01/backupvaults/client.go new file mode 100644 index 00000000000..7a4dd932170 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/client.go @@ -0,0 +1,26 @@ +package backupvaults + +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 BackupVaultsClient struct { + Client *resourcemanager.Client +} + +func NewBackupVaultsClientWithBaseURI(sdkApi sdkEnv.Api) (*BackupVaultsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "backupvaults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BackupVaultsClient: %+v", err) + } + + return &BackupVaultsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/constants.go b/resource-manager/dataprotection/2024-04-01/backupvaults/constants.go new file mode 100644 index 00000000000..731af792200 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/constants.go @@ -0,0 +1,653 @@ +package backupvaults + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertsState string + +const ( + AlertsStateDisabled AlertsState = "Disabled" + AlertsStateEnabled AlertsState = "Enabled" +) + +func PossibleValuesForAlertsState() []string { + return []string{ + string(AlertsStateDisabled), + string(AlertsStateEnabled), + } +} + +func (s *AlertsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlertsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlertsState(input string) (*AlertsState, error) { + vals := map[string]AlertsState{ + "disabled": AlertsStateDisabled, + "enabled": AlertsStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AlertsState(input) + return &out, nil +} + +type BCDRSecurityLevel string + +const ( + BCDRSecurityLevelExcellent BCDRSecurityLevel = "Excellent" + BCDRSecurityLevelFair BCDRSecurityLevel = "Fair" + BCDRSecurityLevelGood BCDRSecurityLevel = "Good" + BCDRSecurityLevelNotSupported BCDRSecurityLevel = "NotSupported" + BCDRSecurityLevelPoor BCDRSecurityLevel = "Poor" +) + +func PossibleValuesForBCDRSecurityLevel() []string { + return []string{ + string(BCDRSecurityLevelExcellent), + string(BCDRSecurityLevelFair), + string(BCDRSecurityLevelGood), + string(BCDRSecurityLevelNotSupported), + string(BCDRSecurityLevelPoor), + } +} + +func (s *BCDRSecurityLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBCDRSecurityLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBCDRSecurityLevel(input string) (*BCDRSecurityLevel, error) { + vals := map[string]BCDRSecurityLevel{ + "excellent": BCDRSecurityLevelExcellent, + "fair": BCDRSecurityLevelFair, + "good": BCDRSecurityLevelGood, + "notsupported": BCDRSecurityLevelNotSupported, + "poor": BCDRSecurityLevelPoor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BCDRSecurityLevel(input) + return &out, nil +} + +type CrossRegionRestoreState string + +const ( + CrossRegionRestoreStateDisabled CrossRegionRestoreState = "Disabled" + CrossRegionRestoreStateEnabled CrossRegionRestoreState = "Enabled" +) + +func PossibleValuesForCrossRegionRestoreState() []string { + return []string{ + string(CrossRegionRestoreStateDisabled), + string(CrossRegionRestoreStateEnabled), + } +} + +func (s *CrossRegionRestoreState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCrossRegionRestoreState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCrossRegionRestoreState(input string) (*CrossRegionRestoreState, error) { + vals := map[string]CrossRegionRestoreState{ + "disabled": CrossRegionRestoreStateDisabled, + "enabled": CrossRegionRestoreStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CrossRegionRestoreState(input) + return &out, nil +} + +type CrossSubscriptionRestoreState string + +const ( + CrossSubscriptionRestoreStateDisabled CrossSubscriptionRestoreState = "Disabled" + CrossSubscriptionRestoreStateEnabled CrossSubscriptionRestoreState = "Enabled" + CrossSubscriptionRestoreStatePermanentlyDisabled CrossSubscriptionRestoreState = "PermanentlyDisabled" +) + +func PossibleValuesForCrossSubscriptionRestoreState() []string { + return []string{ + string(CrossSubscriptionRestoreStateDisabled), + string(CrossSubscriptionRestoreStateEnabled), + string(CrossSubscriptionRestoreStatePermanentlyDisabled), + } +} + +func (s *CrossSubscriptionRestoreState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCrossSubscriptionRestoreState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCrossSubscriptionRestoreState(input string) (*CrossSubscriptionRestoreState, error) { + vals := map[string]CrossSubscriptionRestoreState{ + "disabled": CrossSubscriptionRestoreStateDisabled, + "enabled": CrossSubscriptionRestoreStateEnabled, + "permanentlydisabled": CrossSubscriptionRestoreStatePermanentlyDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CrossSubscriptionRestoreState(input) + return &out, nil +} + +type EncryptionState string + +const ( + EncryptionStateDisabled EncryptionState = "Disabled" + EncryptionStateEnabled EncryptionState = "Enabled" + EncryptionStateInconsistent EncryptionState = "Inconsistent" +) + +func PossibleValuesForEncryptionState() []string { + return []string{ + string(EncryptionStateDisabled), + string(EncryptionStateEnabled), + string(EncryptionStateInconsistent), + } +} + +func (s *EncryptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEncryptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEncryptionState(input string) (*EncryptionState, error) { + vals := map[string]EncryptionState{ + "disabled": EncryptionStateDisabled, + "enabled": EncryptionStateEnabled, + "inconsistent": EncryptionStateInconsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionState(input) + return &out, nil +} + +type IdentityType string + +const ( + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + IdentityTypeUserAssigned IdentityType = "UserAssigned" +) + +func PossibleValuesForIdentityType() []string { + return []string{ + string(IdentityTypeSystemAssigned), + string(IdentityTypeUserAssigned), + } +} + +func (s *IdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIdentityType(input string) (*IdentityType, error) { + vals := map[string]IdentityType{ + "systemassigned": IdentityTypeSystemAssigned, + "userassigned": IdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IdentityType(input) + return &out, nil +} + +type ImmutabilityState string + +const ( + ImmutabilityStateDisabled ImmutabilityState = "Disabled" + ImmutabilityStateLocked ImmutabilityState = "Locked" + ImmutabilityStateUnlocked ImmutabilityState = "Unlocked" +) + +func PossibleValuesForImmutabilityState() []string { + return []string{ + string(ImmutabilityStateDisabled), + string(ImmutabilityStateLocked), + string(ImmutabilityStateUnlocked), + } +} + +func (s *ImmutabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImmutabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseImmutabilityState(input string) (*ImmutabilityState, error) { + vals := map[string]ImmutabilityState{ + "disabled": ImmutabilityStateDisabled, + "locked": ImmutabilityStateLocked, + "unlocked": ImmutabilityStateUnlocked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ImmutabilityState(input) + return &out, nil +} + +type InfrastructureEncryptionState string + +const ( + InfrastructureEncryptionStateDisabled InfrastructureEncryptionState = "Disabled" + InfrastructureEncryptionStateEnabled InfrastructureEncryptionState = "Enabled" +) + +func PossibleValuesForInfrastructureEncryptionState() []string { + return []string{ + string(InfrastructureEncryptionStateDisabled), + string(InfrastructureEncryptionStateEnabled), + } +} + +func (s *InfrastructureEncryptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInfrastructureEncryptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInfrastructureEncryptionState(input string) (*InfrastructureEncryptionState, error) { + vals := map[string]InfrastructureEncryptionState{ + "disabled": InfrastructureEncryptionStateDisabled, + "enabled": InfrastructureEncryptionStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InfrastructureEncryptionState(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceMoveState string + +const ( + ResourceMoveStateCommitFailed ResourceMoveState = "CommitFailed" + ResourceMoveStateCommitTimedout ResourceMoveState = "CommitTimedout" + ResourceMoveStateCriticalFailure ResourceMoveState = "CriticalFailure" + ResourceMoveStateFailed ResourceMoveState = "Failed" + ResourceMoveStateInProgress ResourceMoveState = "InProgress" + ResourceMoveStateMoveSucceeded ResourceMoveState = "MoveSucceeded" + ResourceMoveStatePartialSuccess ResourceMoveState = "PartialSuccess" + ResourceMoveStatePrepareFailed ResourceMoveState = "PrepareFailed" + ResourceMoveStatePrepareTimedout ResourceMoveState = "PrepareTimedout" + ResourceMoveStateUnknown ResourceMoveState = "Unknown" +) + +func PossibleValuesForResourceMoveState() []string { + return []string{ + string(ResourceMoveStateCommitFailed), + string(ResourceMoveStateCommitTimedout), + string(ResourceMoveStateCriticalFailure), + string(ResourceMoveStateFailed), + string(ResourceMoveStateInProgress), + string(ResourceMoveStateMoveSucceeded), + string(ResourceMoveStatePartialSuccess), + string(ResourceMoveStatePrepareFailed), + string(ResourceMoveStatePrepareTimedout), + string(ResourceMoveStateUnknown), + } +} + +func (s *ResourceMoveState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceMoveState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceMoveState(input string) (*ResourceMoveState, error) { + vals := map[string]ResourceMoveState{ + "commitfailed": ResourceMoveStateCommitFailed, + "committimedout": ResourceMoveStateCommitTimedout, + "criticalfailure": ResourceMoveStateCriticalFailure, + "failed": ResourceMoveStateFailed, + "inprogress": ResourceMoveStateInProgress, + "movesucceeded": ResourceMoveStateMoveSucceeded, + "partialsuccess": ResourceMoveStatePartialSuccess, + "preparefailed": ResourceMoveStatePrepareFailed, + "preparetimedout": ResourceMoveStatePrepareTimedout, + "unknown": ResourceMoveStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceMoveState(input) + return &out, nil +} + +type SecureScoreLevel string + +const ( + SecureScoreLevelAdequate SecureScoreLevel = "Adequate" + SecureScoreLevelMaximum SecureScoreLevel = "Maximum" + SecureScoreLevelMinimum SecureScoreLevel = "Minimum" + SecureScoreLevelNone SecureScoreLevel = "None" + SecureScoreLevelNotSupported SecureScoreLevel = "NotSupported" +) + +func PossibleValuesForSecureScoreLevel() []string { + return []string{ + string(SecureScoreLevelAdequate), + string(SecureScoreLevelMaximum), + string(SecureScoreLevelMinimum), + string(SecureScoreLevelNone), + string(SecureScoreLevelNotSupported), + } +} + +func (s *SecureScoreLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecureScoreLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecureScoreLevel(input string) (*SecureScoreLevel, error) { + vals := map[string]SecureScoreLevel{ + "adequate": SecureScoreLevelAdequate, + "maximum": SecureScoreLevelMaximum, + "minimum": SecureScoreLevelMinimum, + "none": SecureScoreLevelNone, + "notsupported": SecureScoreLevelNotSupported, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecureScoreLevel(input) + return &out, nil +} + +type SoftDeleteState string + +const ( + SoftDeleteStateAlwaysOn SoftDeleteState = "AlwaysOn" + SoftDeleteStateOff SoftDeleteState = "Off" + SoftDeleteStateOn SoftDeleteState = "On" +) + +func PossibleValuesForSoftDeleteState() []string { + return []string{ + string(SoftDeleteStateAlwaysOn), + string(SoftDeleteStateOff), + string(SoftDeleteStateOn), + } +} + +func (s *SoftDeleteState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSoftDeleteState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSoftDeleteState(input string) (*SoftDeleteState, error) { + vals := map[string]SoftDeleteState{ + "alwayson": SoftDeleteStateAlwaysOn, + "off": SoftDeleteStateOff, + "on": SoftDeleteStateOn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SoftDeleteState(input) + return &out, nil +} + +type StorageSettingStoreTypes string + +const ( + StorageSettingStoreTypesArchiveStore StorageSettingStoreTypes = "ArchiveStore" + StorageSettingStoreTypesOperationalStore StorageSettingStoreTypes = "OperationalStore" + StorageSettingStoreTypesVaultStore StorageSettingStoreTypes = "VaultStore" +) + +func PossibleValuesForStorageSettingStoreTypes() []string { + return []string{ + string(StorageSettingStoreTypesArchiveStore), + string(StorageSettingStoreTypesOperationalStore), + string(StorageSettingStoreTypesVaultStore), + } +} + +func (s *StorageSettingStoreTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageSettingStoreTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageSettingStoreTypes(input string) (*StorageSettingStoreTypes, error) { + vals := map[string]StorageSettingStoreTypes{ + "archivestore": StorageSettingStoreTypesArchiveStore, + "operationalstore": StorageSettingStoreTypesOperationalStore, + "vaultstore": StorageSettingStoreTypesVaultStore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageSettingStoreTypes(input) + return &out, nil +} + +type StorageSettingTypes string + +const ( + StorageSettingTypesGeoRedundant StorageSettingTypes = "GeoRedundant" + StorageSettingTypesLocallyRedundant StorageSettingTypes = "LocallyRedundant" + StorageSettingTypesZoneRedundant StorageSettingTypes = "ZoneRedundant" +) + +func PossibleValuesForStorageSettingTypes() []string { + return []string{ + string(StorageSettingTypesGeoRedundant), + string(StorageSettingTypesLocallyRedundant), + string(StorageSettingTypesZoneRedundant), + } +} + +func (s *StorageSettingTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageSettingTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageSettingTypes(input string) (*StorageSettingTypes, error) { + vals := map[string]StorageSettingTypes{ + "georedundant": StorageSettingTypesGeoRedundant, + "locallyredundant": StorageSettingTypesLocallyRedundant, + "zoneredundant": StorageSettingTypesZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageSettingTypes(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault.go b/resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault.go new file mode 100644 index 00000000000..037dbb924a0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault.go @@ -0,0 +1,130 @@ +package backupvaults + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault_test.go b/resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault_test.go new file mode 100644 index 00000000000..1b5438b36d1 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/id_backupvault_test.go @@ -0,0 +1,282 @@ +package backupvaults + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/dataprotection/2024-04-01/backupvaults/id_providerlocation.go b/resource-manager/dataprotection/2024-04-01/backupvaults/id_providerlocation.go new file mode 100644 index 00000000000..0a99f41369d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/id_providerlocation.go @@ -0,0 +1,130 @@ +package backupvaults + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/id_providerlocation_test.go b/resource-manager/dataprotection/2024-04-01/backupvaults/id_providerlocation_test.go new file mode 100644 index 00000000000..e522b5f2bc3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package backupvaults + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/method_checknameavailability.go b/resource-manager/dataprotection/2024-04-01/backupvaults/method_checknameavailability.go new file mode 100644 index 00000000000..6e006b786d0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/method_checknameavailability.go @@ -0,0 +1,59 @@ +package backupvaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c BackupVaultsClient) CheckNameAvailability(ctx context.Context, id ProviderLocationId, input CheckNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/method_createorupdate.go b/resource-manager/dataprotection/2024-04-01/backupvaults/method_createorupdate.go new file mode 100644 index 00000000000..0e1892eb095 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/method_createorupdate.go @@ -0,0 +1,103 @@ +package backupvaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupVaultResource +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c BackupVaultsClient) CreateOrUpdate(ctx context.Context, id BackupVaultId, input BackupVaultResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c BackupVaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id BackupVaultId, input BackupVaultResource, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/method_delete.go b/resource-manager/dataprotection/2024-04-01/backupvaults/method_delete.go new file mode 100644 index 00000000000..6899d5db814 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/method_delete.go @@ -0,0 +1,71 @@ +package backupvaults + +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 BackupVaultsClient) Delete(ctx context.Context, id BackupVaultId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 BackupVaultsClient) DeleteThenPoll(ctx context.Context, id BackupVaultId) 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/dataprotection/2024-04-01/backupvaults/method_get.go b/resource-manager/dataprotection/2024-04-01/backupvaults/method_get.go new file mode 100644 index 00000000000..5e1ed9d0258 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/method_get.go @@ -0,0 +1,54 @@ +package backupvaults + +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 *BackupVaultResource +} + +// Get ... +func (c BackupVaultsClient) Get(ctx context.Context, id BackupVaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupVaultResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/method_getinresourcegroup.go b/resource-manager/dataprotection/2024-04-01/backupvaults/method_getinresourcegroup.go new file mode 100644 index 00000000000..0328a7adca4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/method_getinresourcegroup.go @@ -0,0 +1,92 @@ +package backupvaults + +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 GetInResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupVaultResource +} + +type GetInResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupVaultResource +} + +// GetInResourceGroup ... +func (c BackupVaultsClient) GetInResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result GetInResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DataProtection/backupVaults", 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 *[]BackupVaultResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetInResourceGroupComplete retrieves all the results into a single object +func (c BackupVaultsClient) GetInResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (GetInResourceGroupCompleteResult, error) { + return c.GetInResourceGroupCompleteMatchingPredicate(ctx, id, BackupVaultResourceOperationPredicate{}) +} + +// GetInResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupVaultsClient) GetInResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate BackupVaultResourceOperationPredicate) (result GetInResourceGroupCompleteResult, err error) { + items := make([]BackupVaultResource, 0) + + resp, err := c.GetInResourceGroup(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 = GetInResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/method_getinsubscription.go b/resource-manager/dataprotection/2024-04-01/backupvaults/method_getinsubscription.go new file mode 100644 index 00000000000..db858d0c65e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/method_getinsubscription.go @@ -0,0 +1,92 @@ +package backupvaults + +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 GetInSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupVaultResource +} + +type GetInSubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupVaultResource +} + +// GetInSubscription ... +func (c BackupVaultsClient) GetInSubscription(ctx context.Context, id commonids.SubscriptionId) (result GetInSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DataProtection/backupVaults", 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 *[]BackupVaultResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetInSubscriptionComplete retrieves all the results into a single object +func (c BackupVaultsClient) GetInSubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (GetInSubscriptionCompleteResult, error) { + return c.GetInSubscriptionCompleteMatchingPredicate(ctx, id, BackupVaultResourceOperationPredicate{}) +} + +// GetInSubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BackupVaultsClient) GetInSubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BackupVaultResourceOperationPredicate) (result GetInSubscriptionCompleteResult, err error) { + items := make([]BackupVaultResource, 0) + + resp, err := c.GetInSubscription(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 = GetInSubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/method_update.go b/resource-manager/dataprotection/2024-04-01/backupvaults/method_update.go new file mode 100644 index 00000000000..999efb3f727 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/method_update.go @@ -0,0 +1,103 @@ +package backupvaults + +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 *BackupVaultResource +} + +type UpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c BackupVaultsClient) Update(ctx context.Context, id BackupVaultId, input PatchResourceRequestInput, options UpdateOperationOptions) (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(), + OptionsObject: options, + } + + 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 BackupVaultsClient) UpdateThenPoll(ctx context.Context, id BackupVaultId, input PatchResourceRequestInput, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_azuremonitoralertsettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_azuremonitoralertsettings.go new file mode 100644 index 00000000000..8abdec3ec1b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_azuremonitoralertsettings.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureMonitorAlertSettings struct { + AlertsForAllJobFailures *AlertsState `json:"alertsForAllJobFailures,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvault.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvault.go new file mode 100644 index 00000000000..e4b439669fc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvault.go @@ -0,0 +1,19 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupVault struct { + BcdrSecurityLevel *BCDRSecurityLevel `json:"bcdrSecurityLevel,omitempty"` + FeatureSettings *FeatureSettings `json:"featureSettings,omitempty"` + IsVaultProtectedByResourceGuard *bool `json:"isVaultProtectedByResourceGuard,omitempty"` + MonitoringSettings *MonitoringSettings `json:"monitoringSettings,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReplicatedRegions *[]string `json:"replicatedRegions,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ResourceMoveDetails *ResourceMoveDetails `json:"resourceMoveDetails,omitempty"` + ResourceMoveState *ResourceMoveState `json:"resourceMoveState,omitempty"` + SecureScore *SecureScoreLevel `json:"secureScore,omitempty"` + SecuritySettings *SecuritySettings `json:"securitySettings,omitempty"` + StorageSettings []StorageSetting `json:"storageSettings"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvaultresource.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvaultresource.go new file mode 100644 index 00000000000..29a98bad3b8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_backupvaultresource.go @@ -0,0 +1,20 @@ +package backupvaults + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupVaultResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *DppIdentityDetails `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties BackupVault `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityrequest.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityrequest.go new file mode 100644 index 00000000000..bb78afc83b2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityrequest.go @@ -0,0 +1,9 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityRequest struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityresult.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityresult.go new file mode 100644 index 00000000000..86c51891313 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResult struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkekidentity.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkekidentity.go new file mode 100644 index 00000000000..5d5fa1569f4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkekidentity.go @@ -0,0 +1,9 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkKekIdentity struct { + IdentityId *string `json:"identityId,omitempty"` + IdentityType *IdentityType `json:"identityType,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkeyvaultproperties.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkeyvaultproperties.go new file mode 100644 index 00000000000..b17ed0aea42 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_cmkkeyvaultproperties.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkKeyVaultProperties struct { + KeyUri *string `json:"keyUri,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_crossregionrestoresettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_crossregionrestoresettings.go new file mode 100644 index 00000000000..71637991bdd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_crossregionrestoresettings.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossRegionRestoreSettings struct { + State *CrossRegionRestoreState `json:"state,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_crosssubscriptionrestoresettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_crosssubscriptionrestoresettings.go new file mode 100644 index 00000000000..0e8ba93d082 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_crosssubscriptionrestoresettings.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossSubscriptionRestoreSettings struct { + State *CrossSubscriptionRestoreState `json:"state,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_dppidentitydetails.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_dppidentitydetails.go new file mode 100644 index 00000000000..88294a548cd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_dppidentitydetails.go @@ -0,0 +1,11 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DppIdentityDetails struct { + PrincipalId *string `json:"principalId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Type *string `json:"type,omitempty"` + UserAssignedIdentities *map[string]UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_encryptionsettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_encryptionsettings.go new file mode 100644 index 00000000000..89ddfc7332b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_encryptionsettings.go @@ -0,0 +1,11 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionSettings struct { + InfrastructureEncryption *InfrastructureEncryptionState `json:"infrastructureEncryption,omitempty"` + KekIdentity *CmkKekIdentity `json:"kekIdentity,omitempty"` + KeyVaultProperties *CmkKeyVaultProperties `json:"keyVaultProperties,omitempty"` + State *EncryptionState `json:"state,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_featuresettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_featuresettings.go new file mode 100644 index 00000000000..c8981f793c3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_featuresettings.go @@ -0,0 +1,9 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureSettings struct { + CrossRegionRestoreSettings *CrossRegionRestoreSettings `json:"crossRegionRestoreSettings,omitempty"` + CrossSubscriptionRestoreSettings *CrossSubscriptionRestoreSettings `json:"crossSubscriptionRestoreSettings,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_immutabilitysettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_immutabilitysettings.go new file mode 100644 index 00000000000..1e8bb471362 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_immutabilitysettings.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImmutabilitySettings struct { + State *ImmutabilityState `json:"state,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_monitoringsettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_monitoringsettings.go new file mode 100644 index 00000000000..de0fa26a601 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_monitoringsettings.go @@ -0,0 +1,8 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringSettings struct { + AzureMonitorAlertSettings *AzureMonitorAlertSettings `json:"azureMonitorAlertSettings,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_patchbackupvaultinput.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_patchbackupvaultinput.go new file mode 100644 index 00000000000..19f63cb6049 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_patchbackupvaultinput.go @@ -0,0 +1,11 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchBackupVaultInput struct { + FeatureSettings *FeatureSettings `json:"featureSettings,omitempty"` + MonitoringSettings *MonitoringSettings `json:"monitoringSettings,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SecuritySettings *SecuritySettings `json:"securitySettings,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_patchresourcerequestinput.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_patchresourcerequestinput.go new file mode 100644 index 00000000000..09683e7a1d0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_patchresourcerequestinput.go @@ -0,0 +1,10 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchResourceRequestInput struct { + Identity *DppIdentityDetails `json:"identity,omitempty"` + Properties *PatchBackupVaultInput `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_resourcemovedetails.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_resourcemovedetails.go new file mode 100644 index 00000000000..dc459fff005 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_resourcemovedetails.go @@ -0,0 +1,12 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMoveDetails struct { + CompletionTimeUtc *string `json:"completionTimeUtc,omitempty"` + OperationId *string `json:"operationId,omitempty"` + SourceResourcePath *string `json:"sourceResourcePath,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + TargetResourcePath *string `json:"targetResourcePath,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_securitysettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_securitysettings.go new file mode 100644 index 00000000000..599a66600d9 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_securitysettings.go @@ -0,0 +1,10 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuritySettings struct { + EncryptionSettings *EncryptionSettings `json:"encryptionSettings,omitempty"` + ImmutabilitySettings *ImmutabilitySettings `json:"immutabilitySettings,omitempty"` + SoftDeleteSettings *SoftDeleteSettings `json:"softDeleteSettings,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_softdeletesettings.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_softdeletesettings.go new file mode 100644 index 00000000000..903e8180d14 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_softdeletesettings.go @@ -0,0 +1,9 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SoftDeleteSettings struct { + RetentionDurationInDays *float64 `json:"retentionDurationInDays,omitempty"` + State *SoftDeleteState `json:"state,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_storagesetting.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_storagesetting.go new file mode 100644 index 00000000000..6112268872b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_storagesetting.go @@ -0,0 +1,9 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageSetting struct { + DatastoreType *StorageSettingStoreTypes `json:"datastoreType,omitempty"` + Type *StorageSettingTypes `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/model_userassignedidentity.go b/resource-manager/dataprotection/2024-04-01/backupvaults/model_userassignedidentity.go new file mode 100644 index 00000000000..25716effc20 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/model_userassignedidentity.go @@ -0,0 +1,9 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentity struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/predicates.go b/resource-manager/dataprotection/2024-04-01/backupvaults/predicates.go new file mode 100644 index 00000000000..04141be33e7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/predicates.go @@ -0,0 +1,37 @@ +package backupvaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupVaultResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p BackupVaultResourceOperationPredicate) Matches(input BackupVaultResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/dataprotection/2024-04-01/backupvaults/version.go b/resource-manager/dataprotection/2024-04-01/backupvaults/version.go new file mode 100644 index 00000000000..fa80e7e1c21 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/backupvaults/version.go @@ -0,0 +1,12 @@ +package backupvaults + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupvaults/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/client.go b/resource-manager/dataprotection/2024-04-01/client.go new file mode 100644 index 00000000000..0734d3d7684 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/client.go @@ -0,0 +1,145 @@ +package v2024_04_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/dataprotection/2024-04-01/azurebackupjob" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/azurebackupjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backupinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backupinstancesextensionrouting" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backuppolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/backupvaults" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/deletedbackupinstances" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/dppfeaturesupport" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/dppjob" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/recoverypoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/resourceguards" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AzureBackupJob *azurebackupjob.AzureBackupJobClient + AzureBackupJobs *azurebackupjobs.AzureBackupJobsClient + BackupInstances *backupinstances.BackupInstancesClient + BackupInstancesExtensionRouting *backupinstancesextensionrouting.BackupInstancesExtensionRoutingClient + BackupPolicies *backuppolicies.BackupPoliciesClient + BackupVaults *backupvaults.BackupVaultsClient + DeletedBackupInstances *deletedbackupinstances.DeletedBackupInstancesClient + DppFeatureSupport *dppfeaturesupport.DppFeatureSupportClient + DppJob *dppjob.DppJobClient + DppResourceGuardProxies *dppresourceguardproxies.DppResourceGuardProxiesClient + FetchSecondaryRecoveryPoints *fetchsecondaryrecoverypoints.FetchSecondaryRecoveryPointsClient + FindRestorableTimeRanges *findrestorabletimeranges.FindRestorableTimeRangesClient + RecoveryPoint *recoverypoint.RecoveryPointClient + ResourceGuards *resourceguards.ResourceGuardsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + azureBackupJobClient, err := azurebackupjob.NewAzureBackupJobClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AzureBackupJob client: %+v", err) + } + configureFunc(azureBackupJobClient.Client) + + azureBackupJobsClient, err := azurebackupjobs.NewAzureBackupJobsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AzureBackupJobs client: %+v", err) + } + configureFunc(azureBackupJobsClient.Client) + + backupInstancesClient, err := backupinstances.NewBackupInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BackupInstances client: %+v", err) + } + configureFunc(backupInstancesClient.Client) + + backupInstancesExtensionRoutingClient, err := backupinstancesextensionrouting.NewBackupInstancesExtensionRoutingClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BackupInstancesExtensionRouting client: %+v", err) + } + configureFunc(backupInstancesExtensionRoutingClient.Client) + + backupPoliciesClient, err := backuppolicies.NewBackupPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BackupPolicies client: %+v", err) + } + configureFunc(backupPoliciesClient.Client) + + backupVaultsClient, err := backupvaults.NewBackupVaultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BackupVaults client: %+v", err) + } + configureFunc(backupVaultsClient.Client) + + deletedBackupInstancesClient, err := deletedbackupinstances.NewDeletedBackupInstancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DeletedBackupInstances client: %+v", err) + } + configureFunc(deletedBackupInstancesClient.Client) + + dppFeatureSupportClient, err := dppfeaturesupport.NewDppFeatureSupportClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DppFeatureSupport client: %+v", err) + } + configureFunc(dppFeatureSupportClient.Client) + + dppJobClient, err := dppjob.NewDppJobClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DppJob client: %+v", err) + } + configureFunc(dppJobClient.Client) + + dppResourceGuardProxiesClient, err := dppresourceguardproxies.NewDppResourceGuardProxiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DppResourceGuardProxies client: %+v", err) + } + configureFunc(dppResourceGuardProxiesClient.Client) + + fetchSecondaryRecoveryPointsClient, err := fetchsecondaryrecoverypoints.NewFetchSecondaryRecoveryPointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FetchSecondaryRecoveryPoints client: %+v", err) + } + configureFunc(fetchSecondaryRecoveryPointsClient.Client) + + findRestorableTimeRangesClient, err := findrestorabletimeranges.NewFindRestorableTimeRangesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FindRestorableTimeRanges client: %+v", err) + } + configureFunc(findRestorableTimeRangesClient.Client) + + recoveryPointClient, err := recoverypoint.NewRecoveryPointClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RecoveryPoint client: %+v", err) + } + configureFunc(recoveryPointClient.Client) + + resourceGuardsClient, err := resourceguards.NewResourceGuardsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceGuards client: %+v", err) + } + configureFunc(resourceGuardsClient.Client) + + return &Client{ + AzureBackupJob: azureBackupJobClient, + AzureBackupJobs: azureBackupJobsClient, + BackupInstances: backupInstancesClient, + BackupInstancesExtensionRouting: backupInstancesExtensionRoutingClient, + BackupPolicies: backupPoliciesClient, + BackupVaults: backupVaultsClient, + DeletedBackupInstances: deletedBackupInstancesClient, + DppFeatureSupport: dppFeatureSupportClient, + DppJob: dppJobClient, + DppResourceGuardProxies: dppResourceGuardProxiesClient, + FetchSecondaryRecoveryPoints: fetchSecondaryRecoveryPointsClient, + FindRestorableTimeRanges: findRestorableTimeRangesClient, + RecoveryPoint: recoveryPointClient, + ResourceGuards: resourceGuardsClient, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/README.md b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/README.md new file mode 100644 index 00000000000..2c0a40435c3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/deletedbackupinstances` Documentation + +The `deletedbackupinstances` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/deletedbackupinstances" +``` + + +### Client Initialization + +```go +client := deletedbackupinstances.NewDeletedBackupInstancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DeletedBackupInstancesClient.Get` + +```go +ctx := context.TODO() +id := deletedbackupinstances.NewDeletedBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "deletedBackupInstanceValue") + +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: `DeletedBackupInstancesClient.List` + +```go +ctx := context.TODO() +id := deletedbackupinstances.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +// 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: `DeletedBackupInstancesClient.Undelete` + +```go +ctx := context.TODO() +id := deletedbackupinstances.NewDeletedBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "deletedBackupInstanceValue") + +if err := client.UndeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/client.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/client.go new file mode 100644 index 00000000000..e70cb344e5d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/client.go @@ -0,0 +1,26 @@ +package deletedbackupinstances + +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 DeletedBackupInstancesClient struct { + Client *resourcemanager.Client +} + +func NewDeletedBackupInstancesClientWithBaseURI(sdkApi sdkEnv.Api) (*DeletedBackupInstancesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "deletedbackupinstances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeletedBackupInstancesClient: %+v", err) + } + + return &DeletedBackupInstancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/constants.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/constants.go new file mode 100644 index 00000000000..d0a2f7e9313 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/constants.go @@ -0,0 +1,298 @@ +package deletedbackupinstances + +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 CurrentProtectionState string + +const ( + CurrentProtectionStateBackupSchedulesSuspended CurrentProtectionState = "BackupSchedulesSuspended" + CurrentProtectionStateConfiguringProtection CurrentProtectionState = "ConfiguringProtection" + CurrentProtectionStateConfiguringProtectionFailed CurrentProtectionState = "ConfiguringProtectionFailed" + CurrentProtectionStateInvalid CurrentProtectionState = "Invalid" + CurrentProtectionStateNotProtected CurrentProtectionState = "NotProtected" + CurrentProtectionStateProtectionConfigured CurrentProtectionState = "ProtectionConfigured" + CurrentProtectionStateProtectionError CurrentProtectionState = "ProtectionError" + CurrentProtectionStateProtectionStopped CurrentProtectionState = "ProtectionStopped" + CurrentProtectionStateRetentionSchedulesSuspended CurrentProtectionState = "RetentionSchedulesSuspended" + CurrentProtectionStateSoftDeleted CurrentProtectionState = "SoftDeleted" + CurrentProtectionStateSoftDeleting CurrentProtectionState = "SoftDeleting" + CurrentProtectionStateUpdatingProtection CurrentProtectionState = "UpdatingProtection" +) + +func PossibleValuesForCurrentProtectionState() []string { + return []string{ + string(CurrentProtectionStateBackupSchedulesSuspended), + string(CurrentProtectionStateConfiguringProtection), + string(CurrentProtectionStateConfiguringProtectionFailed), + string(CurrentProtectionStateInvalid), + string(CurrentProtectionStateNotProtected), + string(CurrentProtectionStateProtectionConfigured), + string(CurrentProtectionStateProtectionError), + string(CurrentProtectionStateProtectionStopped), + string(CurrentProtectionStateRetentionSchedulesSuspended), + string(CurrentProtectionStateSoftDeleted), + string(CurrentProtectionStateSoftDeleting), + string(CurrentProtectionStateUpdatingProtection), + } +} + +func (s *CurrentProtectionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCurrentProtectionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCurrentProtectionState(input string) (*CurrentProtectionState, error) { + vals := map[string]CurrentProtectionState{ + "backupschedulessuspended": CurrentProtectionStateBackupSchedulesSuspended, + "configuringprotection": CurrentProtectionStateConfiguringProtection, + "configuringprotectionfailed": CurrentProtectionStateConfiguringProtectionFailed, + "invalid": CurrentProtectionStateInvalid, + "notprotected": CurrentProtectionStateNotProtected, + "protectionconfigured": CurrentProtectionStateProtectionConfigured, + "protectionerror": CurrentProtectionStateProtectionError, + "protectionstopped": CurrentProtectionStateProtectionStopped, + "retentionschedulessuspended": CurrentProtectionStateRetentionSchedulesSuspended, + "softdeleted": CurrentProtectionStateSoftDeleted, + "softdeleting": CurrentProtectionStateSoftDeleting, + "updatingprotection": CurrentProtectionStateUpdatingProtection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CurrentProtectionState(input) + return &out, nil +} + +type DataStoreTypes string + +const ( + DataStoreTypesArchiveStore DataStoreTypes = "ArchiveStore" + DataStoreTypesOperationalStore DataStoreTypes = "OperationalStore" + DataStoreTypesVaultStore DataStoreTypes = "VaultStore" +) + +func PossibleValuesForDataStoreTypes() []string { + return []string{ + string(DataStoreTypesArchiveStore), + string(DataStoreTypesOperationalStore), + string(DataStoreTypesVaultStore), + } +} + +func (s *DataStoreTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataStoreTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataStoreTypes(input string) (*DataStoreTypes, error) { + vals := map[string]DataStoreTypes{ + "archivestore": DataStoreTypesArchiveStore, + "operationalstore": DataStoreTypesOperationalStore, + "vaultstore": DataStoreTypesVaultStore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataStoreTypes(input) + return &out, nil +} + +type ResourcePropertiesObjectType string + +const ( + ResourcePropertiesObjectTypeDefaultResourceProperties ResourcePropertiesObjectType = "DefaultResourceProperties" +) + +func PossibleValuesForResourcePropertiesObjectType() []string { + return []string{ + string(ResourcePropertiesObjectTypeDefaultResourceProperties), + } +} + +func (s *ResourcePropertiesObjectType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourcePropertiesObjectType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourcePropertiesObjectType(input string) (*ResourcePropertiesObjectType, error) { + vals := map[string]ResourcePropertiesObjectType{ + "defaultresourceproperties": ResourcePropertiesObjectTypeDefaultResourceProperties, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourcePropertiesObjectType(input) + return &out, nil +} + +type SecretStoreType string + +const ( + SecretStoreTypeAzureKeyVault SecretStoreType = "AzureKeyVault" + SecretStoreTypeInvalid SecretStoreType = "Invalid" +) + +func PossibleValuesForSecretStoreType() []string { + return []string{ + string(SecretStoreTypeAzureKeyVault), + string(SecretStoreTypeInvalid), + } +} + +func (s *SecretStoreType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecretStoreType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecretStoreType(input string) (*SecretStoreType, error) { + vals := map[string]SecretStoreType{ + "azurekeyvault": SecretStoreTypeAzureKeyVault, + "invalid": SecretStoreTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecretStoreType(input) + return &out, nil +} + +type Status string + +const ( + StatusConfiguringProtection Status = "ConfiguringProtection" + StatusConfiguringProtectionFailed Status = "ConfiguringProtectionFailed" + StatusProtectionConfigured Status = "ProtectionConfigured" + StatusProtectionStopped Status = "ProtectionStopped" + StatusSoftDeleted Status = "SoftDeleted" + StatusSoftDeleting Status = "SoftDeleting" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusConfiguringProtection), + string(StatusConfiguringProtectionFailed), + string(StatusProtectionConfigured), + string(StatusProtectionStopped), + string(StatusSoftDeleted), + string(StatusSoftDeleting), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "configuringprotection": StatusConfiguringProtection, + "configuringprotectionfailed": StatusConfiguringProtectionFailed, + "protectionconfigured": StatusProtectionConfigured, + "protectionstopped": StatusProtectionStopped, + "softdeleted": StatusSoftDeleted, + "softdeleting": StatusSoftDeleting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} + +type ValidationType string + +const ( + ValidationTypeDeepValidation ValidationType = "DeepValidation" + ValidationTypeShallowValidation ValidationType = "ShallowValidation" +) + +func PossibleValuesForValidationType() []string { + return []string{ + string(ValidationTypeDeepValidation), + string(ValidationTypeShallowValidation), + } +} + +func (s *ValidationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationType(input string) (*ValidationType, error) { + vals := map[string]ValidationType{ + "deepvalidation": ValidationTypeDeepValidation, + "shallowvalidation": ValidationTypeShallowValidation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationType(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault.go new file mode 100644 index 00000000000..6dc4dce0b7f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault.go @@ -0,0 +1,130 @@ +package deletedbackupinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault_test.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault_test.go new file mode 100644 index 00000000000..1a324bf4c31 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_backupvault_test.go @@ -0,0 +1,282 @@ +package deletedbackupinstances + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance.go new file mode 100644 index 00000000000..f81e2080068 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance.go @@ -0,0 +1,139 @@ +package deletedbackupinstances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeletedBackupInstanceId{}) +} + +var _ resourceids.ResourceId = &DeletedBackupInstanceId{} + +// DeletedBackupInstanceId is a struct representing the Resource ID for a Deleted Backup Instance +type DeletedBackupInstanceId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + DeletedBackupInstanceName string +} + +// NewDeletedBackupInstanceID returns a new DeletedBackupInstanceId struct +func NewDeletedBackupInstanceID(subscriptionId string, resourceGroupName string, backupVaultName string, deletedBackupInstanceName string) DeletedBackupInstanceId { + return DeletedBackupInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + DeletedBackupInstanceName: deletedBackupInstanceName, + } +} + +// ParseDeletedBackupInstanceID parses 'input' into a DeletedBackupInstanceId +func ParseDeletedBackupInstanceID(input string) (*DeletedBackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedBackupInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedBackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeletedBackupInstanceIDInsensitively parses 'input' case-insensitively into a DeletedBackupInstanceId +// note: this method should only be used for API response data and not user input +func ParseDeletedBackupInstanceIDInsensitively(input string) (*DeletedBackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedBackupInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedBackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeletedBackupInstanceId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.DeletedBackupInstanceName, ok = input.Parsed["deletedBackupInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deletedBackupInstanceName", input) + } + + return nil +} + +// ValidateDeletedBackupInstanceID checks that 'input' can be parsed as a Deleted Backup Instance ID +func ValidateDeletedBackupInstanceID(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 := ParseDeletedBackupInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deleted Backup Instance ID +func (id DeletedBackupInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/deletedBackupInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.DeletedBackupInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deleted Backup Instance ID +func (id DeletedBackupInstanceId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticDeletedBackupInstances", "deletedBackupInstances", "deletedBackupInstances"), + resourceids.UserSpecifiedSegment("deletedBackupInstanceName", "deletedBackupInstanceValue"), + } +} + +// String returns a human-readable description of this Deleted Backup Instance ID +func (id DeletedBackupInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Deleted Backup Instance Name: %q", id.DeletedBackupInstanceName), + } + return fmt.Sprintf("Deleted Backup Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance_test.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance_test.go new file mode 100644 index 00000000000..85eadc843ab --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/id_deletedbackupinstance_test.go @@ -0,0 +1,327 @@ +package deletedbackupinstances + +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 = &DeletedBackupInstanceId{} + +func TestNewDeletedBackupInstanceID(t *testing.T) { + id := NewDeletedBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "deletedBackupInstanceValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.DeletedBackupInstanceName != "deletedBackupInstanceValue" { + t.Fatalf("Expected %q but got %q for Segment 'DeletedBackupInstanceName'", id.DeletedBackupInstanceName, "deletedBackupInstanceValue") + } +} + +func TestFormatDeletedBackupInstanceID(t *testing.T) { + actual := NewDeletedBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "deletedBackupInstanceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/deletedBackupInstances/deletedBackupInstanceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeletedBackupInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedBackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/deletedBackupInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/deletedBackupInstances/deletedBackupInstanceValue", + Expected: &DeletedBackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + DeletedBackupInstanceName: "deletedBackupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/deletedBackupInstances/deletedBackupInstanceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedBackupInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.DeletedBackupInstanceName != v.Expected.DeletedBackupInstanceName { + t.Fatalf("Expected %q but got %q for DeletedBackupInstanceName", v.Expected.DeletedBackupInstanceName, actual.DeletedBackupInstanceName) + } + + } +} + +func TestParseDeletedBackupInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedBackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/deletedBackupInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/dElEtEdBaCkUpInStAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/deletedBackupInstances/deletedBackupInstanceValue", + Expected: &DeletedBackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + DeletedBackupInstanceName: "deletedBackupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/deletedBackupInstances/deletedBackupInstanceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/dElEtEdBaCkUpInStAnCeS/dElEtEdBaCkUpInStAnCeVaLuE", + Expected: &DeletedBackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + DeletedBackupInstanceName: "dElEtEdBaCkUpInStAnCeVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/dElEtEdBaCkUpInStAnCeS/dElEtEdBaCkUpInStAnCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedBackupInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.DeletedBackupInstanceName != v.Expected.DeletedBackupInstanceName { + t.Fatalf("Expected %q but got %q for DeletedBackupInstanceName", v.Expected.DeletedBackupInstanceName, actual.DeletedBackupInstanceName) + } + + } +} + +func TestSegmentsForDeletedBackupInstanceId(t *testing.T) { + segments := DeletedBackupInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeletedBackupInstanceId 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/dataprotection/2024-04-01/deletedbackupinstances/method_get.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_get.go new file mode 100644 index 00000000000..8326bd4395b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_get.go @@ -0,0 +1,54 @@ +package deletedbackupinstances + +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 *DeletedBackupInstanceResource +} + +// Get ... +func (c DeletedBackupInstancesClient) Get(ctx context.Context, id DeletedBackupInstanceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeletedBackupInstanceResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_list.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_list.go new file mode 100644 index 00000000000..85fb1a36279 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_list.go @@ -0,0 +1,91 @@ +package deletedbackupinstances + +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 *[]DeletedBackupInstanceResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedBackupInstanceResource +} + +// List ... +func (c DeletedBackupInstancesClient) List(ctx context.Context, id BackupVaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deletedBackupInstances", 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 *[]DeletedBackupInstanceResource `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 DeletedBackupInstancesClient) ListComplete(ctx context.Context, id BackupVaultId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DeletedBackupInstanceResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedBackupInstancesClient) ListCompleteMatchingPredicate(ctx context.Context, id BackupVaultId, predicate DeletedBackupInstanceResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DeletedBackupInstanceResource, 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/dataprotection/2024-04-01/deletedbackupinstances/method_undelete.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_undelete.go new file mode 100644 index 00000000000..1ab188478a5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/method_undelete.go @@ -0,0 +1,70 @@ +package deletedbackupinstances + +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 UndeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Undelete ... +func (c DeletedBackupInstancesClient) Undelete(ctx context.Context, id DeletedBackupInstanceId) (result UndeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/undelete", 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 +} + +// UndeleteThenPoll performs Undelete then polls until it's completed +func (c DeletedBackupInstancesClient) UndeleteThenPoll(ctx context.Context, id DeletedBackupInstanceId) error { + result, err := c.Undelete(ctx, id) + if err != nil { + return fmt.Errorf("performing Undelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Undelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_authcredentials.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_authcredentials.go new file mode 100644 index 00000000000..e1f6967a3f6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_authcredentials.go @@ -0,0 +1,53 @@ +package deletedbackupinstances + +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 AuthCredentials interface { +} + +// RawAuthCredentialsImpl 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 RawAuthCredentialsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAuthCredentialsImplementation(input []byte) (AuthCredentials, 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 AuthCredentials into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "SecretStoreBasedAuthCredentials") { + var out SecretStoreBasedAuthCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SecretStoreBasedAuthCredentials: %+v", err) + } + return out, nil + } + + out := RawAuthCredentialsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_azureoperationalstoreparameters.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_azureoperationalstoreparameters.go new file mode 100644 index 00000000000..82c85ebf9e1 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_azureoperationalstoreparameters.go @@ -0,0 +1,42 @@ +package deletedbackupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataStoreParameters = AzureOperationalStoreParameters{} + +type AzureOperationalStoreParameters struct { + ResourceGroupId *string `json:"resourceGroupId,omitempty"` + + // Fields inherited from DataStoreParameters + DataStoreType DataStoreTypes `json:"dataStoreType"` +} + +var _ json.Marshaler = AzureOperationalStoreParameters{} + +func (s AzureOperationalStoreParameters) MarshalJSON() ([]byte, error) { + type wrapper AzureOperationalStoreParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureOperationalStoreParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureOperationalStoreParameters: %+v", err) + } + decoded["objectType"] = "AzureOperationalStoreParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureOperationalStoreParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_backupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_backupdatasourceparameters.go new file mode 100644 index 00000000000..61a96f79393 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_backupdatasourceparameters.go @@ -0,0 +1,61 @@ +package deletedbackupinstances + +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 BackupDatasourceParameters interface { +} + +// RawBackupDatasourceParametersImpl 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 RawBackupDatasourceParametersImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBackupDatasourceParametersImplementation(input []byte) (BackupDatasourceParameters, 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 BackupDatasourceParameters into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "BlobBackupDatasourceParameters") { + var out BlobBackupDatasourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BlobBackupDatasourceParameters: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "KubernetesClusterBackupDatasourceParameters") { + var out KubernetesClusterBackupDatasourceParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesClusterBackupDatasourceParameters: %+v", err) + } + return out, nil + } + + out := RawBackupDatasourceParametersImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_baseresourceproperties.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_baseresourceproperties.go new file mode 100644 index 00000000000..395fa05201d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_baseresourceproperties.go @@ -0,0 +1,53 @@ +package deletedbackupinstances + +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 BaseResourceProperties interface { +} + +// RawBaseResourcePropertiesImpl 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 RawBaseResourcePropertiesImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBaseResourcePropertiesImplementation(input []byte) (BaseResourceProperties, 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 BaseResourceProperties into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "DefaultResourceProperties") { + var out DefaultResourceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DefaultResourceProperties: %+v", err) + } + return out, nil + } + + out := RawBaseResourcePropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_blobbackupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_blobbackupdatasourceparameters.go new file mode 100644 index 00000000000..8dbfe3038cd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_blobbackupdatasourceparameters.go @@ -0,0 +1,41 @@ +package deletedbackupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupDatasourceParameters = BlobBackupDatasourceParameters{} + +type BlobBackupDatasourceParameters struct { + ContainersList []string `json:"containersList"` + + // Fields inherited from BackupDatasourceParameters +} + +var _ json.Marshaler = BlobBackupDatasourceParameters{} + +func (s BlobBackupDatasourceParameters) MarshalJSON() ([]byte, error) { + type wrapper BlobBackupDatasourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BlobBackupDatasourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BlobBackupDatasourceParameters: %+v", err) + } + decoded["objectType"] = "BlobBackupDatasourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BlobBackupDatasourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasource.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasource.go new file mode 100644 index 00000000000..ae955b4355b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasource.go @@ -0,0 +1,52 @@ +package deletedbackupinstances + +import ( + "encoding/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 Datasource struct { + DatasourceType *string `json:"datasourceType,omitempty"` + ObjectType *string `json:"objectType,omitempty"` + ResourceID string `json:"resourceID"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceProperties BaseResourceProperties `json:"resourceProperties"` + ResourceType *string `json:"resourceType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} + +var _ json.Unmarshaler = &Datasource{} + +func (s *Datasource) UnmarshalJSON(bytes []byte) error { + type alias Datasource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into Datasource: %+v", err) + } + + s.DatasourceType = decoded.DatasourceType + s.ObjectType = decoded.ObjectType + s.ResourceID = decoded.ResourceID + s.ResourceLocation = decoded.ResourceLocation + s.ResourceName = decoded.ResourceName + s.ResourceType = decoded.ResourceType + s.ResourceUri = decoded.ResourceUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Datasource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourceProperties"]; ok { + impl, err := unmarshalBaseResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourceProperties' for 'Datasource': %+v", err) + } + s.ResourceProperties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasourceset.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasourceset.go new file mode 100644 index 00000000000..03857806dea --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datasourceset.go @@ -0,0 +1,52 @@ +package deletedbackupinstances + +import ( + "encoding/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 DatasourceSet struct { + DatasourceType *string `json:"datasourceType,omitempty"` + ObjectType *string `json:"objectType,omitempty"` + ResourceID string `json:"resourceID"` + ResourceLocation *string `json:"resourceLocation,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceProperties BaseResourceProperties `json:"resourceProperties"` + ResourceType *string `json:"resourceType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} + +var _ json.Unmarshaler = &DatasourceSet{} + +func (s *DatasourceSet) UnmarshalJSON(bytes []byte) error { + type alias DatasourceSet + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into DatasourceSet: %+v", err) + } + + s.DatasourceType = decoded.DatasourceType + s.ObjectType = decoded.ObjectType + s.ResourceID = decoded.ResourceID + s.ResourceLocation = decoded.ResourceLocation + s.ResourceName = decoded.ResourceName + s.ResourceType = decoded.ResourceType + s.ResourceUri = decoded.ResourceUri + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DatasourceSet into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["resourceProperties"]; ok { + impl, err := unmarshalBaseResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ResourceProperties' for 'DatasourceSet': %+v", err) + } + s.ResourceProperties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datastoreparameters.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datastoreparameters.go new file mode 100644 index 00000000000..0c5750816d1 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_datastoreparameters.go @@ -0,0 +1,53 @@ +package deletedbackupinstances + +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 DataStoreParameters interface { +} + +// RawDataStoreParametersImpl 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 RawDataStoreParametersImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalDataStoreParametersImplementation(input []byte) (DataStoreParameters, 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 DataStoreParameters into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureOperationalStoreParameters") { + var out AzureOperationalStoreParameters + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureOperationalStoreParameters: %+v", err) + } + return out, nil + } + + out := RawDataStoreParametersImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_defaultresourceproperties.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_defaultresourceproperties.go new file mode 100644 index 00000000000..618a75af3b9 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_defaultresourceproperties.go @@ -0,0 +1,40 @@ +package deletedbackupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BaseResourceProperties = DefaultResourceProperties{} + +type DefaultResourceProperties struct { + + // Fields inherited from BaseResourceProperties +} + +var _ json.Marshaler = DefaultResourceProperties{} + +func (s DefaultResourceProperties) MarshalJSON() ([]byte, error) { + type wrapper DefaultResourceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DefaultResourceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DefaultResourceProperties: %+v", err) + } + decoded["objectType"] = "DefaultResourceProperties" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DefaultResourceProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstance.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstance.go new file mode 100644 index 00000000000..fc2cbfb5c99 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstance.go @@ -0,0 +1,64 @@ +package deletedbackupinstances + +import ( + "encoding/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 DeletedBackupInstance struct { + CurrentProtectionState *CurrentProtectionState `json:"currentProtectionState,omitempty"` + DataSourceInfo Datasource `json:"dataSourceInfo"` + DataSourceSetInfo *DatasourceSet `json:"dataSourceSetInfo,omitempty"` + DatasourceAuthCredentials AuthCredentials `json:"datasourceAuthCredentials"` + DeletionInfo *DeletionInfo `json:"deletionInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + IdentityDetails *IdentityDetails `json:"identityDetails,omitempty"` + ObjectType string `json:"objectType"` + PolicyInfo PolicyInfo `json:"policyInfo"` + ProtectionErrorDetails *UserFacingError `json:"protectionErrorDetails,omitempty"` + ProtectionStatus *ProtectionStatusDetails `json:"protectionStatus,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ValidationType *ValidationType `json:"validationType,omitempty"` +} + +var _ json.Unmarshaler = &DeletedBackupInstance{} + +func (s *DeletedBackupInstance) UnmarshalJSON(bytes []byte) error { + type alias DeletedBackupInstance + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into DeletedBackupInstance: %+v", err) + } + + s.CurrentProtectionState = decoded.CurrentProtectionState + s.DataSourceInfo = decoded.DataSourceInfo + s.DataSourceSetInfo = decoded.DataSourceSetInfo + s.DeletionInfo = decoded.DeletionInfo + s.FriendlyName = decoded.FriendlyName + s.IdentityDetails = decoded.IdentityDetails + s.ObjectType = decoded.ObjectType + s.PolicyInfo = decoded.PolicyInfo + s.ProtectionErrorDetails = decoded.ProtectionErrorDetails + s.ProtectionStatus = decoded.ProtectionStatus + s.ProvisioningState = decoded.ProvisioningState + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.ValidationType = decoded.ValidationType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DeletedBackupInstance into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["datasourceAuthCredentials"]; ok { + impl, err := unmarshalAuthCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'DatasourceAuthCredentials' for 'DeletedBackupInstance': %+v", err) + } + s.DatasourceAuthCredentials = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstanceresource.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstanceresource.go new file mode 100644 index 00000000000..9d4b9f116ec --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletedbackupinstanceresource.go @@ -0,0 +1,16 @@ +package deletedbackupinstances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedBackupInstanceResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedBackupInstance `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletioninfo.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletioninfo.go new file mode 100644 index 00000000000..e01dc7d9b15 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_deletioninfo.go @@ -0,0 +1,11 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletionInfo struct { + BillingEndDate *string `json:"billingEndDate,omitempty"` + DeleteActivityID *string `json:"deleteActivityID,omitempty"` + DeletionTime *string `json:"deletionTime,omitempty"` + ScheduledPurgeTime *string `json:"scheduledPurgeTime,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_identitydetails.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_identitydetails.go new file mode 100644 index 00000000000..e04ae4cdbf2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_identitydetails.go @@ -0,0 +1,9 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityDetails struct { + UseSystemAssignedIdentity *bool `json:"useSystemAssignedIdentity,omitempty"` + UserAssignedIdentityArmUrl *string `json:"userAssignedIdentityArmUrl,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_innererror.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_innererror.go new file mode 100644 index 00000000000..e59cb1caa0f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_innererror.go @@ -0,0 +1,10 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InnerError struct { + AdditionalInfo *map[string]string `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + EmbeddedInnerError *InnerError `json:"embeddedInnerError,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_kubernetesclusterbackupdatasourceparameters.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_kubernetesclusterbackupdatasourceparameters.go new file mode 100644 index 00000000000..10068d31fa5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_kubernetesclusterbackupdatasourceparameters.go @@ -0,0 +1,48 @@ +package deletedbackupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupDatasourceParameters = KubernetesClusterBackupDatasourceParameters{} + +type KubernetesClusterBackupDatasourceParameters struct { + BackupHookReferences *[]NamespacedNameResource `json:"backupHookReferences,omitempty"` + ExcludedNamespaces *[]string `json:"excludedNamespaces,omitempty"` + ExcludedResourceTypes *[]string `json:"excludedResourceTypes,omitempty"` + IncludeClusterScopeResources bool `json:"includeClusterScopeResources"` + IncludedNamespaces *[]string `json:"includedNamespaces,omitempty"` + IncludedResourceTypes *[]string `json:"includedResourceTypes,omitempty"` + LabelSelectors *[]string `json:"labelSelectors,omitempty"` + SnapshotVolumes bool `json:"snapshotVolumes"` + + // Fields inherited from BackupDatasourceParameters +} + +var _ json.Marshaler = KubernetesClusterBackupDatasourceParameters{} + +func (s KubernetesClusterBackupDatasourceParameters) MarshalJSON() ([]byte, error) { + type wrapper KubernetesClusterBackupDatasourceParameters + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + decoded["objectType"] = "KubernetesClusterBackupDatasourceParameters" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesClusterBackupDatasourceParameters: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_namespacednameresource.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_namespacednameresource.go new file mode 100644 index 00000000000..70d84cc64c6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_namespacednameresource.go @@ -0,0 +1,9 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NamespacedNameResource struct { + Name *string `json:"name,omitempty"` + Namespace *string `json:"namespace,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyinfo.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyinfo.go new file mode 100644 index 00000000000..0ab008c3307 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyinfo.go @@ -0,0 +1,10 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyInfo struct { + PolicyId string `json:"policyId"` + PolicyParameters *PolicyParameters `json:"policyParameters,omitempty"` + PolicyVersion *string `json:"policyVersion,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyparameters.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyparameters.go new file mode 100644 index 00000000000..b1f479381f0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_policyparameters.go @@ -0,0 +1,59 @@ +package deletedbackupinstances + +import ( + "encoding/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 PolicyParameters struct { + BackupDatasourceParametersList *[]BackupDatasourceParameters `json:"backupDatasourceParametersList,omitempty"` + DataStoreParametersList *[]DataStoreParameters `json:"dataStoreParametersList,omitempty"` +} + +var _ json.Unmarshaler = &PolicyParameters{} + +func (s *PolicyParameters) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PolicyParameters into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["backupDatasourceParametersList"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling BackupDatasourceParametersList into list []json.RawMessage: %+v", err) + } + + output := make([]BackupDatasourceParameters, 0) + for i, val := range listTemp { + impl, err := unmarshalBackupDatasourceParametersImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'BackupDatasourceParametersList' for 'PolicyParameters': %+v", i, err) + } + output = append(output, impl) + } + s.BackupDatasourceParametersList = &output + } + + if v, ok := temp["dataStoreParametersList"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling DataStoreParametersList into list []json.RawMessage: %+v", err) + } + + output := make([]DataStoreParameters, 0) + for i, val := range listTemp { + impl, err := unmarshalDataStoreParametersImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'DataStoreParametersList' for 'PolicyParameters': %+v", i, err) + } + output = append(output, impl) + } + s.DataStoreParametersList = &output + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_protectionstatusdetails.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_protectionstatusdetails.go new file mode 100644 index 00000000000..27e9741b405 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_protectionstatusdetails.go @@ -0,0 +1,9 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionStatusDetails struct { + ErrorDetails *UserFacingError `json:"errorDetails,omitempty"` + Status *Status `json:"status,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstorebasedauthcredentials.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstorebasedauthcredentials.go new file mode 100644 index 00000000000..61dd7ae1963 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstorebasedauthcredentials.go @@ -0,0 +1,41 @@ +package deletedbackupinstances + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AuthCredentials = SecretStoreBasedAuthCredentials{} + +type SecretStoreBasedAuthCredentials struct { + SecretStoreResource *SecretStoreResource `json:"secretStoreResource,omitempty"` + + // Fields inherited from AuthCredentials +} + +var _ json.Marshaler = SecretStoreBasedAuthCredentials{} + +func (s SecretStoreBasedAuthCredentials) MarshalJSON() ([]byte, error) { + type wrapper SecretStoreBasedAuthCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SecretStoreBasedAuthCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SecretStoreBasedAuthCredentials: %+v", err) + } + decoded["objectType"] = "SecretStoreBasedAuthCredentials" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SecretStoreBasedAuthCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstoreresource.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstoreresource.go new file mode 100644 index 00000000000..940322a2821 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_secretstoreresource.go @@ -0,0 +1,10 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretStoreResource struct { + SecretStoreType SecretStoreType `json:"secretStoreType"` + Uri *string `json:"uri,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_userfacingerror.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_userfacingerror.go new file mode 100644 index 00000000000..db9ffc175f6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/model_userfacingerror.go @@ -0,0 +1,16 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingError struct { + Code *string `json:"code,omitempty"` + Details *[]UserFacingError `json:"details,omitempty"` + InnerError *InnerError `json:"innerError,omitempty"` + IsRetryable *bool `json:"isRetryable,omitempty"` + IsUserError *bool `json:"isUserError,omitempty"` + Message *string `json:"message,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + RecommendedAction *[]string `json:"recommendedAction,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/predicates.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/predicates.go new file mode 100644 index 00000000000..d7c6585786d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/predicates.go @@ -0,0 +1,27 @@ +package deletedbackupinstances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedBackupInstanceResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DeletedBackupInstanceResourceOperationPredicate) Matches(input DeletedBackupInstanceResource) 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/dataprotection/2024-04-01/deletedbackupinstances/version.go b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/version.go new file mode 100644 index 00000000000..7d2529b9e2c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/deletedbackupinstances/version.go @@ -0,0 +1,12 @@ +package deletedbackupinstances + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/deletedbackupinstances/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/README.md b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/README.md new file mode 100644 index 00000000000..9089cd760c0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/dppfeaturesupport` Documentation + +The `dppfeaturesupport` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/dppfeaturesupport" +``` + + +### Client Initialization + +```go +client := dppfeaturesupport.NewDppFeatureSupportClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DppFeatureSupportClient.DataProtectionCheckFeatureSupport` + +```go +ctx := context.TODO() +id := dppfeaturesupport.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := dppfeaturesupport.FeatureValidationRequestBase{ + // ... +} + + +read, err := client.DataProtectionCheckFeatureSupport(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/client.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/client.go new file mode 100644 index 00000000000..05f9070486d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/client.go @@ -0,0 +1,26 @@ +package dppfeaturesupport + +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 DppFeatureSupportClient struct { + Client *resourcemanager.Client +} + +func NewDppFeatureSupportClientWithBaseURI(sdkApi sdkEnv.Api) (*DppFeatureSupportClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dppfeaturesupport", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DppFeatureSupportClient: %+v", err) + } + + return &DppFeatureSupportClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/constants.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/constants.go new file mode 100644 index 00000000000..91dae34ba66 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/constants.go @@ -0,0 +1,104 @@ +package dppfeaturesupport + +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 FeatureSupportStatus string + +const ( + FeatureSupportStatusAlphaPreview FeatureSupportStatus = "AlphaPreview" + FeatureSupportStatusGenerallyAvailable FeatureSupportStatus = "GenerallyAvailable" + FeatureSupportStatusInvalid FeatureSupportStatus = "Invalid" + FeatureSupportStatusNotSupported FeatureSupportStatus = "NotSupported" + FeatureSupportStatusPrivatePreview FeatureSupportStatus = "PrivatePreview" + FeatureSupportStatusPublicPreview FeatureSupportStatus = "PublicPreview" +) + +func PossibleValuesForFeatureSupportStatus() []string { + return []string{ + string(FeatureSupportStatusAlphaPreview), + string(FeatureSupportStatusGenerallyAvailable), + string(FeatureSupportStatusInvalid), + string(FeatureSupportStatusNotSupported), + string(FeatureSupportStatusPrivatePreview), + string(FeatureSupportStatusPublicPreview), + } +} + +func (s *FeatureSupportStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureSupportStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureSupportStatus(input string) (*FeatureSupportStatus, error) { + vals := map[string]FeatureSupportStatus{ + "alphapreview": FeatureSupportStatusAlphaPreview, + "generallyavailable": FeatureSupportStatusGenerallyAvailable, + "invalid": FeatureSupportStatusInvalid, + "notsupported": FeatureSupportStatusNotSupported, + "privatepreview": FeatureSupportStatusPrivatePreview, + "publicpreview": FeatureSupportStatusPublicPreview, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureSupportStatus(input) + return &out, nil +} + +type FeatureType string + +const ( + FeatureTypeDataSourceType FeatureType = "DataSourceType" + FeatureTypeInvalid FeatureType = "Invalid" +) + +func PossibleValuesForFeatureType() []string { + return []string{ + string(FeatureTypeDataSourceType), + string(FeatureTypeInvalid), + } +} + +func (s *FeatureType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureType(input string) (*FeatureType, error) { + vals := map[string]FeatureType{ + "datasourcetype": FeatureTypeDataSourceType, + "invalid": FeatureTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureType(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location.go new file mode 100644 index 00000000000..4d1ff865e11 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location.go @@ -0,0 +1,121 @@ +package dppfeaturesupport + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DataProtection/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location_test.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location_test.go new file mode 100644 index 00000000000..b9e1cf4efba --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/id_location_test.go @@ -0,0 +1,237 @@ +package dppfeaturesupport + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/method_dataprotectioncheckfeaturesupport.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/method_dataprotectioncheckfeaturesupport.go new file mode 100644 index 00000000000..5b01a004060 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/method_dataprotectioncheckfeaturesupport.go @@ -0,0 +1,63 @@ +package dppfeaturesupport + +import ( + "context" + "encoding/json" + "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 DataProtectionCheckFeatureSupportOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FeatureValidationResponseBase +} + +// DataProtectionCheckFeatureSupport ... +func (c DppFeatureSupportClient) DataProtectionCheckFeatureSupport(ctx context.Context, id LocationId, input FeatureValidationRequestBase) (result DataProtectionCheckFeatureSupportOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkFeatureSupport", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := unmarshalFeatureValidationResponseBaseImplementation(respObj) + if err != nil { + return + } + result.Model = &model + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequest.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequest.go new file mode 100644 index 00000000000..245619e2f34 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequest.go @@ -0,0 +1,42 @@ +package dppfeaturesupport + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FeatureValidationRequestBase = FeatureValidationRequest{} + +type FeatureValidationRequest struct { + FeatureName *string `json:"featureName,omitempty"` + FeatureType *FeatureType `json:"featureType,omitempty"` + + // Fields inherited from FeatureValidationRequestBase +} + +var _ json.Marshaler = FeatureValidationRequest{} + +func (s FeatureValidationRequest) MarshalJSON() ([]byte, error) { + type wrapper FeatureValidationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FeatureValidationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FeatureValidationRequest: %+v", err) + } + decoded["objectType"] = "FeatureValidationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FeatureValidationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequestbase.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequestbase.go new file mode 100644 index 00000000000..80efd7fd693 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationrequestbase.go @@ -0,0 +1,53 @@ +package dppfeaturesupport + +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 FeatureValidationRequestBase interface { +} + +// RawFeatureValidationRequestBaseImpl 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 RawFeatureValidationRequestBaseImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFeatureValidationRequestBaseImplementation(input []byte) (FeatureValidationRequestBase, 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 FeatureValidationRequestBase into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "FeatureValidationRequest") { + var out FeatureValidationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FeatureValidationRequest: %+v", err) + } + return out, nil + } + + out := RawFeatureValidationRequestBaseImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponse.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponse.go new file mode 100644 index 00000000000..cf7a0191334 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponse.go @@ -0,0 +1,42 @@ +package dppfeaturesupport + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FeatureValidationResponseBase = FeatureValidationResponse{} + +type FeatureValidationResponse struct { + FeatureType *FeatureType `json:"featureType,omitempty"` + Features *[]SupportedFeature `json:"features,omitempty"` + + // Fields inherited from FeatureValidationResponseBase +} + +var _ json.Marshaler = FeatureValidationResponse{} + +func (s FeatureValidationResponse) MarshalJSON() ([]byte, error) { + type wrapper FeatureValidationResponse + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FeatureValidationResponse: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FeatureValidationResponse: %+v", err) + } + decoded["objectType"] = "FeatureValidationResponse" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FeatureValidationResponse: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponsebase.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponsebase.go new file mode 100644 index 00000000000..77514fd0908 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_featurevalidationresponsebase.go @@ -0,0 +1,53 @@ +package dppfeaturesupport + +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 FeatureValidationResponseBase interface { +} + +// RawFeatureValidationResponseBaseImpl 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 RawFeatureValidationResponseBaseImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFeatureValidationResponseBaseImplementation(input []byte) (FeatureValidationResponseBase, 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 FeatureValidationResponseBase into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "FeatureValidationResponse") { + var out FeatureValidationResponse + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FeatureValidationResponse: %+v", err) + } + return out, nil + } + + out := RawFeatureValidationResponseBaseImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_supportedfeature.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_supportedfeature.go new file mode 100644 index 00000000000..f32f28b1b2c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/model_supportedfeature.go @@ -0,0 +1,10 @@ +package dppfeaturesupport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedFeature struct { + ExposureControlledFeatures *[]string `json:"exposureControlledFeatures,omitempty"` + FeatureName *string `json:"featureName,omitempty"` + SupportStatus *FeatureSupportStatus `json:"supportStatus,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/version.go b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/version.go new file mode 100644 index 00000000000..eb22d1ac312 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppfeaturesupport/version.go @@ -0,0 +1,12 @@ +package dppfeaturesupport + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dppfeaturesupport/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/README.md b/resource-manager/dataprotection/2024-04-01/dppjob/README.md new file mode 100644 index 00000000000..ecb18342127 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/README.md @@ -0,0 +1,63 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/dppjob` Documentation + +The `dppjob` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/dppjob" +``` + + +### Client Initialization + +```go +client := dppjob.NewDppJobClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DppJobClient.FetchCrossRegionRestoreJobGet` + +```go +ctx := context.TODO() +id := dppjob.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +payload := dppjob.CrossRegionRestoreJobRequest{ + // ... +} + + +read, err := client.FetchCrossRegionRestoreJobGet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DppJobClient.FetchCrossRegionRestoreJobsList` + +```go +ctx := context.TODO() +id := dppjob.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +payload := dppjob.CrossRegionRestoreJobsRequest{ + // ... +} + + +// alternatively `client.FetchCrossRegionRestoreJobsList(ctx, id, payload, dppjob.DefaultFetchCrossRegionRestoreJobsListOperationOptions())` can be used to do batched pagination +items, err := client.FetchCrossRegionRestoreJobsListComplete(ctx, id, payload, dppjob.DefaultFetchCrossRegionRestoreJobsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/client.go b/resource-manager/dataprotection/2024-04-01/dppjob/client.go new file mode 100644 index 00000000000..0d6159de0c6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/client.go @@ -0,0 +1,26 @@ +package dppjob + +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 DppJobClient struct { + Client *resourcemanager.Client +} + +func NewDppJobClientWithBaseURI(sdkApi sdkEnv.Api) (*DppJobClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dppjob", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DppJobClient: %+v", err) + } + + return &DppJobClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation.go b/resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation.go new file mode 100644 index 00000000000..9e8309b040d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation.go @@ -0,0 +1,130 @@ +package dppjob + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation_test.go b/resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation_test.go new file mode 100644 index 00000000000..f944816b967 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package dppjob + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobget.go b/resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobget.go new file mode 100644 index 00000000000..9635b5ff158 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobget.go @@ -0,0 +1,59 @@ +package dppjob + +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 FetchCrossRegionRestoreJobGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureBackupJobResource +} + +// FetchCrossRegionRestoreJobGet ... +func (c DppJobClient) FetchCrossRegionRestoreJobGet(ctx context.Context, id ProviderLocationId, input CrossRegionRestoreJobRequest) (result FetchCrossRegionRestoreJobGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/fetchCrossRegionRestoreJob", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureBackupJobResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobslist.go b/resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobslist.go new file mode 100644 index 00000000000..533c244ffd8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/method_fetchcrossregionrestorejobslist.go @@ -0,0 +1,119 @@ +package dppjob + +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 FetchCrossRegionRestoreJobsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureBackupJobResource +} + +type FetchCrossRegionRestoreJobsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AzureBackupJobResource +} + +type FetchCrossRegionRestoreJobsListOperationOptions struct { + Filter *string +} + +func DefaultFetchCrossRegionRestoreJobsListOperationOptions() FetchCrossRegionRestoreJobsListOperationOptions { + return FetchCrossRegionRestoreJobsListOperationOptions{} +} + +func (o FetchCrossRegionRestoreJobsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o FetchCrossRegionRestoreJobsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o FetchCrossRegionRestoreJobsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// FetchCrossRegionRestoreJobsList ... +func (c DppJobClient) FetchCrossRegionRestoreJobsList(ctx context.Context, id ProviderLocationId, input CrossRegionRestoreJobsRequest, options FetchCrossRegionRestoreJobsListOperationOptions) (result FetchCrossRegionRestoreJobsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/fetchCrossRegionRestoreJobs", 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 *[]AzureBackupJobResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// FetchCrossRegionRestoreJobsListComplete retrieves all the results into a single object +func (c DppJobClient) FetchCrossRegionRestoreJobsListComplete(ctx context.Context, id ProviderLocationId, input CrossRegionRestoreJobsRequest, options FetchCrossRegionRestoreJobsListOperationOptions) (FetchCrossRegionRestoreJobsListCompleteResult, error) { + return c.FetchCrossRegionRestoreJobsListCompleteMatchingPredicate(ctx, id, input, options, AzureBackupJobResourceOperationPredicate{}) +} + +// FetchCrossRegionRestoreJobsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DppJobClient) FetchCrossRegionRestoreJobsListCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, input CrossRegionRestoreJobsRequest, options FetchCrossRegionRestoreJobsListOperationOptions, predicate AzureBackupJobResourceOperationPredicate) (result FetchCrossRegionRestoreJobsListCompleteResult, err error) { + items := make([]AzureBackupJobResource, 0) + + resp, err := c.FetchCrossRegionRestoreJobsList(ctx, id, input, 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 = FetchCrossRegionRestoreJobsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjob.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjob.go new file mode 100644 index 00000000000..65be91508fc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjob.go @@ -0,0 +1,65 @@ +package dppjob + +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 AzureBackupJob struct { + ActivityID string `json:"activityID"` + BackupInstanceFriendlyName string `json:"backupInstanceFriendlyName"` + BackupInstanceId *string `json:"backupInstanceId,omitempty"` + DataSourceId string `json:"dataSourceId"` + DataSourceLocation string `json:"dataSourceLocation"` + DataSourceName string `json:"dataSourceName"` + DataSourceSetName *string `json:"dataSourceSetName,omitempty"` + DataSourceType string `json:"dataSourceType"` + DestinationDataStoreName *string `json:"destinationDataStoreName,omitempty"` + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ErrorDetails *[]UserFacingError `json:"errorDetails,omitempty"` + Etag *string `json:"etag,omitempty"` + ExtendedInfo *JobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered bool `json:"isUserTriggered"` + Operation string `json:"operation"` + OperationCategory string `json:"operationCategory"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ProgressEnabled bool `json:"progressEnabled"` + ProgressUrl *string `json:"progressUrl,omitempty"` + RehydrationPriority *string `json:"rehydrationPriority,omitempty"` + RestoreType *string `json:"restoreType,omitempty"` + SourceDataStoreName *string `json:"sourceDataStoreName,omitempty"` + SourceResourceGroup string `json:"sourceResourceGroup"` + SourceSubscriptionID string `json:"sourceSubscriptionID"` + StartTime string `json:"startTime"` + Status string `json:"status"` + SubscriptionId string `json:"subscriptionId"` + SupportedActions []string `json:"supportedActions"` + VaultName string `json:"vaultName"` +} + +func (o *AzureBackupJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureBackupJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureBackupJob) GetStartTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureBackupJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjobresource.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjobresource.go new file mode 100644 index 00000000000..51c24fa7f16 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_azurebackupjobresource.go @@ -0,0 +1,16 @@ +package dppjob + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupJobResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureBackupJob `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobrequest.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobrequest.go new file mode 100644 index 00000000000..a1c23f023e2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobrequest.go @@ -0,0 +1,10 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossRegionRestoreJobRequest struct { + JobId string `json:"jobId"` + SourceBackupVaultId string `json:"sourceBackupVaultId"` + SourceRegion string `json:"sourceRegion"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobsrequest.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobsrequest.go new file mode 100644 index 00000000000..a75015188e1 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_crossregionrestorejobsrequest.go @@ -0,0 +1,9 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossRegionRestoreJobsRequest struct { + SourceBackupVaultId string `json:"sourceBackupVaultId"` + SourceRegion string `json:"sourceRegion"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_innererror.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_innererror.go new file mode 100644 index 00000000000..cc4341695b4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_innererror.go @@ -0,0 +1,10 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InnerError struct { + AdditionalInfo *map[string]string `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + EmbeddedInnerError *InnerError `json:"embeddedInnerError,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_jobextendedinfo.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_jobextendedinfo.go new file mode 100644 index 00000000000..92a9c42ff56 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_jobextendedinfo.go @@ -0,0 +1,15 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobExtendedInfo struct { + AdditionalDetails *map[string]string `json:"additionalDetails,omitempty"` + BackupInstanceState *string `json:"backupInstanceState,omitempty"` + DataTransferredInBytes *float64 `json:"dataTransferredInBytes,omitempty"` + RecoveryDestination *string `json:"recoveryDestination,omitempty"` + SourceRecoverPoint *RestoreJobRecoveryPointDetails `json:"sourceRecoverPoint,omitempty"` + SubTasks *[]JobSubTask `json:"subTasks,omitempty"` + TargetRecoverPoint *RestoreJobRecoveryPointDetails `json:"targetRecoverPoint,omitempty"` + WarningDetails *[]UserFacingWarningDetail `json:"warningDetails,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_jobsubtask.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_jobsubtask.go new file mode 100644 index 00000000000..e329c0eadda --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_jobsubtask.go @@ -0,0 +1,12 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobSubTask struct { + AdditionalDetails *map[string]string `json:"additionalDetails,omitempty"` + TaskId int64 `json:"taskId"` + TaskName string `json:"taskName"` + TaskProgress *string `json:"taskProgress,omitempty"` + TaskStatus string `json:"taskStatus"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_restorejobrecoverypointdetails.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_restorejobrecoverypointdetails.go new file mode 100644 index 00000000000..10f708f3acd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_restorejobrecoverypointdetails.go @@ -0,0 +1,27 @@ +package dppjob + +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 RestoreJobRecoveryPointDetails struct { + RecoveryPointID *string `json:"recoveryPointID,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` +} + +func (o *RestoreJobRecoveryPointDetails) GetRecoveryPointTimeAsTime() (*time.Time, error) { + if o.RecoveryPointTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RecoveryPointTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RestoreJobRecoveryPointDetails) SetRecoveryPointTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RecoveryPointTime = &formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingerror.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingerror.go new file mode 100644 index 00000000000..d2f0c3f3043 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingerror.go @@ -0,0 +1,16 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingError struct { + Code *string `json:"code,omitempty"` + Details *[]UserFacingError `json:"details,omitempty"` + InnerError *InnerError `json:"innerError,omitempty"` + IsRetryable *bool `json:"isRetryable,omitempty"` + IsUserError *bool `json:"isUserError,omitempty"` + Message *string `json:"message,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + RecommendedAction *[]string `json:"recommendedAction,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingwarningdetail.go b/resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingwarningdetail.go new file mode 100644 index 00000000000..f398426c80d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/model_userfacingwarningdetail.go @@ -0,0 +1,9 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserFacingWarningDetail struct { + ResourceName *string `json:"resourceName,omitempty"` + Warning UserFacingError `json:"warning"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppjob/predicates.go b/resource-manager/dataprotection/2024-04-01/dppjob/predicates.go new file mode 100644 index 00000000000..3a5fc03f205 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/predicates.go @@ -0,0 +1,27 @@ +package dppjob + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupJobResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AzureBackupJobResourceOperationPredicate) Matches(input AzureBackupJobResource) 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/dataprotection/2024-04-01/dppjob/version.go b/resource-manager/dataprotection/2024-04-01/dppjob/version.go new file mode 100644 index 00000000000..99425ee09c5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppjob/version.go @@ -0,0 +1,12 @@ +package dppjob + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dppjob/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/README.md b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/README.md new file mode 100644 index 00000000000..92d27602337 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/README.md @@ -0,0 +1,111 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies` Documentation + +The `dppresourceguardproxies` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/dppresourceguardproxies" +``` + + +### Client Initialization + +```go +client := dppresourceguardproxies.NewDppResourceGuardProxiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DppResourceGuardProxiesClient.DppResourceGuardProxyCreateOrUpdate` + +```go +ctx := context.TODO() +id := dppresourceguardproxies.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupResourceGuardProxyValue") + +payload := dppresourceguardproxies.ResourceGuardProxyBaseResource{ + // ... +} + + +read, err := client.DppResourceGuardProxyCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DppResourceGuardProxiesClient.DppResourceGuardProxyDelete` + +```go +ctx := context.TODO() +id := dppresourceguardproxies.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupResourceGuardProxyValue") + +read, err := client.DppResourceGuardProxyDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DppResourceGuardProxiesClient.DppResourceGuardProxyGet` + +```go +ctx := context.TODO() +id := dppresourceguardproxies.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupResourceGuardProxyValue") + +read, err := client.DppResourceGuardProxyGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DppResourceGuardProxiesClient.DppResourceGuardProxyList` + +```go +ctx := context.TODO() +id := dppresourceguardproxies.NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + +// alternatively `client.DppResourceGuardProxyList(ctx, id)` can be used to do batched pagination +items, err := client.DppResourceGuardProxyListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DppResourceGuardProxiesClient.DppResourceGuardProxyUnlockDelete` + +```go +ctx := context.TODO() +id := dppresourceguardproxies.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupResourceGuardProxyValue") + +payload := dppresourceguardproxies.UnlockDeleteRequest{ + // ... +} + + +read, err := client.DppResourceGuardProxyUnlockDelete(ctx, id, payload, dppresourceguardproxies.DefaultDppResourceGuardProxyUnlockDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/client.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/client.go new file mode 100644 index 00000000000..f44efd92c08 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/client.go @@ -0,0 +1,26 @@ +package dppresourceguardproxies + +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 DppResourceGuardProxiesClient struct { + Client *resourcemanager.Client +} + +func NewDppResourceGuardProxiesClientWithBaseURI(sdkApi sdkEnv.Api) (*DppResourceGuardProxiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dppresourceguardproxies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DppResourceGuardProxiesClient: %+v", err) + } + + return &DppResourceGuardProxiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy.go new file mode 100644 index 00000000000..a6f07c8cb77 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy.go @@ -0,0 +1,139 @@ +package dppresourceguardproxies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupResourceGuardProxyId{}) +} + +var _ resourceids.ResourceId = &BackupResourceGuardProxyId{} + +// BackupResourceGuardProxyId is a struct representing the Resource ID for a Backup Resource Guard Proxy +type BackupResourceGuardProxyId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + BackupResourceGuardProxyName string +} + +// NewBackupResourceGuardProxyID returns a new BackupResourceGuardProxyId struct +func NewBackupResourceGuardProxyID(subscriptionId string, resourceGroupName string, backupVaultName string, backupResourceGuardProxyName string) BackupResourceGuardProxyId { + return BackupResourceGuardProxyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + BackupResourceGuardProxyName: backupResourceGuardProxyName, + } +} + +// ParseBackupResourceGuardProxyID parses 'input' into a BackupResourceGuardProxyId +func ParseBackupResourceGuardProxyID(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupResourceGuardProxyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupResourceGuardProxyIDInsensitively parses 'input' case-insensitively into a BackupResourceGuardProxyId +// note: this method should only be used for API response data and not user input +func ParseBackupResourceGuardProxyIDInsensitively(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupResourceGuardProxyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupResourceGuardProxyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.BackupResourceGuardProxyName, ok = input.Parsed["backupResourceGuardProxyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupResourceGuardProxyName", input) + } + + return nil +} + +// ValidateBackupResourceGuardProxyID checks that 'input' can be parsed as a Backup Resource Guard Proxy ID +func ValidateBackupResourceGuardProxyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupResourceGuardProxyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupResourceGuardProxies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.BackupResourceGuardProxyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupResourceGuardProxies", "backupResourceGuardProxies", "backupResourceGuardProxies"), + resourceids.UserSpecifiedSegment("backupResourceGuardProxyName", "backupResourceGuardProxyValue"), + } +} + +// String returns a human-readable description of this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Backup Resource Guard Proxy Name: %q", id.BackupResourceGuardProxyName), + } + return fmt.Sprintf("Backup Resource Guard Proxy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy_test.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy_test.go new file mode 100644 index 00000000000..2309a3fddb0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupresourceguardproxy_test.go @@ -0,0 +1,327 @@ +package dppresourceguardproxies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupResourceGuardProxyId{} + +func TestNewBackupResourceGuardProxyID(t *testing.T) { + id := NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupResourceGuardProxyValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.BackupResourceGuardProxyName != "backupResourceGuardProxyValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupResourceGuardProxyName'", id.BackupResourceGuardProxyName, "backupResourceGuardProxyValue") + } +} + +func TestFormatBackupResourceGuardProxyID(t *testing.T) { + actual := NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupResourceGuardProxyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupResourceGuardProxyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupResourceGuardProxyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupResourceGuardProxies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupResourceGuardProxyName: "backupResourceGuardProxyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupResourceGuardProxyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupResourceGuardProxyName != v.Expected.BackupResourceGuardProxyName { + t.Fatalf("Expected %q but got %q for BackupResourceGuardProxyName", v.Expected.BackupResourceGuardProxyName, actual.BackupResourceGuardProxyName) + } + + } +} + +func TestParseBackupResourceGuardProxyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupResourceGuardProxyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupResourceGuardProxies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupResourceGuardProxyName: "backupResourceGuardProxyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYvAlUe", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + BackupResourceGuardProxyName: "bAcKuPrEsOuRcEgUaRdPrOxYvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupResourceGuardProxyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupResourceGuardProxyName != v.Expected.BackupResourceGuardProxyName { + t.Fatalf("Expected %q but got %q for BackupResourceGuardProxyName", v.Expected.BackupResourceGuardProxyName, actual.BackupResourceGuardProxyName) + } + + } +} + +func TestSegmentsForBackupResourceGuardProxyId(t *testing.T) { + segments := BackupResourceGuardProxyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupResourceGuardProxyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault.go new file mode 100644 index 00000000000..e495aa166e4 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault.go @@ -0,0 +1,130 @@ +package dppresourceguardproxies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupVaultId{}) +} + +var _ resourceids.ResourceId = &BackupVaultId{} + +// BackupVaultId is a struct representing the Resource ID for a Backup Vault +type BackupVaultId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string +} + +// NewBackupVaultID returns a new BackupVaultId struct +func NewBackupVaultID(subscriptionId string, resourceGroupName string, backupVaultName string) BackupVaultId { + return BackupVaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + } +} + +// ParseBackupVaultID parses 'input' into a BackupVaultId +func ParseBackupVaultID(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupVaultIDInsensitively parses 'input' case-insensitively into a BackupVaultId +// note: this method should only be used for API response data and not user input +func ParseBackupVaultIDInsensitively(input string) (*BackupVaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupVaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupVaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupVaultId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + return nil +} + +// ValidateBackupVaultID checks that 'input' can be parsed as a Backup Vault ID +func ValidateBackupVaultID(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 := ParseBackupVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Vault ID +func (id BackupVaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Vault ID +func (id BackupVaultId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + } +} + +// String returns a human-readable description of this Backup Vault ID +func (id BackupVaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + } + return fmt.Sprintf("Backup Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault_test.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault_test.go new file mode 100644 index 00000000000..0e6fef664c0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/id_backupvault_test.go @@ -0,0 +1,282 @@ +package dppresourceguardproxies + +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 = &BackupVaultId{} + +func TestNewBackupVaultID(t *testing.T) { + id := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } +} + +func TestFormatBackupVaultID(t *testing.T) { + actual := NewBackupVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestParseBackupVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupVaultId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Expected: &BackupVaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + } +} + +func TestSegmentsForBackupVaultId(t *testing.T) { + segments := BackupVaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupVaultId 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/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxycreateorupdate.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxycreateorupdate.go new file mode 100644 index 00000000000..a59d9ee6c52 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxycreateorupdate.go @@ -0,0 +1,58 @@ +package dppresourceguardproxies + +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 DppResourceGuardProxyCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceGuardProxyBaseResource +} + +// DppResourceGuardProxyCreateOrUpdate ... +func (c DppResourceGuardProxiesClient) DppResourceGuardProxyCreateOrUpdate(ctx context.Context, id BackupResourceGuardProxyId, input ResourceGuardProxyBaseResource) (result DppResourceGuardProxyCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceGuardProxyBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxydelete.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxydelete.go new file mode 100644 index 00000000000..86075b7794f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxydelete.go @@ -0,0 +1,47 @@ +package dppresourceguardproxies + +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 DppResourceGuardProxyDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DppResourceGuardProxyDelete ... +func (c DppResourceGuardProxiesClient) DppResourceGuardProxyDelete(ctx context.Context, id BackupResourceGuardProxyId) (result DppResourceGuardProxyDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyget.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyget.go new file mode 100644 index 00000000000..33b05521f54 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyget.go @@ -0,0 +1,54 @@ +package dppresourceguardproxies + +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 DppResourceGuardProxyGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceGuardProxyBaseResource +} + +// DppResourceGuardProxyGet ... +func (c DppResourceGuardProxiesClient) DppResourceGuardProxyGet(ctx context.Context, id BackupResourceGuardProxyId) (result DppResourceGuardProxyGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceGuardProxyBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxylist.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxylist.go new file mode 100644 index 00000000000..c36e8705c3f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxylist.go @@ -0,0 +1,91 @@ +package dppresourceguardproxies + +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 DppResourceGuardProxyListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceGuardProxyBaseResource +} + +type DppResourceGuardProxyListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceGuardProxyBaseResource +} + +// DppResourceGuardProxyList ... +func (c DppResourceGuardProxiesClient) DppResourceGuardProxyList(ctx context.Context, id BackupVaultId) (result DppResourceGuardProxyListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backupResourceGuardProxies", 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 *[]ResourceGuardProxyBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DppResourceGuardProxyListComplete retrieves all the results into a single object +func (c DppResourceGuardProxiesClient) DppResourceGuardProxyListComplete(ctx context.Context, id BackupVaultId) (DppResourceGuardProxyListCompleteResult, error) { + return c.DppResourceGuardProxyListCompleteMatchingPredicate(ctx, id, ResourceGuardProxyBaseResourceOperationPredicate{}) +} + +// DppResourceGuardProxyListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DppResourceGuardProxiesClient) DppResourceGuardProxyListCompleteMatchingPredicate(ctx context.Context, id BackupVaultId, predicate ResourceGuardProxyBaseResourceOperationPredicate) (result DppResourceGuardProxyListCompleteResult, err error) { + items := make([]ResourceGuardProxyBaseResource, 0) + + resp, err := c.DppResourceGuardProxyList(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 = DppResourceGuardProxyListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyunlockdelete.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyunlockdelete.go new file mode 100644 index 00000000000..8395140925b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/method_dppresourceguardproxyunlockdelete.go @@ -0,0 +1,87 @@ +package dppresourceguardproxies + +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 DppResourceGuardProxyUnlockDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *UnlockDeleteResponse +} + +type DppResourceGuardProxyUnlockDeleteOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultDppResourceGuardProxyUnlockDeleteOperationOptions() DppResourceGuardProxyUnlockDeleteOperationOptions { + return DppResourceGuardProxyUnlockDeleteOperationOptions{} +} + +func (o DppResourceGuardProxyUnlockDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o DppResourceGuardProxyUnlockDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DppResourceGuardProxyUnlockDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// DppResourceGuardProxyUnlockDelete ... +func (c DppResourceGuardProxiesClient) DppResourceGuardProxyUnlockDelete(ctx context.Context, id BackupResourceGuardProxyId, input UnlockDeleteRequest, options DppResourceGuardProxyUnlockDeleteOperationOptions) (result DppResourceGuardProxyUnlockDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unlockDelete", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model UnlockDeleteResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardoperationdetail.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardoperationdetail.go new file mode 100644 index 00000000000..6540ed78351 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardoperationdetail.go @@ -0,0 +1,9 @@ +package dppresourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardOperationDetail struct { + DefaultResourceRequest *string `json:"defaultResourceRequest,omitempty"` + VaultCriticalOperation *string `json:"vaultCriticalOperation,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybase.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybase.go new file mode 100644 index 00000000000..d752010f8cc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybase.go @@ -0,0 +1,11 @@ +package dppresourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBase struct { + Description *string `json:"description,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + ResourceGuardOperationDetails *[]ResourceGuardOperationDetail `json:"resourceGuardOperationDetails,omitempty"` + ResourceGuardResourceId *string `json:"resourceGuardResourceId,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybaseresource.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybaseresource.go new file mode 100644 index 00000000000..4e6713c4856 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_resourceguardproxybaseresource.go @@ -0,0 +1,16 @@ +package dppresourceguardproxies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceGuardProxyBase `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleterequest.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleterequest.go new file mode 100644 index 00000000000..e5415cf7db3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleterequest.go @@ -0,0 +1,9 @@ +package dppresourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteRequest struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ResourceToBeDeleted *string `json:"resourceToBeDeleted,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleteresponse.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleteresponse.go new file mode 100644 index 00000000000..408d1ec0fc8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/model_unlockdeleteresponse.go @@ -0,0 +1,8 @@ +package dppresourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteResponse struct { + UnlockDeleteExpiryTime *string `json:"unlockDeleteExpiryTime,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/predicates.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/predicates.go new file mode 100644 index 00000000000..6da3b96156e --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/predicates.go @@ -0,0 +1,27 @@ +package dppresourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ResourceGuardProxyBaseResourceOperationPredicate) Matches(input ResourceGuardProxyBaseResource) 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/dataprotection/2024-04-01/dppresourceguardproxies/version.go b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/version.go new file mode 100644 index 00000000000..a0cdd34fe55 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/dppresourceguardproxies/version.go @@ -0,0 +1,12 @@ +package dppresourceguardproxies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dppresourceguardproxies/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/README.md b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/README.md new file mode 100644 index 00000000000..36c620284eb --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints` Documentation + +The `fetchsecondaryrecoverypoints` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/fetchsecondaryrecoverypoints" +``` + + +### Client Initialization + +```go +client := fetchsecondaryrecoverypoints.NewFetchSecondaryRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FetchSecondaryRecoveryPointsClient.List` + +```go +ctx := context.TODO() +id := fetchsecondaryrecoverypoints.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +payload := fetchsecondaryrecoverypoints.FetchSecondaryRPsRequestParameters{ + // ... +} + + +// alternatively `client.List(ctx, id, payload, fetchsecondaryrecoverypoints.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, payload, fetchsecondaryrecoverypoints.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/client.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/client.go new file mode 100644 index 00000000000..0ac726e9656 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/client.go @@ -0,0 +1,26 @@ +package fetchsecondaryrecoverypoints + +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 FetchSecondaryRecoveryPointsClient struct { + Client *resourcemanager.Client +} + +func NewFetchSecondaryRecoveryPointsClientWithBaseURI(sdkApi sdkEnv.Api) (*FetchSecondaryRecoveryPointsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "fetchsecondaryrecoverypoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FetchSecondaryRecoveryPointsClient: %+v", err) + } + + return &FetchSecondaryRecoveryPointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/constants.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/constants.go new file mode 100644 index 00000000000..4ad5deabceb --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/constants.go @@ -0,0 +1,101 @@ +package fetchsecondaryrecoverypoints + +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 RecoveryPointCompletionState string + +const ( + RecoveryPointCompletionStateCompleted RecoveryPointCompletionState = "Completed" + RecoveryPointCompletionStatePartial RecoveryPointCompletionState = "Partial" +) + +func PossibleValuesForRecoveryPointCompletionState() []string { + return []string{ + string(RecoveryPointCompletionStateCompleted), + string(RecoveryPointCompletionStatePartial), + } +} + +func (s *RecoveryPointCompletionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointCompletionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointCompletionState(input string) (*RecoveryPointCompletionState, error) { + vals := map[string]RecoveryPointCompletionState{ + "completed": RecoveryPointCompletionStateCompleted, + "partial": RecoveryPointCompletionStatePartial, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointCompletionState(input) + return &out, nil +} + +type RehydrationStatus string + +const ( + RehydrationStatusCOMPLETED RehydrationStatus = "COMPLETED" + RehydrationStatusCREATEINPROGRESS RehydrationStatus = "CREATE_IN_PROGRESS" + RehydrationStatusDELETED RehydrationStatus = "DELETED" + RehydrationStatusDELETEINPROGRESS RehydrationStatus = "DELETE_IN_PROGRESS" + RehydrationStatusFAILED RehydrationStatus = "FAILED" +) + +func PossibleValuesForRehydrationStatus() []string { + return []string{ + string(RehydrationStatusCOMPLETED), + string(RehydrationStatusCREATEINPROGRESS), + string(RehydrationStatusDELETED), + string(RehydrationStatusDELETEINPROGRESS), + string(RehydrationStatusFAILED), + } +} + +func (s *RehydrationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRehydrationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRehydrationStatus(input string) (*RehydrationStatus, error) { + vals := map[string]RehydrationStatus{ + "completed": RehydrationStatusCOMPLETED, + "create_in_progress": RehydrationStatusCREATEINPROGRESS, + "deleted": RehydrationStatusDELETED, + "delete_in_progress": RehydrationStatusDELETEINPROGRESS, + "failed": RehydrationStatusFAILED, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationStatus(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation.go new file mode 100644 index 00000000000..72b7a004674 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation.go @@ -0,0 +1,130 @@ +package fetchsecondaryrecoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation_test.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation_test.go new file mode 100644 index 00000000000..54d1e596660 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package fetchsecondaryrecoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/method_list.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/method_list.go new file mode 100644 index 00000000000..c12ef3ccd31 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/method_list.go @@ -0,0 +1,119 @@ +package fetchsecondaryrecoverypoints + +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 *[]AzureBackupRecoveryPointResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AzureBackupRecoveryPointResource +} + +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 FetchSecondaryRecoveryPointsClient) List(ctx context.Context, id ProviderLocationId, input FetchSecondaryRPsRequestParameters, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/fetchSecondaryRecoveryPoints", 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 *[]AzureBackupRecoveryPointResource `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 FetchSecondaryRecoveryPointsClient) ListComplete(ctx context.Context, id ProviderLocationId, input FetchSecondaryRPsRequestParameters, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, input, options, AzureBackupRecoveryPointResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FetchSecondaryRecoveryPointsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, input FetchSecondaryRPsRequestParameters, options ListOperationOptions, predicate AzureBackupRecoveryPointResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AzureBackupRecoveryPointResource, 0) + + resp, err := c.List(ctx, id, input, 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/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackupdiscreterecoverypoint.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackupdiscreterecoverypoint.go new file mode 100644 index 00000000000..33e554f5b79 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackupdiscreterecoverypoint.go @@ -0,0 +1,51 @@ +package fetchsecondaryrecoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AzureBackupRecoveryPoint = AzureBackupDiscreteRecoveryPoint{} + +type AzureBackupDiscreteRecoveryPoint struct { + ExpiryTime *string `json:"expiryTime,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + PolicyVersion *string `json:"policyVersion,omitempty"` + RecoveryPointDataStoresDetails *[]RecoveryPointDataStoreDetails `json:"recoveryPointDataStoresDetails,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointState *RecoveryPointCompletionState `json:"recoveryPointState,omitempty"` + RecoveryPointTime string `json:"recoveryPointTime"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + RetentionTagName *string `json:"retentionTagName,omitempty"` + RetentionTagVersion *string `json:"retentionTagVersion,omitempty"` + + // Fields inherited from AzureBackupRecoveryPoint +} + +var _ json.Marshaler = AzureBackupDiscreteRecoveryPoint{} + +func (s AzureBackupDiscreteRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupDiscreteRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupDiscreteRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupDiscreteRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureBackupDiscreteRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupDiscreteRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypoint.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypoint.go new file mode 100644 index 00000000000..81815b8b85c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypoint.go @@ -0,0 +1,53 @@ +package fetchsecondaryrecoverypoints + +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 AzureBackupRecoveryPoint interface { +} + +// RawAzureBackupRecoveryPointImpl 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 RawAzureBackupRecoveryPointImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAzureBackupRecoveryPointImplementation(input []byte) (AzureBackupRecoveryPoint, 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 AzureBackupRecoveryPoint into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupDiscreteRecoveryPoint") { + var out AzureBackupDiscreteRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupDiscreteRecoveryPoint: %+v", err) + } + return out, nil + } + + out := RawAzureBackupRecoveryPointImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypointresource.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypointresource.go new file mode 100644 index 00000000000..b09db4ee8cd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_azurebackuprecoverypointresource.go @@ -0,0 +1,48 @@ +package fetchsecondaryrecoverypoints + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupRecoveryPointResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AzureBackupRecoveryPoint `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &AzureBackupRecoveryPointResource{} + +func (s *AzureBackupRecoveryPointResource) UnmarshalJSON(bytes []byte) error { + type alias AzureBackupRecoveryPointResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureBackupRecoveryPointResource: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureBackupRecoveryPointResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalAzureBackupRecoveryPointImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'AzureBackupRecoveryPointResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_fetchsecondaryrpsrequestparameters.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_fetchsecondaryrpsrequestparameters.go new file mode 100644 index 00000000000..7a692e03408 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_fetchsecondaryrpsrequestparameters.go @@ -0,0 +1,9 @@ +package fetchsecondaryrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FetchSecondaryRPsRequestParameters struct { + SourceBackupInstanceId *string `json:"sourceBackupInstanceId,omitempty"` + SourceRegion *string `json:"sourceRegion,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_recoverypointdatastoredetails.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_recoverypointdatastoredetails.go new file mode 100644 index 00000000000..abdf9b9007f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/model_recoverypointdatastoredetails.go @@ -0,0 +1,58 @@ +package fetchsecondaryrecoverypoints + +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 RecoveryPointDataStoreDetails struct { + CreationTime *string `json:"creationTime,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Id *string `json:"id,omitempty"` + MetaData *string `json:"metaData,omitempty"` + RehydrationExpiryTime *string `json:"rehydrationExpiryTime,omitempty"` + RehydrationStatus *RehydrationStatus `json:"rehydrationStatus,omitempty"` + State *string `json:"state,omitempty"` + Type *string `json:"type,omitempty"` + Visible *bool `json:"visible,omitempty"` +} + +func (o *RecoveryPointDataStoreDetails) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointDataStoreDetails) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RecoveryPointDataStoreDetails) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointDataStoreDetails) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +func (o *RecoveryPointDataStoreDetails) GetRehydrationExpiryTimeAsTime() (*time.Time, error) { + if o.RehydrationExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RehydrationExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointDataStoreDetails) SetRehydrationExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RehydrationExpiryTime = &formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/predicates.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/predicates.go new file mode 100644 index 00000000000..b9a05d28a27 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/predicates.go @@ -0,0 +1,27 @@ +package fetchsecondaryrecoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupRecoveryPointResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AzureBackupRecoveryPointResourceOperationPredicate) Matches(input AzureBackupRecoveryPointResource) 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/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/version.go b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/version.go new file mode 100644 index 00000000000..98346fda9bd --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/fetchsecondaryrecoverypoints/version.go @@ -0,0 +1,12 @@ +package fetchsecondaryrecoverypoints + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/fetchsecondaryrecoverypoints/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/README.md b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/README.md new file mode 100644 index 00000000000..7322509ad29 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges` Documentation + +The `findrestorabletimeranges` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/findrestorabletimeranges" +``` + + +### Client Initialization + +```go +client := findrestorabletimeranges.NewFindRestorableTimeRangesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FindRestorableTimeRangesClient.RestorableTimeRangesFind` + +```go +ctx := context.TODO() +id := findrestorabletimeranges.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +payload := findrestorabletimeranges.AzureBackupFindRestorableTimeRangesRequest{ + // ... +} + + +read, err := client.RestorableTimeRangesFind(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/client.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/client.go new file mode 100644 index 00000000000..bfd1fda26df --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/client.go @@ -0,0 +1,26 @@ +package findrestorabletimeranges + +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 FindRestorableTimeRangesClient struct { + Client *resourcemanager.Client +} + +func NewFindRestorableTimeRangesClientWithBaseURI(sdkApi sdkEnv.Api) (*FindRestorableTimeRangesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "findrestorabletimeranges", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FindRestorableTimeRangesClient: %+v", err) + } + + return &FindRestorableTimeRangesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/constants.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/constants.go new file mode 100644 index 00000000000..3afd71927af --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/constants.go @@ -0,0 +1,54 @@ +package findrestorabletimeranges + +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 RestoreSourceDataStoreType string + +const ( + RestoreSourceDataStoreTypeArchiveStore RestoreSourceDataStoreType = "ArchiveStore" + RestoreSourceDataStoreTypeOperationalStore RestoreSourceDataStoreType = "OperationalStore" + RestoreSourceDataStoreTypeVaultStore RestoreSourceDataStoreType = "VaultStore" +) + +func PossibleValuesForRestoreSourceDataStoreType() []string { + return []string{ + string(RestoreSourceDataStoreTypeArchiveStore), + string(RestoreSourceDataStoreTypeOperationalStore), + string(RestoreSourceDataStoreTypeVaultStore), + } +} + +func (s *RestoreSourceDataStoreType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRestoreSourceDataStoreType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRestoreSourceDataStoreType(input string) (*RestoreSourceDataStoreType, error) { + vals := map[string]RestoreSourceDataStoreType{ + "archivestore": RestoreSourceDataStoreTypeArchiveStore, + "operationalstore": RestoreSourceDataStoreTypeOperationalStore, + "vaultstore": RestoreSourceDataStoreTypeVaultStore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreSourceDataStoreType(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance.go new file mode 100644 index 00000000000..25f53ef1e8a --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance.go @@ -0,0 +1,139 @@ +package findrestorabletimeranges + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupInstanceId{}) +} + +var _ resourceids.ResourceId = &BackupInstanceId{} + +// BackupInstanceId is a struct representing the Resource ID for a Backup Instance +type BackupInstanceId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + BackupInstanceName string +} + +// NewBackupInstanceID returns a new BackupInstanceId struct +func NewBackupInstanceID(subscriptionId string, resourceGroupName string, backupVaultName string, backupInstanceName string) BackupInstanceId { + return BackupInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + BackupInstanceName: backupInstanceName, + } +} + +// ParseBackupInstanceID parses 'input' into a BackupInstanceId +func ParseBackupInstanceID(input string) (*BackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupInstanceIDInsensitively parses 'input' case-insensitively into a BackupInstanceId +// note: this method should only be used for API response data and not user input +func ParseBackupInstanceIDInsensitively(input string) (*BackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupInstanceId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.BackupInstanceName, ok = input.Parsed["backupInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupInstanceName", input) + } + + return nil +} + +// ValidateBackupInstanceID checks that 'input' can be parsed as a Backup Instance ID +func ValidateBackupInstanceID(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 := ParseBackupInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Instance ID +func (id BackupInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.BackupInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Instance ID +func (id BackupInstanceId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupInstances", "backupInstances", "backupInstances"), + resourceids.UserSpecifiedSegment("backupInstanceName", "backupInstanceValue"), + } +} + +// String returns a human-readable description of this Backup Instance ID +func (id BackupInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Backup Instance Name: %q", id.BackupInstanceName), + } + return fmt.Sprintf("Backup Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance_test.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance_test.go new file mode 100644 index 00000000000..14892d4f842 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/id_backupinstance_test.go @@ -0,0 +1,327 @@ +package findrestorabletimeranges + +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 = &BackupInstanceId{} + +func TestNewBackupInstanceID(t *testing.T) { + id := NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.BackupInstanceName != "backupInstanceValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupInstanceName'", id.BackupInstanceName, "backupInstanceValue") + } +} + +func TestFormatBackupInstanceID(t *testing.T) { + actual := NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + } +} + +func TestParseBackupInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + BackupInstanceName: "bAcKuPiNsTaNcEvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + } +} + +func TestSegmentsForBackupInstanceId(t *testing.T) { + segments := BackupInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupInstanceId 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/dataprotection/2024-04-01/findrestorabletimeranges/method_restorabletimerangesfind.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/method_restorabletimerangesfind.go new file mode 100644 index 00000000000..a0c43a05b78 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/method_restorabletimerangesfind.go @@ -0,0 +1,59 @@ +package findrestorabletimeranges + +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 RestorableTimeRangesFindOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureBackupFindRestorableTimeRangesResponseResource +} + +// RestorableTimeRangesFind ... +func (c FindRestorableTimeRangesClient) RestorableTimeRangesFind(ctx context.Context, id BackupInstanceId, input AzureBackupFindRestorableTimeRangesRequest) (result RestorableTimeRangesFindOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/findRestorableTimeRanges", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureBackupFindRestorableTimeRangesResponseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesrequest.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesrequest.go new file mode 100644 index 00000000000..3788f11d512 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesrequest.go @@ -0,0 +1,10 @@ +package findrestorabletimeranges + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupFindRestorableTimeRangesRequest struct { + EndTime *string `json:"endTime,omitempty"` + SourceDataStoreType RestoreSourceDataStoreType `json:"sourceDataStoreType"` + StartTime *string `json:"startTime,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponse.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponse.go new file mode 100644 index 00000000000..2c361dccf44 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponse.go @@ -0,0 +1,9 @@ +package findrestorabletimeranges + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupFindRestorableTimeRangesResponse struct { + ObjectType *string `json:"objectType,omitempty"` + RestorableTimeRanges *[]RestorableTimeRange `json:"restorableTimeRanges,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponseresource.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponseresource.go new file mode 100644 index 00000000000..bd16082c55f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_azurebackupfindrestorabletimerangesresponseresource.go @@ -0,0 +1,16 @@ +package findrestorabletimeranges + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupFindRestorableTimeRangesResponseResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureBackupFindRestorableTimeRangesResponse `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_restorabletimerange.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_restorabletimerange.go new file mode 100644 index 00000000000..1ea7cdc9433 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/model_restorabletimerange.go @@ -0,0 +1,10 @@ +package findrestorabletimeranges + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestorableTimeRange struct { + EndTime string `json:"endTime"` + ObjectType *string `json:"objectType,omitempty"` + StartTime string `json:"startTime"` +} diff --git a/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/version.go b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/version.go new file mode 100644 index 00000000000..515ceb0ad09 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/findrestorabletimeranges/version.go @@ -0,0 +1,12 @@ +package findrestorabletimeranges + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/findrestorabletimeranges/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/README.md b/resource-manager/dataprotection/2024-04-01/recoverypoint/README.md new file mode 100644 index 00000000000..38fde1ef01c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/recoverypoint` Documentation + +The `recoverypoint` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/recoverypoint" +``` + + +### Client Initialization + +```go +client := recoverypoint.NewRecoveryPointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointClient.Get` + +```go +ctx := context.TODO() +id := recoverypoint.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue", "recoveryPointIdValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecoveryPointClient.List` + +```go +ctx := context.TODO() +id := recoverypoint.NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + +// alternatively `client.List(ctx, id, recoverypoint.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, recoverypoint.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/client.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/client.go new file mode 100644 index 00000000000..d58f74c6c6a --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/client.go @@ -0,0 +1,26 @@ +package recoverypoint + +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 RecoveryPointClient struct { + Client *resourcemanager.Client +} + +func NewRecoveryPointClientWithBaseURI(sdkApi sdkEnv.Api) (*RecoveryPointClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "recoverypoint", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecoveryPointClient: %+v", err) + } + + return &RecoveryPointClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/constants.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/constants.go new file mode 100644 index 00000000000..9a81c1ea973 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/constants.go @@ -0,0 +1,101 @@ +package recoverypoint + +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 RecoveryPointCompletionState string + +const ( + RecoveryPointCompletionStateCompleted RecoveryPointCompletionState = "Completed" + RecoveryPointCompletionStatePartial RecoveryPointCompletionState = "Partial" +) + +func PossibleValuesForRecoveryPointCompletionState() []string { + return []string{ + string(RecoveryPointCompletionStateCompleted), + string(RecoveryPointCompletionStatePartial), + } +} + +func (s *RecoveryPointCompletionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecoveryPointCompletionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecoveryPointCompletionState(input string) (*RecoveryPointCompletionState, error) { + vals := map[string]RecoveryPointCompletionState{ + "completed": RecoveryPointCompletionStateCompleted, + "partial": RecoveryPointCompletionStatePartial, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointCompletionState(input) + return &out, nil +} + +type RehydrationStatus string + +const ( + RehydrationStatusCOMPLETED RehydrationStatus = "COMPLETED" + RehydrationStatusCREATEINPROGRESS RehydrationStatus = "CREATE_IN_PROGRESS" + RehydrationStatusDELETED RehydrationStatus = "DELETED" + RehydrationStatusDELETEINPROGRESS RehydrationStatus = "DELETE_IN_PROGRESS" + RehydrationStatusFAILED RehydrationStatus = "FAILED" +) + +func PossibleValuesForRehydrationStatus() []string { + return []string{ + string(RehydrationStatusCOMPLETED), + string(RehydrationStatusCREATEINPROGRESS), + string(RehydrationStatusDELETED), + string(RehydrationStatusDELETEINPROGRESS), + string(RehydrationStatusFAILED), + } +} + +func (s *RehydrationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRehydrationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRehydrationStatus(input string) (*RehydrationStatus, error) { + vals := map[string]RehydrationStatus{ + "completed": RehydrationStatusCOMPLETED, + "create_in_progress": RehydrationStatusCREATEINPROGRESS, + "deleted": RehydrationStatusDELETED, + "delete_in_progress": RehydrationStatusDELETEINPROGRESS, + "failed": RehydrationStatusFAILED, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationStatus(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance.go new file mode 100644 index 00000000000..ae213017beb --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance.go @@ -0,0 +1,139 @@ +package recoverypoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupInstanceId{}) +} + +var _ resourceids.ResourceId = &BackupInstanceId{} + +// BackupInstanceId is a struct representing the Resource ID for a Backup Instance +type BackupInstanceId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + BackupInstanceName string +} + +// NewBackupInstanceID returns a new BackupInstanceId struct +func NewBackupInstanceID(subscriptionId string, resourceGroupName string, backupVaultName string, backupInstanceName string) BackupInstanceId { + return BackupInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + BackupInstanceName: backupInstanceName, + } +} + +// ParseBackupInstanceID parses 'input' into a BackupInstanceId +func ParseBackupInstanceID(input string) (*BackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupInstanceIDInsensitively parses 'input' case-insensitively into a BackupInstanceId +// note: this method should only be used for API response data and not user input +func ParseBackupInstanceIDInsensitively(input string) (*BackupInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupInstanceId) 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.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.BackupInstanceName, ok = input.Parsed["backupInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupInstanceName", input) + } + + return nil +} + +// ValidateBackupInstanceID checks that 'input' can be parsed as a Backup Instance ID +func ValidateBackupInstanceID(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 := ParseBackupInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Instance ID +func (id BackupInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.BackupInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Instance ID +func (id BackupInstanceId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupInstances", "backupInstances", "backupInstances"), + resourceids.UserSpecifiedSegment("backupInstanceName", "backupInstanceValue"), + } +} + +// String returns a human-readable description of this Backup Instance ID +func (id BackupInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Backup Instance Name: %q", id.BackupInstanceName), + } + return fmt.Sprintf("Backup Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance_test.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance_test.go new file mode 100644 index 00000000000..02d1b157ded --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_backupinstance_test.go @@ -0,0 +1,327 @@ +package recoverypoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupInstanceId{} + +func TestNewBackupInstanceID(t *testing.T) { + id := NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue") + + 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.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.BackupInstanceName != "backupInstanceValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupInstanceName'", id.BackupInstanceName, "backupInstanceValue") + } +} + +func TestFormatBackupInstanceID(t *testing.T) { + actual := NewBackupInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + } +} + +func TestParseBackupInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupInstanceId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe", + Expected: &BackupInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + BackupInstanceName: "bAcKuPiNsTaNcEvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + } +} + +func TestSegmentsForBackupInstanceId(t *testing.T) { + segments := BackupInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupInstanceId 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/dataprotection/2024-04-01/recoverypoint/id_recoverypoint.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_recoverypoint.go new file mode 100644 index 00000000000..8a6823eb8aa --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_recoverypoint.go @@ -0,0 +1,148 @@ +package recoverypoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + BackupVaultName string + BackupInstanceName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, backupVaultName string, backupInstanceName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BackupVaultName: backupVaultName, + BackupInstanceName: backupInstanceName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BackupVaultName, ok = input.Parsed["backupVaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupVaultName", input) + } + + if id.BackupInstanceName, ok = input.Parsed["backupInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupInstanceName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/backupVaults/%s/backupInstances/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BackupVaultName, id.BackupInstanceName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticBackupVaults", "backupVaults", "backupVaults"), + resourceids.UserSpecifiedSegment("backupVaultName", "backupVaultValue"), + resourceids.StaticSegment("staticBackupInstances", "backupInstances", "backupInstances"), + resourceids.UserSpecifiedSegment("backupInstanceName", "backupInstanceValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Backup Vault Name: %q", id.BackupVaultName), + fmt.Sprintf("Backup Instance Name: %q", id.BackupInstanceName), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/id_recoverypoint_test.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_recoverypoint_test.go new file mode 100644 index 00000000000..c046b6c56ad --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/id_recoverypoint_test.go @@ -0,0 +1,372 @@ +package recoverypoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue", "recoveryPointIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BackupVaultName != "backupVaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupVaultName'", id.BackupVaultName, "backupVaultValue") + } + + if id.BackupInstanceName != "backupInstanceValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupInstanceName'", id.BackupInstanceName, "backupInstanceValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "backupVaultValue", "backupInstanceValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/recoveryPoints/recoveryPointIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BackupVaultName: "backupVaultValue", + BackupInstanceName: "backupInstanceValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/backupVaults/backupVaultValue/backupInstances/backupInstanceValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BackupVaultName: "bAcKuPvAuLtVaLuE", + BackupInstanceName: "bAcKuPiNsTaNcEvAlUe", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/bAcKuPvAuLtS/bAcKuPvAuLtVaLuE/bAcKuPiNsTaNcEs/bAcKuPiNsTaNcEvAlUe/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BackupVaultName != v.Expected.BackupVaultName { + t.Fatalf("Expected %q but got %q for BackupVaultName", v.Expected.BackupVaultName, actual.BackupVaultName) + } + + if actual.BackupInstanceName != v.Expected.BackupInstanceName { + t.Fatalf("Expected %q but got %q for BackupInstanceName", v.Expected.BackupInstanceName, actual.BackupInstanceName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/method_get.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/method_get.go new file mode 100644 index 00000000000..aef9f3c1f69 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/method_get.go @@ -0,0 +1,54 @@ +package recoverypoint + +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 *AzureBackupRecoveryPointResource +} + +// Get ... +func (c RecoveryPointClient) 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 + } + + var model AzureBackupRecoveryPointResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/method_list.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/method_list.go new file mode 100644 index 00000000000..87bc29f8d70 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/method_list.go @@ -0,0 +1,119 @@ +package recoverypoint + +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 *[]AzureBackupRecoveryPointResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AzureBackupRecoveryPointResource +} + +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 RecoveryPointClient) List(ctx context.Context, id BackupInstanceId, 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/recoveryPoints", 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 *[]AzureBackupRecoveryPointResource `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 RecoveryPointClient) ListComplete(ctx context.Context, id BackupInstanceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, AzureBackupRecoveryPointResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecoveryPointClient) ListCompleteMatchingPredicate(ctx context.Context, id BackupInstanceId, options ListOperationOptions, predicate AzureBackupRecoveryPointResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AzureBackupRecoveryPointResource, 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/dataprotection/2024-04-01/recoverypoint/model_azurebackupdiscreterecoverypoint.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackupdiscreterecoverypoint.go new file mode 100644 index 00000000000..ecc3e64361c --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackupdiscreterecoverypoint.go @@ -0,0 +1,51 @@ +package recoverypoint + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AzureBackupRecoveryPoint = AzureBackupDiscreteRecoveryPoint{} + +type AzureBackupDiscreteRecoveryPoint struct { + ExpiryTime *string `json:"expiryTime,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + PolicyVersion *string `json:"policyVersion,omitempty"` + RecoveryPointDataStoresDetails *[]RecoveryPointDataStoreDetails `json:"recoveryPointDataStoresDetails,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointState *RecoveryPointCompletionState `json:"recoveryPointState,omitempty"` + RecoveryPointTime string `json:"recoveryPointTime"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + RetentionTagName *string `json:"retentionTagName,omitempty"` + RetentionTagVersion *string `json:"retentionTagVersion,omitempty"` + + // Fields inherited from AzureBackupRecoveryPoint +} + +var _ json.Marshaler = AzureBackupDiscreteRecoveryPoint{} + +func (s AzureBackupDiscreteRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupDiscreteRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupDiscreteRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupDiscreteRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureBackupDiscreteRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupDiscreteRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypoint.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypoint.go new file mode 100644 index 00000000000..384f69a0f65 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypoint.go @@ -0,0 +1,53 @@ +package recoverypoint + +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 AzureBackupRecoveryPoint interface { +} + +// RawAzureBackupRecoveryPointImpl 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 RawAzureBackupRecoveryPointImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalAzureBackupRecoveryPointImplementation(input []byte) (AzureBackupRecoveryPoint, 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 AzureBackupRecoveryPoint into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupDiscreteRecoveryPoint") { + var out AzureBackupDiscreteRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupDiscreteRecoveryPoint: %+v", err) + } + return out, nil + } + + out := RawAzureBackupRecoveryPointImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypointresource.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypointresource.go new file mode 100644 index 00000000000..8f11d9bda9d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_azurebackuprecoverypointresource.go @@ -0,0 +1,48 @@ +package recoverypoint + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupRecoveryPointResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AzureBackupRecoveryPoint `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &AzureBackupRecoveryPointResource{} + +func (s *AzureBackupRecoveryPointResource) UnmarshalJSON(bytes []byte) error { + type alias AzureBackupRecoveryPointResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureBackupRecoveryPointResource: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureBackupRecoveryPointResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalAzureBackupRecoveryPointImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'AzureBackupRecoveryPointResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/model_recoverypointdatastoredetails.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_recoverypointdatastoredetails.go new file mode 100644 index 00000000000..0cde4767bde --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/model_recoverypointdatastoredetails.go @@ -0,0 +1,58 @@ +package recoverypoint + +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 RecoveryPointDataStoreDetails struct { + CreationTime *string `json:"creationTime,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Id *string `json:"id,omitempty"` + MetaData *string `json:"metaData,omitempty"` + RehydrationExpiryTime *string `json:"rehydrationExpiryTime,omitempty"` + RehydrationStatus *RehydrationStatus `json:"rehydrationStatus,omitempty"` + State *string `json:"state,omitempty"` + Type *string `json:"type,omitempty"` + Visible *bool `json:"visible,omitempty"` +} + +func (o *RecoveryPointDataStoreDetails) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointDataStoreDetails) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RecoveryPointDataStoreDetails) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointDataStoreDetails) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +func (o *RecoveryPointDataStoreDetails) GetRehydrationExpiryTimeAsTime() (*time.Time, error) { + if o.RehydrationExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RehydrationExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecoveryPointDataStoreDetails) SetRehydrationExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RehydrationExpiryTime = &formatted +} diff --git a/resource-manager/dataprotection/2024-04-01/recoverypoint/predicates.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/predicates.go new file mode 100644 index 00000000000..4c929e3a8cc --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/predicates.go @@ -0,0 +1,27 @@ +package recoverypoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBackupRecoveryPointResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AzureBackupRecoveryPointResourceOperationPredicate) Matches(input AzureBackupRecoveryPointResource) 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/dataprotection/2024-04-01/recoverypoint/version.go b/resource-manager/dataprotection/2024-04-01/recoverypoint/version.go new file mode 100644 index 00000000000..6dd0d8881d3 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/recoverypoint/version.go @@ -0,0 +1,12 @@ +package recoverypoint + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypoint/%s", defaultApiVersion) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/README.md b/resource-manager/dataprotection/2024-04-01/resourceguards/README.md new file mode 100644 index 00000000000..5e568680884 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/README.md @@ -0,0 +1,327 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/dataprotection/2024-04-01/resourceguards` Documentation + +The `resourceguards` SDK allows for interaction with the Azure Resource Manager Service `dataprotection` (API Version `2024-04-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/dataprotection/2024-04-01/resourceguards" +``` + + +### Client Initialization + +```go +client := resourceguards.NewResourceGuardsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceGuardsClient.Delete` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.Get` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +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: `ResourceGuardsClient.GetBackupSecurityPINRequestsObjects` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +// alternatively `client.GetBackupSecurityPINRequestsObjects(ctx, id)` can be used to do batched pagination +items, err := client.GetBackupSecurityPINRequestsObjectsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject` + +```go +ctx := context.TODO() +id := resourceguards.NewGetBackupSecurityPINRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "getBackupSecurityPINRequestValue") + +read, err := client.GetDefaultBackupSecurityPINRequestsObject(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject` + +```go +ctx := context.TODO() +id := resourceguards.NewDeleteProtectedItemRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "deleteProtectedItemRequestValue") + +read, err := client.GetDefaultDeleteProtectedItemRequestsObject(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject` + +```go +ctx := context.TODO() +id := resourceguards.NewDeleteResourceGuardProxyRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "deleteResourceGuardProxyRequestValue") + +read, err := client.GetDefaultDeleteResourceGuardProxyRequestsObject(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject` + +```go +ctx := context.TODO() +id := resourceguards.NewDisableSoftDeleteRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "disableSoftDeleteRequestValue") + +read, err := client.GetDefaultDisableSoftDeleteRequestsObject(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject` + +```go +ctx := context.TODO() +id := resourceguards.NewUpdateProtectedItemRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "updateProtectedItemRequestValue") + +read, err := client.GetDefaultUpdateProtectedItemRequestsObject(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject` + +```go +ctx := context.TODO() +id := resourceguards.NewUpdateProtectionPolicyRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "updateProtectionPolicyRequestValue") + +read, err := client.GetDefaultUpdateProtectionPolicyRequestsObject(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDeleteProtectedItemRequestsObjects` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +// alternatively `client.GetDeleteProtectedItemRequestsObjects(ctx, id)` can be used to do batched pagination +items, err := client.GetDeleteProtectedItemRequestsObjectsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDeleteResourceGuardProxyRequestsObjects` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +// alternatively `client.GetDeleteResourceGuardProxyRequestsObjects(ctx, id)` can be used to do batched pagination +items, err := client.GetDeleteResourceGuardProxyRequestsObjectsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.GetDisableSoftDeleteRequestsObjects` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +// alternatively `client.GetDisableSoftDeleteRequestsObjects(ctx, id)` can be used to do batched pagination +items, err := client.GetDisableSoftDeleteRequestsObjectsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.GetResourcesInResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.GetResourcesInResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.GetResourcesInResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.GetResourcesInSubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.GetResourcesInSubscription(ctx, id)` can be used to do batched pagination +items, err := client.GetResourcesInSubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.GetUpdateProtectedItemRequestsObjects` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +// alternatively `client.GetUpdateProtectedItemRequestsObjects(ctx, id)` can be used to do batched pagination +items, err := client.GetUpdateProtectedItemRequestsObjectsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.GetUpdateProtectionPolicyRequestsObjects` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +// alternatively `client.GetUpdateProtectionPolicyRequestsObjects(ctx, id)` can be used to do batched pagination +items, err := client.GetUpdateProtectionPolicyRequestsObjectsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceGuardsClient.Patch` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +payload := resourceguards.PatchResourceGuardInput{ + // ... +} + + +read, err := client.Patch(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardsClient.Put` + +```go +ctx := context.TODO() +id := resourceguards.NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + +payload := resourceguards.ResourceGuardResource{ + // ... +} + + +read, err := client.Put(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/client.go b/resource-manager/dataprotection/2024-04-01/resourceguards/client.go new file mode 100644 index 00000000000..2a79980112d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/client.go @@ -0,0 +1,26 @@ +package resourceguards + +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 ResourceGuardsClient struct { + Client *resourcemanager.Client +} + +func NewResourceGuardsClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceGuardsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "resourceguards", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceGuardsClient: %+v", err) + } + + return &ResourceGuardsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/constants.go b/resource-manager/dataprotection/2024-04-01/resourceguards/constants.go new file mode 100644 index 00000000000..883176c506a --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/constants.go @@ -0,0 +1,60 @@ +package resourceguards + +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 ProvisioningState string + +const ( + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest.go new file mode 100644 index 00000000000..797704c5a13 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest.go @@ -0,0 +1,139 @@ +package resourceguards + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeleteProtectedItemRequestId{}) +} + +var _ resourceids.ResourceId = &DeleteProtectedItemRequestId{} + +// DeleteProtectedItemRequestId is a struct representing the Resource ID for a Delete Protected Item Request +type DeleteProtectedItemRequestId struct { + SubscriptionId string + ResourceGroupName string + ResourceGuardName string + DeleteProtectedItemRequestName string +} + +// NewDeleteProtectedItemRequestID returns a new DeleteProtectedItemRequestId struct +func NewDeleteProtectedItemRequestID(subscriptionId string, resourceGroupName string, resourceGuardName string, deleteProtectedItemRequestName string) DeleteProtectedItemRequestId { + return DeleteProtectedItemRequestId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceGuardName: resourceGuardName, + DeleteProtectedItemRequestName: deleteProtectedItemRequestName, + } +} + +// ParseDeleteProtectedItemRequestID parses 'input' into a DeleteProtectedItemRequestId +func ParseDeleteProtectedItemRequestID(input string) (*DeleteProtectedItemRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteProtectedItemRequestId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteProtectedItemRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeleteProtectedItemRequestIDInsensitively parses 'input' case-insensitively into a DeleteProtectedItemRequestId +// note: this method should only be used for API response data and not user input +func ParseDeleteProtectedItemRequestIDInsensitively(input string) (*DeleteProtectedItemRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteProtectedItemRequestId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteProtectedItemRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeleteProtectedItemRequestId) 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.ResourceGuardName, ok = input.Parsed["resourceGuardName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGuardName", input) + } + + if id.DeleteProtectedItemRequestName, ok = input.Parsed["deleteProtectedItemRequestName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deleteProtectedItemRequestName", input) + } + + return nil +} + +// ValidateDeleteProtectedItemRequestID checks that 'input' can be parsed as a Delete Protected Item Request ID +func ValidateDeleteProtectedItemRequestID(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 := ParseDeleteProtectedItemRequestID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Delete Protected Item Request ID +func (id DeleteProtectedItemRequestId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/resourceGuards/%s/deleteProtectedItemRequests/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceGuardName, id.DeleteProtectedItemRequestName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Delete Protected Item Request ID +func (id DeleteProtectedItemRequestId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticResourceGuards", "resourceGuards", "resourceGuards"), + resourceids.UserSpecifiedSegment("resourceGuardName", "resourceGuardValue"), + resourceids.StaticSegment("staticDeleteProtectedItemRequests", "deleteProtectedItemRequests", "deleteProtectedItemRequests"), + resourceids.UserSpecifiedSegment("deleteProtectedItemRequestName", "deleteProtectedItemRequestValue"), + } +} + +// String returns a human-readable description of this Delete Protected Item Request ID +func (id DeleteProtectedItemRequestId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Guard Name: %q", id.ResourceGuardName), + fmt.Sprintf("Delete Protected Item Request Name: %q", id.DeleteProtectedItemRequestName), + } + return fmt.Sprintf("Delete Protected Item Request (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest_test.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest_test.go new file mode 100644 index 00000000000..0304976abd2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteprotecteditemrequest_test.go @@ -0,0 +1,327 @@ +package resourceguards + +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 = &DeleteProtectedItemRequestId{} + +func TestNewDeleteProtectedItemRequestID(t *testing.T) { + id := NewDeleteProtectedItemRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "deleteProtectedItemRequestValue") + + 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.ResourceGuardName != "resourceGuardValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGuardName'", id.ResourceGuardName, "resourceGuardValue") + } + + if id.DeleteProtectedItemRequestName != "deleteProtectedItemRequestValue" { + t.Fatalf("Expected %q but got %q for Segment 'DeleteProtectedItemRequestName'", id.DeleteProtectedItemRequestName, "deleteProtectedItemRequestValue") + } +} + +func TestFormatDeleteProtectedItemRequestID(t *testing.T) { + actual := NewDeleteProtectedItemRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "deleteProtectedItemRequestValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteProtectedItemRequests/deleteProtectedItemRequestValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeleteProtectedItemRequestID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteProtectedItemRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteProtectedItemRequests", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteProtectedItemRequests/deleteProtectedItemRequestValue", + Expected: &DeleteProtectedItemRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + DeleteProtectedItemRequestName: "deleteProtectedItemRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteProtectedItemRequests/deleteProtectedItemRequestValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteProtectedItemRequestID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.DeleteProtectedItemRequestName != v.Expected.DeleteProtectedItemRequestName { + t.Fatalf("Expected %q but got %q for DeleteProtectedItemRequestName", v.Expected.DeleteProtectedItemRequestName, actual.DeleteProtectedItemRequestName) + } + + } +} + +func TestParseDeleteProtectedItemRequestIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteProtectedItemRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteProtectedItemRequests", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dElEtEpRoTeCtEdItEmReQuEsTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteProtectedItemRequests/deleteProtectedItemRequestValue", + Expected: &DeleteProtectedItemRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + DeleteProtectedItemRequestName: "deleteProtectedItemRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteProtectedItemRequests/deleteProtectedItemRequestValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dElEtEpRoTeCtEdItEmReQuEsTs/dElEtEpRoTeCtEdItEmReQuEsTvAlUe", + Expected: &DeleteProtectedItemRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceGuardName: "rEsOuRcEgUaRdVaLuE", + DeleteProtectedItemRequestName: "dElEtEpRoTeCtEdItEmReQuEsTvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dElEtEpRoTeCtEdItEmReQuEsTs/dElEtEpRoTeCtEdItEmReQuEsTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteProtectedItemRequestIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.DeleteProtectedItemRequestName != v.Expected.DeleteProtectedItemRequestName { + t.Fatalf("Expected %q but got %q for DeleteProtectedItemRequestName", v.Expected.DeleteProtectedItemRequestName, actual.DeleteProtectedItemRequestName) + } + + } +} + +func TestSegmentsForDeleteProtectedItemRequestId(t *testing.T) { + segments := DeleteProtectedItemRequestId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeleteProtectedItemRequestId 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/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest.go new file mode 100644 index 00000000000..698fd773b09 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest.go @@ -0,0 +1,139 @@ +package resourceguards + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeleteResourceGuardProxyRequestId{}) +} + +var _ resourceids.ResourceId = &DeleteResourceGuardProxyRequestId{} + +// DeleteResourceGuardProxyRequestId is a struct representing the Resource ID for a Delete Resource Guard Proxy Request +type DeleteResourceGuardProxyRequestId struct { + SubscriptionId string + ResourceGroupName string + ResourceGuardName string + DeleteResourceGuardProxyRequestName string +} + +// NewDeleteResourceGuardProxyRequestID returns a new DeleteResourceGuardProxyRequestId struct +func NewDeleteResourceGuardProxyRequestID(subscriptionId string, resourceGroupName string, resourceGuardName string, deleteResourceGuardProxyRequestName string) DeleteResourceGuardProxyRequestId { + return DeleteResourceGuardProxyRequestId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceGuardName: resourceGuardName, + DeleteResourceGuardProxyRequestName: deleteResourceGuardProxyRequestName, + } +} + +// ParseDeleteResourceGuardProxyRequestID parses 'input' into a DeleteResourceGuardProxyRequestId +func ParseDeleteResourceGuardProxyRequestID(input string) (*DeleteResourceGuardProxyRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteResourceGuardProxyRequestId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteResourceGuardProxyRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeleteResourceGuardProxyRequestIDInsensitively parses 'input' case-insensitively into a DeleteResourceGuardProxyRequestId +// note: this method should only be used for API response data and not user input +func ParseDeleteResourceGuardProxyRequestIDInsensitively(input string) (*DeleteResourceGuardProxyRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeleteResourceGuardProxyRequestId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeleteResourceGuardProxyRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeleteResourceGuardProxyRequestId) 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.ResourceGuardName, ok = input.Parsed["resourceGuardName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGuardName", input) + } + + if id.DeleteResourceGuardProxyRequestName, ok = input.Parsed["deleteResourceGuardProxyRequestName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deleteResourceGuardProxyRequestName", input) + } + + return nil +} + +// ValidateDeleteResourceGuardProxyRequestID checks that 'input' can be parsed as a Delete Resource Guard Proxy Request ID +func ValidateDeleteResourceGuardProxyRequestID(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 := ParseDeleteResourceGuardProxyRequestID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Delete Resource Guard Proxy Request ID +func (id DeleteResourceGuardProxyRequestId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/resourceGuards/%s/deleteResourceGuardProxyRequests/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceGuardName, id.DeleteResourceGuardProxyRequestName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Delete Resource Guard Proxy Request ID +func (id DeleteResourceGuardProxyRequestId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticResourceGuards", "resourceGuards", "resourceGuards"), + resourceids.UserSpecifiedSegment("resourceGuardName", "resourceGuardValue"), + resourceids.StaticSegment("staticDeleteResourceGuardProxyRequests", "deleteResourceGuardProxyRequests", "deleteResourceGuardProxyRequests"), + resourceids.UserSpecifiedSegment("deleteResourceGuardProxyRequestName", "deleteResourceGuardProxyRequestValue"), + } +} + +// String returns a human-readable description of this Delete Resource Guard Proxy Request ID +func (id DeleteResourceGuardProxyRequestId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Guard Name: %q", id.ResourceGuardName), + fmt.Sprintf("Delete Resource Guard Proxy Request Name: %q", id.DeleteResourceGuardProxyRequestName), + } + return fmt.Sprintf("Delete Resource Guard Proxy Request (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest_test.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest_test.go new file mode 100644 index 00000000000..21fb07712b5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_deleteresourceguardproxyrequest_test.go @@ -0,0 +1,327 @@ +package resourceguards + +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 = &DeleteResourceGuardProxyRequestId{} + +func TestNewDeleteResourceGuardProxyRequestID(t *testing.T) { + id := NewDeleteResourceGuardProxyRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "deleteResourceGuardProxyRequestValue") + + 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.ResourceGuardName != "resourceGuardValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGuardName'", id.ResourceGuardName, "resourceGuardValue") + } + + if id.DeleteResourceGuardProxyRequestName != "deleteResourceGuardProxyRequestValue" { + t.Fatalf("Expected %q but got %q for Segment 'DeleteResourceGuardProxyRequestName'", id.DeleteResourceGuardProxyRequestName, "deleteResourceGuardProxyRequestValue") + } +} + +func TestFormatDeleteResourceGuardProxyRequestID(t *testing.T) { + actual := NewDeleteResourceGuardProxyRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "deleteResourceGuardProxyRequestValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteResourceGuardProxyRequests/deleteResourceGuardProxyRequestValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeleteResourceGuardProxyRequestID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteResourceGuardProxyRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteResourceGuardProxyRequests", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteResourceGuardProxyRequests/deleteResourceGuardProxyRequestValue", + Expected: &DeleteResourceGuardProxyRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + DeleteResourceGuardProxyRequestName: "deleteResourceGuardProxyRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteResourceGuardProxyRequests/deleteResourceGuardProxyRequestValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteResourceGuardProxyRequestID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.DeleteResourceGuardProxyRequestName != v.Expected.DeleteResourceGuardProxyRequestName { + t.Fatalf("Expected %q but got %q for DeleteResourceGuardProxyRequestName", v.Expected.DeleteResourceGuardProxyRequestName, actual.DeleteResourceGuardProxyRequestName) + } + + } +} + +func TestParseDeleteResourceGuardProxyRequestIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeleteResourceGuardProxyRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteResourceGuardProxyRequests", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dElEtErEsOuRcEgUaRdPrOxYrEqUeStS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteResourceGuardProxyRequests/deleteResourceGuardProxyRequestValue", + Expected: &DeleteResourceGuardProxyRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + DeleteResourceGuardProxyRequestName: "deleteResourceGuardProxyRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/deleteResourceGuardProxyRequests/deleteResourceGuardProxyRequestValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dElEtErEsOuRcEgUaRdPrOxYrEqUeStS/dElEtErEsOuRcEgUaRdPrOxYrEqUeStVaLuE", + Expected: &DeleteResourceGuardProxyRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceGuardName: "rEsOuRcEgUaRdVaLuE", + DeleteResourceGuardProxyRequestName: "dElEtErEsOuRcEgUaRdPrOxYrEqUeStVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dElEtErEsOuRcEgUaRdPrOxYrEqUeStS/dElEtErEsOuRcEgUaRdPrOxYrEqUeStVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeleteResourceGuardProxyRequestIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.DeleteResourceGuardProxyRequestName != v.Expected.DeleteResourceGuardProxyRequestName { + t.Fatalf("Expected %q but got %q for DeleteResourceGuardProxyRequestName", v.Expected.DeleteResourceGuardProxyRequestName, actual.DeleteResourceGuardProxyRequestName) + } + + } +} + +func TestSegmentsForDeleteResourceGuardProxyRequestId(t *testing.T) { + segments := DeleteResourceGuardProxyRequestId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeleteResourceGuardProxyRequestId 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/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest.go new file mode 100644 index 00000000000..a4a28e2d325 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest.go @@ -0,0 +1,139 @@ +package resourceguards + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DisableSoftDeleteRequestId{}) +} + +var _ resourceids.ResourceId = &DisableSoftDeleteRequestId{} + +// DisableSoftDeleteRequestId is a struct representing the Resource ID for a Disable Soft Delete Request +type DisableSoftDeleteRequestId struct { + SubscriptionId string + ResourceGroupName string + ResourceGuardName string + DisableSoftDeleteRequestName string +} + +// NewDisableSoftDeleteRequestID returns a new DisableSoftDeleteRequestId struct +func NewDisableSoftDeleteRequestID(subscriptionId string, resourceGroupName string, resourceGuardName string, disableSoftDeleteRequestName string) DisableSoftDeleteRequestId { + return DisableSoftDeleteRequestId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceGuardName: resourceGuardName, + DisableSoftDeleteRequestName: disableSoftDeleteRequestName, + } +} + +// ParseDisableSoftDeleteRequestID parses 'input' into a DisableSoftDeleteRequestId +func ParseDisableSoftDeleteRequestID(input string) (*DisableSoftDeleteRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&DisableSoftDeleteRequestId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DisableSoftDeleteRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDisableSoftDeleteRequestIDInsensitively parses 'input' case-insensitively into a DisableSoftDeleteRequestId +// note: this method should only be used for API response data and not user input +func ParseDisableSoftDeleteRequestIDInsensitively(input string) (*DisableSoftDeleteRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&DisableSoftDeleteRequestId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DisableSoftDeleteRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DisableSoftDeleteRequestId) 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.ResourceGuardName, ok = input.Parsed["resourceGuardName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGuardName", input) + } + + if id.DisableSoftDeleteRequestName, ok = input.Parsed["disableSoftDeleteRequestName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "disableSoftDeleteRequestName", input) + } + + return nil +} + +// ValidateDisableSoftDeleteRequestID checks that 'input' can be parsed as a Disable Soft Delete Request ID +func ValidateDisableSoftDeleteRequestID(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 := ParseDisableSoftDeleteRequestID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Disable Soft Delete Request ID +func (id DisableSoftDeleteRequestId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/resourceGuards/%s/disableSoftDeleteRequests/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceGuardName, id.DisableSoftDeleteRequestName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Disable Soft Delete Request ID +func (id DisableSoftDeleteRequestId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticResourceGuards", "resourceGuards", "resourceGuards"), + resourceids.UserSpecifiedSegment("resourceGuardName", "resourceGuardValue"), + resourceids.StaticSegment("staticDisableSoftDeleteRequests", "disableSoftDeleteRequests", "disableSoftDeleteRequests"), + resourceids.UserSpecifiedSegment("disableSoftDeleteRequestName", "disableSoftDeleteRequestValue"), + } +} + +// String returns a human-readable description of this Disable Soft Delete Request ID +func (id DisableSoftDeleteRequestId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Guard Name: %q", id.ResourceGuardName), + fmt.Sprintf("Disable Soft Delete Request Name: %q", id.DisableSoftDeleteRequestName), + } + return fmt.Sprintf("Disable Soft Delete Request (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest_test.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest_test.go new file mode 100644 index 00000000000..731851ec1aa --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_disablesoftdeleterequest_test.go @@ -0,0 +1,327 @@ +package resourceguards + +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 = &DisableSoftDeleteRequestId{} + +func TestNewDisableSoftDeleteRequestID(t *testing.T) { + id := NewDisableSoftDeleteRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "disableSoftDeleteRequestValue") + + 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.ResourceGuardName != "resourceGuardValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGuardName'", id.ResourceGuardName, "resourceGuardValue") + } + + if id.DisableSoftDeleteRequestName != "disableSoftDeleteRequestValue" { + t.Fatalf("Expected %q but got %q for Segment 'DisableSoftDeleteRequestName'", id.DisableSoftDeleteRequestName, "disableSoftDeleteRequestValue") + } +} + +func TestFormatDisableSoftDeleteRequestID(t *testing.T) { + actual := NewDisableSoftDeleteRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "disableSoftDeleteRequestValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/disableSoftDeleteRequests/disableSoftDeleteRequestValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDisableSoftDeleteRequestID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DisableSoftDeleteRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/disableSoftDeleteRequests", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/disableSoftDeleteRequests/disableSoftDeleteRequestValue", + Expected: &DisableSoftDeleteRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + DisableSoftDeleteRequestName: "disableSoftDeleteRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/disableSoftDeleteRequests/disableSoftDeleteRequestValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDisableSoftDeleteRequestID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.DisableSoftDeleteRequestName != v.Expected.DisableSoftDeleteRequestName { + t.Fatalf("Expected %q but got %q for DisableSoftDeleteRequestName", v.Expected.DisableSoftDeleteRequestName, actual.DisableSoftDeleteRequestName) + } + + } +} + +func TestParseDisableSoftDeleteRequestIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DisableSoftDeleteRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/disableSoftDeleteRequests", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dIsAbLeSoFtDeLeTeReQuEsTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/disableSoftDeleteRequests/disableSoftDeleteRequestValue", + Expected: &DisableSoftDeleteRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + DisableSoftDeleteRequestName: "disableSoftDeleteRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/disableSoftDeleteRequests/disableSoftDeleteRequestValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dIsAbLeSoFtDeLeTeReQuEsTs/dIsAbLeSoFtDeLeTeReQuEsTvAlUe", + Expected: &DisableSoftDeleteRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceGuardName: "rEsOuRcEgUaRdVaLuE", + DisableSoftDeleteRequestName: "dIsAbLeSoFtDeLeTeReQuEsTvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/dIsAbLeSoFtDeLeTeReQuEsTs/dIsAbLeSoFtDeLeTeReQuEsTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDisableSoftDeleteRequestIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.DisableSoftDeleteRequestName != v.Expected.DisableSoftDeleteRequestName { + t.Fatalf("Expected %q but got %q for DisableSoftDeleteRequestName", v.Expected.DisableSoftDeleteRequestName, actual.DisableSoftDeleteRequestName) + } + + } +} + +func TestSegmentsForDisableSoftDeleteRequestId(t *testing.T) { + segments := DisableSoftDeleteRequestId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DisableSoftDeleteRequestId 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/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest.go new file mode 100644 index 00000000000..9975ae3fc13 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest.go @@ -0,0 +1,139 @@ +package resourceguards + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&GetBackupSecurityPINRequestId{}) +} + +var _ resourceids.ResourceId = &GetBackupSecurityPINRequestId{} + +// GetBackupSecurityPINRequestId is a struct representing the Resource ID for a Get Backup Security P I N Request +type GetBackupSecurityPINRequestId struct { + SubscriptionId string + ResourceGroupName string + ResourceGuardName string + GetBackupSecurityPINRequestName string +} + +// NewGetBackupSecurityPINRequestID returns a new GetBackupSecurityPINRequestId struct +func NewGetBackupSecurityPINRequestID(subscriptionId string, resourceGroupName string, resourceGuardName string, getBackupSecurityPINRequestName string) GetBackupSecurityPINRequestId { + return GetBackupSecurityPINRequestId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceGuardName: resourceGuardName, + GetBackupSecurityPINRequestName: getBackupSecurityPINRequestName, + } +} + +// ParseGetBackupSecurityPINRequestID parses 'input' into a GetBackupSecurityPINRequestId +func ParseGetBackupSecurityPINRequestID(input string) (*GetBackupSecurityPINRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&GetBackupSecurityPINRequestId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GetBackupSecurityPINRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGetBackupSecurityPINRequestIDInsensitively parses 'input' case-insensitively into a GetBackupSecurityPINRequestId +// note: this method should only be used for API response data and not user input +func ParseGetBackupSecurityPINRequestIDInsensitively(input string) (*GetBackupSecurityPINRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&GetBackupSecurityPINRequestId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GetBackupSecurityPINRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GetBackupSecurityPINRequestId) 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.ResourceGuardName, ok = input.Parsed["resourceGuardName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGuardName", input) + } + + if id.GetBackupSecurityPINRequestName, ok = input.Parsed["getBackupSecurityPINRequestName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "getBackupSecurityPINRequestName", input) + } + + return nil +} + +// ValidateGetBackupSecurityPINRequestID checks that 'input' can be parsed as a Get Backup Security P I N Request ID +func ValidateGetBackupSecurityPINRequestID(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 := ParseGetBackupSecurityPINRequestID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Get Backup Security P I N Request ID +func (id GetBackupSecurityPINRequestId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/resourceGuards/%s/getBackupSecurityPINRequests/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceGuardName, id.GetBackupSecurityPINRequestName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Get Backup Security P I N Request ID +func (id GetBackupSecurityPINRequestId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticResourceGuards", "resourceGuards", "resourceGuards"), + resourceids.UserSpecifiedSegment("resourceGuardName", "resourceGuardValue"), + resourceids.StaticSegment("staticGetBackupSecurityPINRequests", "getBackupSecurityPINRequests", "getBackupSecurityPINRequests"), + resourceids.UserSpecifiedSegment("getBackupSecurityPINRequestName", "getBackupSecurityPINRequestValue"), + } +} + +// String returns a human-readable description of this Get Backup Security P I N Request ID +func (id GetBackupSecurityPINRequestId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Guard Name: %q", id.ResourceGuardName), + fmt.Sprintf("Get Backup Security P I N Request Name: %q", id.GetBackupSecurityPINRequestName), + } + return fmt.Sprintf("Get Backup Security P I N Request (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest_test.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest_test.go new file mode 100644 index 00000000000..590c38bdf9b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_getbackupsecuritypinrequest_test.go @@ -0,0 +1,327 @@ +package resourceguards + +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 = &GetBackupSecurityPINRequestId{} + +func TestNewGetBackupSecurityPINRequestID(t *testing.T) { + id := NewGetBackupSecurityPINRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "getBackupSecurityPINRequestValue") + + 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.ResourceGuardName != "resourceGuardValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGuardName'", id.ResourceGuardName, "resourceGuardValue") + } + + if id.GetBackupSecurityPINRequestName != "getBackupSecurityPINRequestValue" { + t.Fatalf("Expected %q but got %q for Segment 'GetBackupSecurityPINRequestName'", id.GetBackupSecurityPINRequestName, "getBackupSecurityPINRequestValue") + } +} + +func TestFormatGetBackupSecurityPINRequestID(t *testing.T) { + actual := NewGetBackupSecurityPINRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "getBackupSecurityPINRequestValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/getBackupSecurityPINRequests/getBackupSecurityPINRequestValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGetBackupSecurityPINRequestID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GetBackupSecurityPINRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/getBackupSecurityPINRequests", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/getBackupSecurityPINRequests/getBackupSecurityPINRequestValue", + Expected: &GetBackupSecurityPINRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + GetBackupSecurityPINRequestName: "getBackupSecurityPINRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/getBackupSecurityPINRequests/getBackupSecurityPINRequestValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGetBackupSecurityPINRequestID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.GetBackupSecurityPINRequestName != v.Expected.GetBackupSecurityPINRequestName { + t.Fatalf("Expected %q but got %q for GetBackupSecurityPINRequestName", v.Expected.GetBackupSecurityPINRequestName, actual.GetBackupSecurityPINRequestName) + } + + } +} + +func TestParseGetBackupSecurityPINRequestIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GetBackupSecurityPINRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/getBackupSecurityPINRequests", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/gEtBaCkUpSeCuRiTyPiNrEqUeStS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/getBackupSecurityPINRequests/getBackupSecurityPINRequestValue", + Expected: &GetBackupSecurityPINRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + GetBackupSecurityPINRequestName: "getBackupSecurityPINRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/getBackupSecurityPINRequests/getBackupSecurityPINRequestValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/gEtBaCkUpSeCuRiTyPiNrEqUeStS/gEtBaCkUpSeCuRiTyPiNrEqUeStVaLuE", + Expected: &GetBackupSecurityPINRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceGuardName: "rEsOuRcEgUaRdVaLuE", + GetBackupSecurityPINRequestName: "gEtBaCkUpSeCuRiTyPiNrEqUeStVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/gEtBaCkUpSeCuRiTyPiNrEqUeStS/gEtBaCkUpSeCuRiTyPiNrEqUeStVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGetBackupSecurityPINRequestIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.GetBackupSecurityPINRequestName != v.Expected.GetBackupSecurityPINRequestName { + t.Fatalf("Expected %q but got %q for GetBackupSecurityPINRequestName", v.Expected.GetBackupSecurityPINRequestName, actual.GetBackupSecurityPINRequestName) + } + + } +} + +func TestSegmentsForGetBackupSecurityPINRequestId(t *testing.T) { + segments := GetBackupSecurityPINRequestId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GetBackupSecurityPINRequestId 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/dataprotection/2024-04-01/resourceguards/id_resourceguard.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_resourceguard.go new file mode 100644 index 00000000000..db774ade737 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_resourceguard.go @@ -0,0 +1,130 @@ +package resourceguards + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ResourceGuardId{}) +} + +var _ resourceids.ResourceId = &ResourceGuardId{} + +// ResourceGuardId is a struct representing the Resource ID for a Resource Guard +type ResourceGuardId struct { + SubscriptionId string + ResourceGroupName string + ResourceGuardName string +} + +// NewResourceGuardID returns a new ResourceGuardId struct +func NewResourceGuardID(subscriptionId string, resourceGroupName string, resourceGuardName string) ResourceGuardId { + return ResourceGuardId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceGuardName: resourceGuardName, + } +} + +// ParseResourceGuardID parses 'input' into a ResourceGuardId +func ParseResourceGuardID(input string) (*ResourceGuardId, error) { + parser := resourceids.NewParserFromResourceIdType(&ResourceGuardId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ResourceGuardId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseResourceGuardIDInsensitively parses 'input' case-insensitively into a ResourceGuardId +// note: this method should only be used for API response data and not user input +func ParseResourceGuardIDInsensitively(input string) (*ResourceGuardId, error) { + parser := resourceids.NewParserFromResourceIdType(&ResourceGuardId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ResourceGuardId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ResourceGuardId) 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.ResourceGuardName, ok = input.Parsed["resourceGuardName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGuardName", input) + } + + return nil +} + +// ValidateResourceGuardID checks that 'input' can be parsed as a Resource Guard ID +func ValidateResourceGuardID(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 := ParseResourceGuardID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Resource Guard ID +func (id ResourceGuardId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/resourceGuards/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceGuardName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Resource Guard ID +func (id ResourceGuardId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticResourceGuards", "resourceGuards", "resourceGuards"), + resourceids.UserSpecifiedSegment("resourceGuardName", "resourceGuardValue"), + } +} + +// String returns a human-readable description of this Resource Guard ID +func (id ResourceGuardId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Guard Name: %q", id.ResourceGuardName), + } + return fmt.Sprintf("Resource Guard (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_resourceguard_test.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_resourceguard_test.go new file mode 100644 index 00000000000..e4985431a93 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_resourceguard_test.go @@ -0,0 +1,282 @@ +package resourceguards + +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 = &ResourceGuardId{} + +func TestNewResourceGuardID(t *testing.T) { + id := NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue") + + 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.ResourceGuardName != "resourceGuardValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGuardName'", id.ResourceGuardName, "resourceGuardValue") + } +} + +func TestFormatResourceGuardID(t *testing.T) { + actual := NewResourceGuardID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseResourceGuardID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ResourceGuardId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Expected: &ResourceGuardId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseResourceGuardID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + } +} + +func TestParseResourceGuardIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ResourceGuardId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Expected: &ResourceGuardId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE", + Expected: &ResourceGuardId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceGuardName: "rEsOuRcEgUaRdVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseResourceGuardIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + } +} + +func TestSegmentsForResourceGuardId(t *testing.T) { + segments := ResourceGuardId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ResourceGuardId 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/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest.go new file mode 100644 index 00000000000..b49508843a6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest.go @@ -0,0 +1,139 @@ +package resourceguards + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UpdateProtectedItemRequestId{}) +} + +var _ resourceids.ResourceId = &UpdateProtectedItemRequestId{} + +// UpdateProtectedItemRequestId is a struct representing the Resource ID for a Update Protected Item Request +type UpdateProtectedItemRequestId struct { + SubscriptionId string + ResourceGroupName string + ResourceGuardName string + UpdateProtectedItemRequestName string +} + +// NewUpdateProtectedItemRequestID returns a new UpdateProtectedItemRequestId struct +func NewUpdateProtectedItemRequestID(subscriptionId string, resourceGroupName string, resourceGuardName string, updateProtectedItemRequestName string) UpdateProtectedItemRequestId { + return UpdateProtectedItemRequestId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceGuardName: resourceGuardName, + UpdateProtectedItemRequestName: updateProtectedItemRequestName, + } +} + +// ParseUpdateProtectedItemRequestID parses 'input' into a UpdateProtectedItemRequestId +func ParseUpdateProtectedItemRequestID(input string) (*UpdateProtectedItemRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&UpdateProtectedItemRequestId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UpdateProtectedItemRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUpdateProtectedItemRequestIDInsensitively parses 'input' case-insensitively into a UpdateProtectedItemRequestId +// note: this method should only be used for API response data and not user input +func ParseUpdateProtectedItemRequestIDInsensitively(input string) (*UpdateProtectedItemRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&UpdateProtectedItemRequestId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UpdateProtectedItemRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UpdateProtectedItemRequestId) 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.ResourceGuardName, ok = input.Parsed["resourceGuardName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGuardName", input) + } + + if id.UpdateProtectedItemRequestName, ok = input.Parsed["updateProtectedItemRequestName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "updateProtectedItemRequestName", input) + } + + return nil +} + +// ValidateUpdateProtectedItemRequestID checks that 'input' can be parsed as a Update Protected Item Request ID +func ValidateUpdateProtectedItemRequestID(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 := ParseUpdateProtectedItemRequestID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Update Protected Item Request ID +func (id UpdateProtectedItemRequestId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/resourceGuards/%s/updateProtectedItemRequests/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceGuardName, id.UpdateProtectedItemRequestName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Update Protected Item Request ID +func (id UpdateProtectedItemRequestId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticResourceGuards", "resourceGuards", "resourceGuards"), + resourceids.UserSpecifiedSegment("resourceGuardName", "resourceGuardValue"), + resourceids.StaticSegment("staticUpdateProtectedItemRequests", "updateProtectedItemRequests", "updateProtectedItemRequests"), + resourceids.UserSpecifiedSegment("updateProtectedItemRequestName", "updateProtectedItemRequestValue"), + } +} + +// String returns a human-readable description of this Update Protected Item Request ID +func (id UpdateProtectedItemRequestId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Guard Name: %q", id.ResourceGuardName), + fmt.Sprintf("Update Protected Item Request Name: %q", id.UpdateProtectedItemRequestName), + } + return fmt.Sprintf("Update Protected Item Request (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest_test.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest_test.go new file mode 100644 index 00000000000..840a3c1bec7 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotecteditemrequest_test.go @@ -0,0 +1,327 @@ +package resourceguards + +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 = &UpdateProtectedItemRequestId{} + +func TestNewUpdateProtectedItemRequestID(t *testing.T) { + id := NewUpdateProtectedItemRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "updateProtectedItemRequestValue") + + 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.ResourceGuardName != "resourceGuardValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGuardName'", id.ResourceGuardName, "resourceGuardValue") + } + + if id.UpdateProtectedItemRequestName != "updateProtectedItemRequestValue" { + t.Fatalf("Expected %q but got %q for Segment 'UpdateProtectedItemRequestName'", id.UpdateProtectedItemRequestName, "updateProtectedItemRequestValue") + } +} + +func TestFormatUpdateProtectedItemRequestID(t *testing.T) { + actual := NewUpdateProtectedItemRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "updateProtectedItemRequestValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectedItemRequests/updateProtectedItemRequestValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUpdateProtectedItemRequestID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UpdateProtectedItemRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectedItemRequests", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectedItemRequests/updateProtectedItemRequestValue", + Expected: &UpdateProtectedItemRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + UpdateProtectedItemRequestName: "updateProtectedItemRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectedItemRequests/updateProtectedItemRequestValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUpdateProtectedItemRequestID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.UpdateProtectedItemRequestName != v.Expected.UpdateProtectedItemRequestName { + t.Fatalf("Expected %q but got %q for UpdateProtectedItemRequestName", v.Expected.UpdateProtectedItemRequestName, actual.UpdateProtectedItemRequestName) + } + + } +} + +func TestParseUpdateProtectedItemRequestIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UpdateProtectedItemRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectedItemRequests", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/uPdAtEpRoTeCtEdItEmReQuEsTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectedItemRequests/updateProtectedItemRequestValue", + Expected: &UpdateProtectedItemRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + UpdateProtectedItemRequestName: "updateProtectedItemRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectedItemRequests/updateProtectedItemRequestValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/uPdAtEpRoTeCtEdItEmReQuEsTs/uPdAtEpRoTeCtEdItEmReQuEsTvAlUe", + Expected: &UpdateProtectedItemRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceGuardName: "rEsOuRcEgUaRdVaLuE", + UpdateProtectedItemRequestName: "uPdAtEpRoTeCtEdItEmReQuEsTvAlUe", + }, + }, + { + // 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.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/uPdAtEpRoTeCtEdItEmReQuEsTs/uPdAtEpRoTeCtEdItEmReQuEsTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUpdateProtectedItemRequestIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.UpdateProtectedItemRequestName != v.Expected.UpdateProtectedItemRequestName { + t.Fatalf("Expected %q but got %q for UpdateProtectedItemRequestName", v.Expected.UpdateProtectedItemRequestName, actual.UpdateProtectedItemRequestName) + } + + } +} + +func TestSegmentsForUpdateProtectedItemRequestId(t *testing.T) { + segments := UpdateProtectedItemRequestId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UpdateProtectedItemRequestId 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/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest.go new file mode 100644 index 00000000000..d1a6daf9f64 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest.go @@ -0,0 +1,139 @@ +package resourceguards + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UpdateProtectionPolicyRequestId{}) +} + +var _ resourceids.ResourceId = &UpdateProtectionPolicyRequestId{} + +// UpdateProtectionPolicyRequestId is a struct representing the Resource ID for a Update Protection Policy Request +type UpdateProtectionPolicyRequestId struct { + SubscriptionId string + ResourceGroupName string + ResourceGuardName string + UpdateProtectionPolicyRequestName string +} + +// NewUpdateProtectionPolicyRequestID returns a new UpdateProtectionPolicyRequestId struct +func NewUpdateProtectionPolicyRequestID(subscriptionId string, resourceGroupName string, resourceGuardName string, updateProtectionPolicyRequestName string) UpdateProtectionPolicyRequestId { + return UpdateProtectionPolicyRequestId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceGuardName: resourceGuardName, + UpdateProtectionPolicyRequestName: updateProtectionPolicyRequestName, + } +} + +// ParseUpdateProtectionPolicyRequestID parses 'input' into a UpdateProtectionPolicyRequestId +func ParseUpdateProtectionPolicyRequestID(input string) (*UpdateProtectionPolicyRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&UpdateProtectionPolicyRequestId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UpdateProtectionPolicyRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUpdateProtectionPolicyRequestIDInsensitively parses 'input' case-insensitively into a UpdateProtectionPolicyRequestId +// note: this method should only be used for API response data and not user input +func ParseUpdateProtectionPolicyRequestIDInsensitively(input string) (*UpdateProtectionPolicyRequestId, error) { + parser := resourceids.NewParserFromResourceIdType(&UpdateProtectionPolicyRequestId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UpdateProtectionPolicyRequestId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UpdateProtectionPolicyRequestId) 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.ResourceGuardName, ok = input.Parsed["resourceGuardName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGuardName", input) + } + + if id.UpdateProtectionPolicyRequestName, ok = input.Parsed["updateProtectionPolicyRequestName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "updateProtectionPolicyRequestName", input) + } + + return nil +} + +// ValidateUpdateProtectionPolicyRequestID checks that 'input' can be parsed as a Update Protection Policy Request ID +func ValidateUpdateProtectionPolicyRequestID(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 := ParseUpdateProtectionPolicyRequestID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Update Protection Policy Request ID +func (id UpdateProtectionPolicyRequestId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DataProtection/resourceGuards/%s/updateProtectionPolicyRequests/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceGuardName, id.UpdateProtectionPolicyRequestName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Update Protection Policy Request ID +func (id UpdateProtectionPolicyRequestId) 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("staticMicrosoftDataProtection", "Microsoft.DataProtection", "Microsoft.DataProtection"), + resourceids.StaticSegment("staticResourceGuards", "resourceGuards", "resourceGuards"), + resourceids.UserSpecifiedSegment("resourceGuardName", "resourceGuardValue"), + resourceids.StaticSegment("staticUpdateProtectionPolicyRequests", "updateProtectionPolicyRequests", "updateProtectionPolicyRequests"), + resourceids.UserSpecifiedSegment("updateProtectionPolicyRequestName", "updateProtectionPolicyRequestValue"), + } +} + +// String returns a human-readable description of this Update Protection Policy Request ID +func (id UpdateProtectionPolicyRequestId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Guard Name: %q", id.ResourceGuardName), + fmt.Sprintf("Update Protection Policy Request Name: %q", id.UpdateProtectionPolicyRequestName), + } + return fmt.Sprintf("Update Protection Policy Request (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest_test.go b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest_test.go new file mode 100644 index 00000000000..3a6d71980ee --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/id_updateprotectionpolicyrequest_test.go @@ -0,0 +1,327 @@ +package resourceguards + +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 = &UpdateProtectionPolicyRequestId{} + +func TestNewUpdateProtectionPolicyRequestID(t *testing.T) { + id := NewUpdateProtectionPolicyRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "updateProtectionPolicyRequestValue") + + 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.ResourceGuardName != "resourceGuardValue" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGuardName'", id.ResourceGuardName, "resourceGuardValue") + } + + if id.UpdateProtectionPolicyRequestName != "updateProtectionPolicyRequestValue" { + t.Fatalf("Expected %q but got %q for Segment 'UpdateProtectionPolicyRequestName'", id.UpdateProtectionPolicyRequestName, "updateProtectionPolicyRequestValue") + } +} + +func TestFormatUpdateProtectionPolicyRequestID(t *testing.T) { + actual := NewUpdateProtectionPolicyRequestID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceGuardValue", "updateProtectionPolicyRequestValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectionPolicyRequests/updateProtectionPolicyRequestValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUpdateProtectionPolicyRequestID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UpdateProtectionPolicyRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectionPolicyRequests", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectionPolicyRequests/updateProtectionPolicyRequestValue", + Expected: &UpdateProtectionPolicyRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + UpdateProtectionPolicyRequestName: "updateProtectionPolicyRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectionPolicyRequests/updateProtectionPolicyRequestValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUpdateProtectionPolicyRequestID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.UpdateProtectionPolicyRequestName != v.Expected.UpdateProtectionPolicyRequestName { + t.Fatalf("Expected %q but got %q for UpdateProtectionPolicyRequestName", v.Expected.UpdateProtectionPolicyRequestName, actual.UpdateProtectionPolicyRequestName) + } + + } +} + +func TestParseUpdateProtectionPolicyRequestIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UpdateProtectionPolicyRequestId + }{ + { + // 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.DataProtection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectionPolicyRequests", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/uPdAtEpRoTeCtIoNpOlIcYrEqUeStS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectionPolicyRequests/updateProtectionPolicyRequestValue", + Expected: &UpdateProtectionPolicyRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ResourceGuardName: "resourceGuardValue", + UpdateProtectionPolicyRequestName: "updateProtectionPolicyRequestValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DataProtection/resourceGuards/resourceGuardValue/updateProtectionPolicyRequests/updateProtectionPolicyRequestValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/uPdAtEpRoTeCtIoNpOlIcYrEqUeStS/uPdAtEpRoTeCtIoNpOlIcYrEqUeStVaLuE", + Expected: &UpdateProtectionPolicyRequestId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ResourceGuardName: "rEsOuRcEgUaRdVaLuE", + UpdateProtectionPolicyRequestName: "uPdAtEpRoTeCtIoNpOlIcYrEqUeStVaLuE", + }, + }, + { + // 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.dAtApRoTeCtIoN/rEsOuRcEgUaRdS/rEsOuRcEgUaRdVaLuE/uPdAtEpRoTeCtIoNpOlIcYrEqUeStS/uPdAtEpRoTeCtIoNpOlIcYrEqUeStVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUpdateProtectionPolicyRequestIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ResourceGuardName != v.Expected.ResourceGuardName { + t.Fatalf("Expected %q but got %q for ResourceGuardName", v.Expected.ResourceGuardName, actual.ResourceGuardName) + } + + if actual.UpdateProtectionPolicyRequestName != v.Expected.UpdateProtectionPolicyRequestName { + t.Fatalf("Expected %q but got %q for UpdateProtectionPolicyRequestName", v.Expected.UpdateProtectionPolicyRequestName, actual.UpdateProtectionPolicyRequestName) + } + + } +} + +func TestSegmentsForUpdateProtectionPolicyRequestId(t *testing.T) { + segments := UpdateProtectionPolicyRequestId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UpdateProtectionPolicyRequestId 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/dataprotection/2024-04-01/resourceguards/method_delete.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_delete.go new file mode 100644 index 00000000000..7641951700d --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_delete.go @@ -0,0 +1,47 @@ +package resourceguards + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ResourceGuardsClient) Delete(ctx context.Context, id ResourceGuardId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_get.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_get.go new file mode 100644 index 00000000000..e95a3d77f1b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_get.go @@ -0,0 +1,54 @@ +package resourceguards + +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 *ResourceGuardResource +} + +// Get ... +func (c ResourceGuardsClient) Get(ctx context.Context, id ResourceGuardId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceGuardResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getbackupsecuritypinrequestsobjects.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getbackupsecuritypinrequestsobjects.go new file mode 100644 index 00000000000..036c8fa37e2 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getbackupsecuritypinrequestsobjects.go @@ -0,0 +1,91 @@ +package resourceguards + +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 GetBackupSecurityPINRequestsObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DppBaseResource +} + +type GetBackupSecurityPINRequestsObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DppBaseResource +} + +// GetBackupSecurityPINRequestsObjects ... +func (c ResourceGuardsClient) GetBackupSecurityPINRequestsObjects(ctx context.Context, id ResourceGuardId) (result GetBackupSecurityPINRequestsObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/getBackupSecurityPINRequests", 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 *[]DppBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBackupSecurityPINRequestsObjectsComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetBackupSecurityPINRequestsObjectsComplete(ctx context.Context, id ResourceGuardId) (GetBackupSecurityPINRequestsObjectsCompleteResult, error) { + return c.GetBackupSecurityPINRequestsObjectsCompleteMatchingPredicate(ctx, id, DppBaseResourceOperationPredicate{}) +} + +// GetBackupSecurityPINRequestsObjectsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetBackupSecurityPINRequestsObjectsCompleteMatchingPredicate(ctx context.Context, id ResourceGuardId, predicate DppBaseResourceOperationPredicate) (result GetBackupSecurityPINRequestsObjectsCompleteResult, err error) { + items := make([]DppBaseResource, 0) + + resp, err := c.GetBackupSecurityPINRequestsObjects(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 = GetBackupSecurityPINRequestsObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultbackupsecuritypinrequestsobject.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultbackupsecuritypinrequestsobject.go new file mode 100644 index 00000000000..4638718dc46 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultbackupsecuritypinrequestsobject.go @@ -0,0 +1,54 @@ +package resourceguards + +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 GetDefaultBackupSecurityPINRequestsObjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DppBaseResource +} + +// GetDefaultBackupSecurityPINRequestsObject ... +func (c ResourceGuardsClient) GetDefaultBackupSecurityPINRequestsObject(ctx context.Context, id GetBackupSecurityPINRequestId) (result GetDefaultBackupSecurityPINRequestsObjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DppBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteprotecteditemrequestsobject.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteprotecteditemrequestsobject.go new file mode 100644 index 00000000000..b3a996b5514 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteprotecteditemrequestsobject.go @@ -0,0 +1,54 @@ +package resourceguards + +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 GetDefaultDeleteProtectedItemRequestsObjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DppBaseResource +} + +// GetDefaultDeleteProtectedItemRequestsObject ... +func (c ResourceGuardsClient) GetDefaultDeleteProtectedItemRequestsObject(ctx context.Context, id DeleteProtectedItemRequestId) (result GetDefaultDeleteProtectedItemRequestsObjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DppBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteresourceguardproxyrequestsobject.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteresourceguardproxyrequestsobject.go new file mode 100644 index 00000000000..82604a5c9ed --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdeleteresourceguardproxyrequestsobject.go @@ -0,0 +1,54 @@ +package resourceguards + +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 GetDefaultDeleteResourceGuardProxyRequestsObjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DppBaseResource +} + +// GetDefaultDeleteResourceGuardProxyRequestsObject ... +func (c ResourceGuardsClient) GetDefaultDeleteResourceGuardProxyRequestsObject(ctx context.Context, id DeleteResourceGuardProxyRequestId) (result GetDefaultDeleteResourceGuardProxyRequestsObjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DppBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdisablesoftdeleterequestsobject.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdisablesoftdeleterequestsobject.go new file mode 100644 index 00000000000..e618503da42 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultdisablesoftdeleterequestsobject.go @@ -0,0 +1,54 @@ +package resourceguards + +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 GetDefaultDisableSoftDeleteRequestsObjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DppBaseResource +} + +// GetDefaultDisableSoftDeleteRequestsObject ... +func (c ResourceGuardsClient) GetDefaultDisableSoftDeleteRequestsObject(ctx context.Context, id DisableSoftDeleteRequestId) (result GetDefaultDisableSoftDeleteRequestsObjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DppBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotecteditemrequestsobject.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotecteditemrequestsobject.go new file mode 100644 index 00000000000..13158cedebe --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotecteditemrequestsobject.go @@ -0,0 +1,54 @@ +package resourceguards + +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 GetDefaultUpdateProtectedItemRequestsObjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DppBaseResource +} + +// GetDefaultUpdateProtectedItemRequestsObject ... +func (c ResourceGuardsClient) GetDefaultUpdateProtectedItemRequestsObject(ctx context.Context, id UpdateProtectedItemRequestId) (result GetDefaultUpdateProtectedItemRequestsObjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DppBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotectionpolicyrequestsobject.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotectionpolicyrequestsobject.go new file mode 100644 index 00000000000..ed3cb61d2f0 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdefaultupdateprotectionpolicyrequestsobject.go @@ -0,0 +1,54 @@ +package resourceguards + +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 GetDefaultUpdateProtectionPolicyRequestsObjectOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DppBaseResource +} + +// GetDefaultUpdateProtectionPolicyRequestsObject ... +func (c ResourceGuardsClient) GetDefaultUpdateProtectionPolicyRequestsObject(ctx context.Context, id UpdateProtectionPolicyRequestId) (result GetDefaultUpdateProtectionPolicyRequestsObjectOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DppBaseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteprotecteditemrequestsobjects.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteprotecteditemrequestsobjects.go new file mode 100644 index 00000000000..a2324a235ba --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteprotecteditemrequestsobjects.go @@ -0,0 +1,91 @@ +package resourceguards + +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 GetDeleteProtectedItemRequestsObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DppBaseResource +} + +type GetDeleteProtectedItemRequestsObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DppBaseResource +} + +// GetDeleteProtectedItemRequestsObjects ... +func (c ResourceGuardsClient) GetDeleteProtectedItemRequestsObjects(ctx context.Context, id ResourceGuardId) (result GetDeleteProtectedItemRequestsObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deleteProtectedItemRequests", 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 *[]DppBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDeleteProtectedItemRequestsObjectsComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetDeleteProtectedItemRequestsObjectsComplete(ctx context.Context, id ResourceGuardId) (GetDeleteProtectedItemRequestsObjectsCompleteResult, error) { + return c.GetDeleteProtectedItemRequestsObjectsCompleteMatchingPredicate(ctx, id, DppBaseResourceOperationPredicate{}) +} + +// GetDeleteProtectedItemRequestsObjectsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetDeleteProtectedItemRequestsObjectsCompleteMatchingPredicate(ctx context.Context, id ResourceGuardId, predicate DppBaseResourceOperationPredicate) (result GetDeleteProtectedItemRequestsObjectsCompleteResult, err error) { + items := make([]DppBaseResource, 0) + + resp, err := c.GetDeleteProtectedItemRequestsObjects(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 = GetDeleteProtectedItemRequestsObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteresourceguardproxyrequestsobjects.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteresourceguardproxyrequestsobjects.go new file mode 100644 index 00000000000..c92a6a46aa8 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdeleteresourceguardproxyrequestsobjects.go @@ -0,0 +1,91 @@ +package resourceguards + +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 GetDeleteResourceGuardProxyRequestsObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DppBaseResource +} + +type GetDeleteResourceGuardProxyRequestsObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DppBaseResource +} + +// GetDeleteResourceGuardProxyRequestsObjects ... +func (c ResourceGuardsClient) GetDeleteResourceGuardProxyRequestsObjects(ctx context.Context, id ResourceGuardId) (result GetDeleteResourceGuardProxyRequestsObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deleteResourceGuardProxyRequests", 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 *[]DppBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDeleteResourceGuardProxyRequestsObjectsComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetDeleteResourceGuardProxyRequestsObjectsComplete(ctx context.Context, id ResourceGuardId) (GetDeleteResourceGuardProxyRequestsObjectsCompleteResult, error) { + return c.GetDeleteResourceGuardProxyRequestsObjectsCompleteMatchingPredicate(ctx, id, DppBaseResourceOperationPredicate{}) +} + +// GetDeleteResourceGuardProxyRequestsObjectsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetDeleteResourceGuardProxyRequestsObjectsCompleteMatchingPredicate(ctx context.Context, id ResourceGuardId, predicate DppBaseResourceOperationPredicate) (result GetDeleteResourceGuardProxyRequestsObjectsCompleteResult, err error) { + items := make([]DppBaseResource, 0) + + resp, err := c.GetDeleteResourceGuardProxyRequestsObjects(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 = GetDeleteResourceGuardProxyRequestsObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdisablesoftdeleterequestsobjects.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdisablesoftdeleterequestsobjects.go new file mode 100644 index 00000000000..0b7aa6da862 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getdisablesoftdeleterequestsobjects.go @@ -0,0 +1,91 @@ +package resourceguards + +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 GetDisableSoftDeleteRequestsObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DppBaseResource +} + +type GetDisableSoftDeleteRequestsObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DppBaseResource +} + +// GetDisableSoftDeleteRequestsObjects ... +func (c ResourceGuardsClient) GetDisableSoftDeleteRequestsObjects(ctx context.Context, id ResourceGuardId) (result GetDisableSoftDeleteRequestsObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/disableSoftDeleteRequests", 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 *[]DppBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDisableSoftDeleteRequestsObjectsComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetDisableSoftDeleteRequestsObjectsComplete(ctx context.Context, id ResourceGuardId) (GetDisableSoftDeleteRequestsObjectsCompleteResult, error) { + return c.GetDisableSoftDeleteRequestsObjectsCompleteMatchingPredicate(ctx, id, DppBaseResourceOperationPredicate{}) +} + +// GetDisableSoftDeleteRequestsObjectsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetDisableSoftDeleteRequestsObjectsCompleteMatchingPredicate(ctx context.Context, id ResourceGuardId, predicate DppBaseResourceOperationPredicate) (result GetDisableSoftDeleteRequestsObjectsCompleteResult, err error) { + items := make([]DppBaseResource, 0) + + resp, err := c.GetDisableSoftDeleteRequestsObjects(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 = GetDisableSoftDeleteRequestsObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinresourcegroup.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinresourcegroup.go new file mode 100644 index 00000000000..f793b18c6ad --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinresourcegroup.go @@ -0,0 +1,92 @@ +package resourceguards + +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 GetResourcesInResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceGuardResource +} + +type GetResourcesInResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceGuardResource +} + +// GetResourcesInResourceGroup ... +func (c ResourceGuardsClient) GetResourcesInResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result GetResourcesInResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DataProtection/resourceGuards", 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 *[]ResourceGuardResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetResourcesInResourceGroupComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetResourcesInResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (GetResourcesInResourceGroupCompleteResult, error) { + return c.GetResourcesInResourceGroupCompleteMatchingPredicate(ctx, id, ResourceGuardResourceOperationPredicate{}) +} + +// GetResourcesInResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetResourcesInResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ResourceGuardResourceOperationPredicate) (result GetResourcesInResourceGroupCompleteResult, err error) { + items := make([]ResourceGuardResource, 0) + + resp, err := c.GetResourcesInResourceGroup(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 = GetResourcesInResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinsubscription.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinsubscription.go new file mode 100644 index 00000000000..b1834048d99 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getresourcesinsubscription.go @@ -0,0 +1,92 @@ +package resourceguards + +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 GetResourcesInSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceGuardResource +} + +type GetResourcesInSubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceGuardResource +} + +// GetResourcesInSubscription ... +func (c ResourceGuardsClient) GetResourcesInSubscription(ctx context.Context, id commonids.SubscriptionId) (result GetResourcesInSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DataProtection/resourceGuards", 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 *[]ResourceGuardResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetResourcesInSubscriptionComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetResourcesInSubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (GetResourcesInSubscriptionCompleteResult, error) { + return c.GetResourcesInSubscriptionCompleteMatchingPredicate(ctx, id, ResourceGuardResourceOperationPredicate{}) +} + +// GetResourcesInSubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetResourcesInSubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ResourceGuardResourceOperationPredicate) (result GetResourcesInSubscriptionCompleteResult, err error) { + items := make([]ResourceGuardResource, 0) + + resp, err := c.GetResourcesInSubscription(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 = GetResourcesInSubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotecteditemrequestsobjects.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotecteditemrequestsobjects.go new file mode 100644 index 00000000000..7d6a56cdf50 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotecteditemrequestsobjects.go @@ -0,0 +1,91 @@ +package resourceguards + +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 GetUpdateProtectedItemRequestsObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DppBaseResource +} + +type GetUpdateProtectedItemRequestsObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DppBaseResource +} + +// GetUpdateProtectedItemRequestsObjects ... +func (c ResourceGuardsClient) GetUpdateProtectedItemRequestsObjects(ctx context.Context, id ResourceGuardId) (result GetUpdateProtectedItemRequestsObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/updateProtectedItemRequests", 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 *[]DppBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUpdateProtectedItemRequestsObjectsComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetUpdateProtectedItemRequestsObjectsComplete(ctx context.Context, id ResourceGuardId) (GetUpdateProtectedItemRequestsObjectsCompleteResult, error) { + return c.GetUpdateProtectedItemRequestsObjectsCompleteMatchingPredicate(ctx, id, DppBaseResourceOperationPredicate{}) +} + +// GetUpdateProtectedItemRequestsObjectsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetUpdateProtectedItemRequestsObjectsCompleteMatchingPredicate(ctx context.Context, id ResourceGuardId, predicate DppBaseResourceOperationPredicate) (result GetUpdateProtectedItemRequestsObjectsCompleteResult, err error) { + items := make([]DppBaseResource, 0) + + resp, err := c.GetUpdateProtectedItemRequestsObjects(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 = GetUpdateProtectedItemRequestsObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotectionpolicyrequestsobjects.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotectionpolicyrequestsobjects.go new file mode 100644 index 00000000000..0426a67705f --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_getupdateprotectionpolicyrequestsobjects.go @@ -0,0 +1,91 @@ +package resourceguards + +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 GetUpdateProtectionPolicyRequestsObjectsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DppBaseResource +} + +type GetUpdateProtectionPolicyRequestsObjectsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DppBaseResource +} + +// GetUpdateProtectionPolicyRequestsObjects ... +func (c ResourceGuardsClient) GetUpdateProtectionPolicyRequestsObjects(ctx context.Context, id ResourceGuardId) (result GetUpdateProtectionPolicyRequestsObjectsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/updateProtectionPolicyRequests", 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 *[]DppBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUpdateProtectionPolicyRequestsObjectsComplete retrieves all the results into a single object +func (c ResourceGuardsClient) GetUpdateProtectionPolicyRequestsObjectsComplete(ctx context.Context, id ResourceGuardId) (GetUpdateProtectionPolicyRequestsObjectsCompleteResult, error) { + return c.GetUpdateProtectionPolicyRequestsObjectsCompleteMatchingPredicate(ctx, id, DppBaseResourceOperationPredicate{}) +} + +// GetUpdateProtectionPolicyRequestsObjectsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceGuardsClient) GetUpdateProtectionPolicyRequestsObjectsCompleteMatchingPredicate(ctx context.Context, id ResourceGuardId, predicate DppBaseResourceOperationPredicate) (result GetUpdateProtectionPolicyRequestsObjectsCompleteResult, err error) { + items := make([]DppBaseResource, 0) + + resp, err := c.GetUpdateProtectionPolicyRequestsObjects(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 = GetUpdateProtectionPolicyRequestsObjectsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_patch.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_patch.go new file mode 100644 index 00000000000..1c4cf4482c6 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_patch.go @@ -0,0 +1,58 @@ +package resourceguards + +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 PatchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceGuardResource +} + +// Patch ... +func (c ResourceGuardsClient) Patch(ctx context.Context, id ResourceGuardId, input PatchResourceGuardInput) (result PatchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ResourceGuardResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/method_put.go b/resource-manager/dataprotection/2024-04-01/resourceguards/method_put.go new file mode 100644 index 00000000000..1f0339e6424 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/method_put.go @@ -0,0 +1,59 @@ +package resourceguards + +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 PutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceGuardResource +} + +// Put ... +func (c ResourceGuardsClient) Put(ctx context.Context, id ResourceGuardId, input ResourceGuardResource) (result PutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceGuardResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/model_dppbaseresource.go b/resource-manager/dataprotection/2024-04-01/resourceguards/model_dppbaseresource.go new file mode 100644 index 00000000000..68d4e93d8b5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/model_dppbaseresource.go @@ -0,0 +1,10 @@ +package resourceguards + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DppBaseResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/model_patchresourceguardinput.go b/resource-manager/dataprotection/2024-04-01/resourceguards/model_patchresourceguardinput.go new file mode 100644 index 00000000000..f1fedc23f9b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/model_patchresourceguardinput.go @@ -0,0 +1,8 @@ +package resourceguards + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchResourceGuardInput struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguard.go b/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguard.go new file mode 100644 index 00000000000..968af9fa9f5 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguard.go @@ -0,0 +1,12 @@ +package resourceguards + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuard struct { + AllowAutoApprovals *bool `json:"allowAutoApprovals,omitempty"` + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuardOperations *[]ResourceGuardOperation `json:"resourceGuardOperations,omitempty"` + VaultCriticalOperationExclusionList *[]string `json:"vaultCriticalOperationExclusionList,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardoperation.go b/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardoperation.go new file mode 100644 index 00000000000..db7b25d6e59 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardoperation.go @@ -0,0 +1,9 @@ +package resourceguards + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardOperation struct { + RequestResourceType *string `json:"requestResourceType,omitempty"` + VaultCriticalOperation *string `json:"vaultCriticalOperation,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardresource.go b/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardresource.go new file mode 100644 index 00000000000..16508017629 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/model_resourceguardresource.go @@ -0,0 +1,19 @@ +package resourceguards + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceGuard `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/predicates.go b/resource-manager/dataprotection/2024-04-01/resourceguards/predicates.go new file mode 100644 index 00000000000..839d8fbca1b --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/predicates.go @@ -0,0 +1,60 @@ +package resourceguards + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DppBaseResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DppBaseResourceOperationPredicate) Matches(input DppBaseResource) 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 +} + +type ResourceGuardResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ResourceGuardResourceOperationPredicate) Matches(input ResourceGuardResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/dataprotection/2024-04-01/resourceguards/version.go b/resource-manager/dataprotection/2024-04-01/resourceguards/version.go new file mode 100644 index 00000000000..501ce9c5d02 --- /dev/null +++ b/resource-manager/dataprotection/2024-04-01/resourceguards/version.go @@ -0,0 +1,12 @@ +package resourceguards + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourceguards/%s", defaultApiVersion) +} diff --git a/resource-manager/eventhub/2024-01-01/client.go b/resource-manager/eventhub/2024-01-01/client.go index b7479f2319f..60302bd7cab 100644 --- a/resource-manager/eventhub/2024-01-01/client.go +++ b/resource-manager/eventhub/2024-01-01/client.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2024-01-01/eventhubsclustersavailableclusterregions" "github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2024-01-01/eventhubsclustersconfiguration" "github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2024-01-01/eventhubsclustersnamespace" - "github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade" "github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2024-01-01/namespaces" "github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2024-01-01/namespacesnetworksecurityperimeterconfigurations" "github.com/hashicorp/go-azure-sdk/resource-manager/eventhub/2024-01-01/namespacesprivateendpointconnections" @@ -44,7 +43,6 @@ type Client struct { EventHubsClustersAvailableClusterRegions *eventhubsclustersavailableclusterregions.EventHubsClustersAvailableClusterRegionsClient EventHubsClustersConfiguration *eventhubsclustersconfiguration.EventHubsClustersConfigurationClient EventHubsClustersNamespace *eventhubsclustersnamespace.EventHubsClustersNamespaceClient - EventHubsClustersUpgrade *eventhubsclustersupgrade.EventHubsClustersUpgradeClient Namespaces *namespaces.NamespacesClient NamespacesNetworkSecurityPerimeterConfigurations *namespacesnetworksecurityperimeterconfigurations.NamespacesNetworkSecurityPerimeterConfigurationsClient NamespacesPrivateEndpointConnections *namespacesprivateendpointconnections.NamespacesPrivateEndpointConnectionsClient @@ -132,12 +130,6 @@ func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanag } configureFunc(eventHubsClustersNamespaceClient.Client) - eventHubsClustersUpgradeClient, err := eventhubsclustersupgrade.NewEventHubsClustersUpgradeClientWithBaseURI(sdkApi) - if err != nil { - return nil, fmt.Errorf("building EventHubsClustersUpgrade client: %+v", err) - } - configureFunc(eventHubsClustersUpgradeClient.Client) - namespacesClient, err := namespaces.NewNamespacesClientWithBaseURI(sdkApi) if err != nil { return nil, fmt.Errorf("building Namespaces client: %+v", err) @@ -188,7 +180,6 @@ func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanag EventHubsClustersAvailableClusterRegions: eventHubsClustersAvailableClusterRegionsClient, EventHubsClustersConfiguration: eventHubsClustersConfigurationClient, EventHubsClustersNamespace: eventHubsClustersNamespaceClient, - EventHubsClustersUpgrade: eventHubsClustersUpgradeClient, Namespaces: namespacesClient, NamespacesNetworkSecurityPerimeterConfigurations: namespacesNetworkSecurityPerimeterConfigurationsClient, NamespacesPrivateEndpointConnections: namespacesPrivateEndpointConnectionsClient, diff --git a/resource-manager/eventhub/2024-01-01/eventhubs/model_eventhubproperties.go b/resource-manager/eventhub/2024-01-01/eventhubs/model_eventhubproperties.go index 026b41dad5e..83eb85a03db 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubs/model_eventhubproperties.go +++ b/resource-manager/eventhub/2024-01-01/eventhubs/model_eventhubproperties.go @@ -18,6 +18,7 @@ type EventhubProperties struct { RetentionDescription *RetentionDescription `json:"retentionDescription,omitempty"` Status *EntityStatus `json:"status,omitempty"` UpdatedAt *string `json:"updatedAt,omitempty"` + UserMetadata *string `json:"userMetadata,omitempty"` } func (o *EventhubProperties) GetCreatedAtAsTime() (*time.Time, error) { diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclusters/constants.go b/resource-manager/eventhub/2024-01-01/eventhubsclusters/constants.go index e796b62d183..49b1fc726a9 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubsclusters/constants.go +++ b/resource-manager/eventhub/2024-01-01/eventhubsclusters/constants.go @@ -105,62 +105,3 @@ func parseProvisioningState(input string) (*ProvisioningState, error) { out := ProvisioningState(input) return &out, nil } - -type StartDayOfWeek string - -const ( - StartDayOfWeekAny StartDayOfWeek = "Any" - StartDayOfWeekFriday StartDayOfWeek = "Friday" - StartDayOfWeekMonday StartDayOfWeek = "Monday" - StartDayOfWeekSaturday StartDayOfWeek = "Saturday" - StartDayOfWeekSunday StartDayOfWeek = "Sunday" - StartDayOfWeekThursday StartDayOfWeek = "Thursday" - StartDayOfWeekTuesday StartDayOfWeek = "Tuesday" - StartDayOfWeekWednesday StartDayOfWeek = "Wednesday" -) - -func PossibleValuesForStartDayOfWeek() []string { - return []string{ - string(StartDayOfWeekAny), - string(StartDayOfWeekFriday), - string(StartDayOfWeekMonday), - string(StartDayOfWeekSaturday), - string(StartDayOfWeekSunday), - string(StartDayOfWeekThursday), - string(StartDayOfWeekTuesday), - string(StartDayOfWeekWednesday), - } -} - -func (s *StartDayOfWeek) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseStartDayOfWeek(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseStartDayOfWeek(input string) (*StartDayOfWeek, error) { - vals := map[string]StartDayOfWeek{ - "any": StartDayOfWeekAny, - "friday": StartDayOfWeekFriday, - "monday": StartDayOfWeekMonday, - "saturday": StartDayOfWeekSaturday, - "sunday": StartDayOfWeekSunday, - "thursday": StartDayOfWeekThursday, - "tuesday": StartDayOfWeekTuesday, - "wednesday": StartDayOfWeekWednesday, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := StartDayOfWeek(input) - return &out, nil -} diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclusters/model_clusterproperties.go b/resource-manager/eventhub/2024-01-01/eventhubsclusters/model_clusterproperties.go index def4b67f2a4..79f93d89f4e 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubsclusters/model_clusterproperties.go +++ b/resource-manager/eventhub/2024-01-01/eventhubsclusters/model_clusterproperties.go @@ -4,11 +4,10 @@ package eventhubsclusters // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type ClusterProperties struct { - CreatedAt *string `json:"createdAt,omitempty"` - MetricId *string `json:"metricId,omitempty"` - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` - Status *string `json:"status,omitempty"` - SupportsScaling *bool `json:"supportsScaling,omitempty"` - UpdatedAt *string `json:"updatedAt,omitempty"` - UpgradePreferences *UpgradePreferences `json:"upgradePreferences,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` + MetricId *string `json:"metricId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *string `json:"status,omitempty"` + SupportsScaling *bool `json:"supportsScaling,omitempty"` + UpdatedAt *string `json:"updatedAt,omitempty"` } diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclusters/model_upgradepreferences.go b/resource-manager/eventhub/2024-01-01/eventhubsclusters/model_upgradepreferences.go deleted file mode 100644 index f12fd4cfaa9..00000000000 --- a/resource-manager/eventhub/2024-01-01/eventhubsclusters/model_upgradepreferences.go +++ /dev/null @@ -1,9 +0,0 @@ -package eventhubsclusters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type UpgradePreferences struct { - StartDayOfWeek *StartDayOfWeek `json:"startDayOfWeek,omitempty"` - StartHourOfDay *int64 `json:"startHourOfDay,omitempty"` -} diff --git a/resource-manager/recoveryservices/2024-04-01/client.go b/resource-manager/recoveryservices/2024-04-01/client.go new file mode 100644 index 00000000000..880cd30eee5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/client.go @@ -0,0 +1,100 @@ +package v2024_04_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/recoveryservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/registeredidentities" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/replicationusages" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultcertificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaults" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultusages" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + GetPrivateLinkResources *getprivatelinkresources.GetPrivateLinkResourcesClient + ListPrivateLinkResources *listprivatelinkresources.ListPrivateLinkResourcesClient + RecoveryServices *recoveryservices.RecoveryServicesClient + RegisteredIdentities *registeredidentities.RegisteredIdentitiesClient + ReplicationUsages *replicationusages.ReplicationUsagesClient + VaultCertificates *vaultcertificates.VaultCertificatesClient + VaultExtendedInfo *vaultextendedinfo.VaultExtendedInfoClient + VaultUsages *vaultusages.VaultUsagesClient + Vaults *vaults.VaultsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + getPrivateLinkResourcesClient, err := getprivatelinkresources.NewGetPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building GetPrivateLinkResources client: %+v", err) + } + configureFunc(getPrivateLinkResourcesClient.Client) + + listPrivateLinkResourcesClient, err := listprivatelinkresources.NewListPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ListPrivateLinkResources client: %+v", err) + } + configureFunc(listPrivateLinkResourcesClient.Client) + + recoveryServicesClient, err := recoveryservices.NewRecoveryServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RecoveryServices client: %+v", err) + } + configureFunc(recoveryServicesClient.Client) + + registeredIdentitiesClient, err := registeredidentities.NewRegisteredIdentitiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RegisteredIdentities client: %+v", err) + } + configureFunc(registeredIdentitiesClient.Client) + + replicationUsagesClient, err := replicationusages.NewReplicationUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReplicationUsages client: %+v", err) + } + configureFunc(replicationUsagesClient.Client) + + vaultCertificatesClient, err := vaultcertificates.NewVaultCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VaultCertificates client: %+v", err) + } + configureFunc(vaultCertificatesClient.Client) + + vaultExtendedInfoClient, err := vaultextendedinfo.NewVaultExtendedInfoClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VaultExtendedInfo client: %+v", err) + } + configureFunc(vaultExtendedInfoClient.Client) + + vaultUsagesClient, err := vaultusages.NewVaultUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VaultUsages client: %+v", err) + } + configureFunc(vaultUsagesClient.Client) + + vaultsClient, err := vaults.NewVaultsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Vaults client: %+v", err) + } + configureFunc(vaultsClient.Client) + + return &Client{ + GetPrivateLinkResources: getPrivateLinkResourcesClient, + ListPrivateLinkResources: listPrivateLinkResourcesClient, + RecoveryServices: recoveryServicesClient, + RegisteredIdentities: registeredIdentitiesClient, + ReplicationUsages: replicationUsagesClient, + VaultCertificates: vaultCertificatesClient, + VaultExtendedInfo: vaultExtendedInfoClient, + VaultUsages: vaultUsagesClient, + Vaults: vaultsClient, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/README.md b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/README.md new file mode 100644 index 00000000000..4b37d35c072 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources` Documentation + +The `getprivatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources" +``` + + +### Client Initialization + +```go +client := getprivatelinkresources.NewGetPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GetPrivateLinkResourcesClient.PrivateLinkResourcesGet` + +```go +ctx := context.TODO() +id := getprivatelinkresources.NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateLinkResourceValue") + +read, err := client.PrivateLinkResourcesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/client.go b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/client.go new file mode 100644 index 00000000000..2c788db4e51 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package getprivatelinkresources + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewGetPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*GetPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "getprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GetPrivateLinkResourcesClient: %+v", err) + } + + return &GetPrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource.go b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource.go new file mode 100644 index 00000000000..70ee568e5d3 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource.go @@ -0,0 +1,139 @@ +package getprivatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateLinkResourceId{}) +} + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +// PrivateLinkResourceId is a struct representing the Resource ID for a Private Link Resource +type PrivateLinkResourceId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + PrivateLinkResourceName string +} + +// NewPrivateLinkResourceID returns a new PrivateLinkResourceId struct +func NewPrivateLinkResourceID(subscriptionId string, resourceGroupName string, vaultName string, privateLinkResourceName string) PrivateLinkResourceId { + return PrivateLinkResourceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + PrivateLinkResourceName: privateLinkResourceName, + } +} + +// ParsePrivateLinkResourceID parses 'input' into a PrivateLinkResourceId +func ParsePrivateLinkResourceID(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateLinkResourceIDInsensitively parses 'input' case-insensitively into a PrivateLinkResourceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkResourceIDInsensitively(input string) (*PrivateLinkResourceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkResourceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkResourceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateLinkResourceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.PrivateLinkResourceName, ok = input.Parsed["privateLinkResourceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateLinkResourceName", input) + } + + return nil +} + +// ValidatePrivateLinkResourceID checks that 'input' can be parsed as a Private Link Resource ID +func ValidatePrivateLinkResourceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateLinkResourceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Resource ID +func (id PrivateLinkResourceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/privateLinkResources/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.PrivateLinkResourceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Resource ID +func (id PrivateLinkResourceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticPrivateLinkResources", "privateLinkResources", "privateLinkResources"), + resourceids.UserSpecifiedSegment("privateLinkResourceName", "privateLinkResourceValue"), + } +} + +// String returns a human-readable description of this Private Link Resource ID +func (id PrivateLinkResourceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Private Link Resource Name: %q", id.PrivateLinkResourceName), + } + return fmt.Sprintf("Private Link Resource (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource_test.go b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource_test.go new file mode 100644 index 00000000000..7ee1c858da1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/id_privatelinkresource_test.go @@ -0,0 +1,327 @@ +package getprivatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateLinkResourceId{} + +func TestNewPrivateLinkResourceID(t *testing.T) { + id := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateLinkResourceValue") + + 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.PrivateLinkResourceName != "privateLinkResourceValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateLinkResourceName'", id.PrivateLinkResourceName, "privateLinkResourceValue") + } +} + +func TestFormatPrivateLinkResourceID(t *testing.T) { + actual := NewPrivateLinkResourceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateLinkResourceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateLinkResources/privateLinkResourceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkResourceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateLinkResources", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateLinkResources/privateLinkResourceValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + PrivateLinkResourceName: "privateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateLinkResources/privateLinkResourceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestParsePrivateLinkResourceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkResourceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/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/privateLinkResources", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/pRiVaTeLiNkReSoUrCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateLinkResources/privateLinkResourceValue", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + PrivateLinkResourceName: "privateLinkResourceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateLinkResources/privateLinkResourceValue/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/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeVaLuE", + Expected: &PrivateLinkResourceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + PrivateLinkResourceName: "pRiVaTeLiNkReSoUrCeVaLuE", + }, + }, + { + // 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/pRiVaTeLiNkReSoUrCeS/pRiVaTeLiNkReSoUrCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkResourceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateLinkResourceName != v.Expected.PrivateLinkResourceName { + t.Fatalf("Expected %q but got %q for PrivateLinkResourceName", v.Expected.PrivateLinkResourceName, actual.PrivateLinkResourceName) + } + + } +} + +func TestSegmentsForPrivateLinkResourceId(t *testing.T) { + segments := PrivateLinkResourceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkResourceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/method_privatelinkresourcesget.go b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/method_privatelinkresourcesget.go new file mode 100644 index 00000000000..8074fb34792 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/method_privatelinkresourcesget.go @@ -0,0 +1,54 @@ +package getprivatelinkresources + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// PrivateLinkResourcesGet ... +func (c GetPrivateLinkResourcesClient) PrivateLinkResourcesGet(ctx context.Context, id PrivateLinkResourceId) (result PrivateLinkResourcesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresource.go b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..36e56a45b5e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package getprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..92b1276283a --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package getprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/version.go b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/version.go new file mode 100644 index 00000000000..a26ae783d0b --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/getprivatelinkresources/version.go @@ -0,0 +1,12 @@ +package getprivatelinkresources + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/getprivatelinkresources/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/README.md b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/README.md new file mode 100644 index 00000000000..9db23692630 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources` Documentation + +The `listprivatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources" +``` + + +### Client Initialization + +```go +client := listprivatelinkresources.NewListPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ListPrivateLinkResourcesClient.PrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := listprivatelinkresources.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.PrivateLinkResourcesList(ctx, id)` can be used to do batched pagination +items, err := client.PrivateLinkResourcesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/client.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/client.go new file mode 100644 index 00000000000..d68ed338ccc --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package listprivatelinkresources + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewListPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*ListPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "listprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ListPrivateLinkResourcesClient: %+v", err) + } + + return &ListPrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/id_vault.go similarity index 54% rename from resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster.go rename to resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/id_vault.go index 546a629b994..332d5bf97d5 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/id_cluster.go +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/id_vault.go @@ -1,4 +1,4 @@ -package eventhubsclustersupgrade +package listprivatelinkresources import ( "fmt" @@ -12,36 +12,36 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. func init() { - recaser.RegisterResourceId(&ClusterId{}) + recaser.RegisterResourceId(&VaultId{}) } -var _ resourceids.ResourceId = &ClusterId{} +var _ resourceids.ResourceId = &VaultId{} -// ClusterId is a struct representing the Resource ID for a Cluster -type ClusterId struct { +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { SubscriptionId string ResourceGroupName string - ClusterName string + VaultName string } -// NewClusterID returns a new ClusterId struct -func NewClusterID(subscriptionId string, resourceGroupName string, clusterName string) ClusterId { - return ClusterId{ +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ SubscriptionId: subscriptionId, ResourceGroupName: resourceGroupName, - ClusterName: clusterName, + VaultName: vaultName, } } -// ParseClusterID parses 'input' into a ClusterId -func ParseClusterID(input string) (*ClusterId, error) { - parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) +// 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 := ClusterId{} + id := VaultId{} if err := id.FromParseResult(*parsed); err != nil { return nil, err } @@ -49,16 +49,16 @@ func ParseClusterID(input string) (*ClusterId, error) { return &id, nil } -// ParseClusterIDInsensitively parses 'input' case-insensitively into a ClusterId +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId // note: this method should only be used for API response data and not user input -func ParseClusterIDInsensitively(input string) (*ClusterId, error) { - parser := resourceids.NewParserFromResourceIdType(&ClusterId{}) +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 := ClusterId{} + id := VaultId{} if err := id.FromParseResult(*parsed); err != nil { return nil, err } @@ -66,7 +66,7 @@ func ParseClusterIDInsensitively(input string) (*ClusterId, error) { return &id, nil } -func (id *ClusterId) FromParseResult(input resourceids.ParseResult) error { +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { var ok bool if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { @@ -77,54 +77,54 @@ func (id *ClusterId) FromParseResult(input resourceids.ParseResult) error { return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) } - if id.ClusterName, ok = input.Parsed["clusterName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "clusterName", input) + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) } return nil } -// ValidateClusterID checks that 'input' can be parsed as a Cluster ID -func ValidateClusterID(input interface{}, key string) (warnings []string, errors []error) { +// 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 := ParseClusterID(v); err != nil { + if _, err := ParseVaultID(v); err != nil { errors = append(errors, err) } return } -// ID returns the formatted Cluster ID -func (id ClusterId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.EventHub/clusters/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ClusterName) +// 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 Cluster ID -func (id ClusterId) Segments() []resourceids.Segment { +// 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("staticMicrosoftEventHub", "Microsoft.EventHub", "Microsoft.EventHub"), - resourceids.StaticSegment("staticClusters", "clusters", "clusters"), - resourceids.UserSpecifiedSegment("clusterName", "clusterValue"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), } } -// String returns a human-readable description of this Cluster ID -func (id ClusterId) String() string { +// 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("Cluster Name: %q", id.ClusterName), + fmt.Sprintf("Vault Name: %q", id.VaultName), } - return fmt.Sprintf("Cluster (%s)", strings.Join(components, "\n")) + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) } diff --git a/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/id_vault_test.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/id_vault_test.go new file mode 100644 index 00000000000..79099dc74de --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/id_vault_test.go @@ -0,0 +1,282 @@ +package listprivatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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/recoveryservices/2024-04-01/listprivatelinkresources/method_privatelinkresourceslist.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/method_privatelinkresourceslist.go new file mode 100644 index 00000000000..994db6cbef7 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/method_privatelinkresourceslist.go @@ -0,0 +1,91 @@ +package listprivatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type PrivateLinkResourcesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +// PrivateLinkResourcesList ... +func (c ListPrivateLinkResourcesClient) PrivateLinkResourcesList(ctx context.Context, id VaultId) (result PrivateLinkResourcesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateLinkResourcesListComplete retrieves all the results into a single object +func (c ListPrivateLinkResourcesClient) PrivateLinkResourcesListComplete(ctx context.Context, id VaultId) (PrivateLinkResourcesListCompleteResult, error) { + return c.PrivateLinkResourcesListCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// PrivateLinkResourcesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ListPrivateLinkResourcesClient) PrivateLinkResourcesListCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate PrivateLinkResourceOperationPredicate) (result PrivateLinkResourcesListCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.PrivateLinkResourcesList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateLinkResourcesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresource.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..43ad3ab77fa --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package listprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..b1ff4a935fd --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package listprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/predicates.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/predicates.go new file mode 100644 index 00000000000..5eb0bb91e57 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/predicates.go @@ -0,0 +1,27 @@ +package listprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/version.go b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/version.go new file mode 100644 index 00000000000..cbed2dde185 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/listprivatelinkresources/version.go @@ -0,0 +1,12 @@ +package listprivatelinkresources + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/listprivatelinkresources/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/README.md b/resource-manager/recoveryservices/2024-04-01/recoveryservices/README.md new file mode 100644 index 00000000000..0d3448c61bc --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/README.md @@ -0,0 +1,62 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/recoveryservices` Documentation + +The `recoveryservices` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/recoveryservices" +``` + + +### Client Initialization + +```go +client := recoveryservices.NewRecoveryServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryServicesClient.Capabilities` + +```go +ctx := context.TODO() +id := recoveryservices.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := recoveryservices.ResourceCapabilities{ + // ... +} + + +read, err := client.Capabilities(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecoveryServicesClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := recoveryservices.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + +payload := recoveryservices.CheckNameAvailabilityParameters{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/client.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/client.go new file mode 100644 index 00000000000..518088771ea --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/client.go @@ -0,0 +1,26 @@ +package recoveryservices + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryServicesClient struct { + Client *resourcemanager.Client +} + +func NewRecoveryServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*RecoveryServicesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "recoveryservices", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecoveryServicesClient: %+v", err) + } + + return &RecoveryServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/constants.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/constants.go new file mode 100644 index 00000000000..920bcd8e566 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/constants.go @@ -0,0 +1,54 @@ +package recoveryservices + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSubResourceType string + +const ( + VaultSubResourceTypeAzureBackup VaultSubResourceType = "AzureBackup" + VaultSubResourceTypeAzureBackupSecondary VaultSubResourceType = "AzureBackup_secondary" + VaultSubResourceTypeAzureSiteRecovery VaultSubResourceType = "AzureSiteRecovery" +) + +func PossibleValuesForVaultSubResourceType() []string { + return []string{ + string(VaultSubResourceTypeAzureBackup), + string(VaultSubResourceTypeAzureBackupSecondary), + string(VaultSubResourceTypeAzureSiteRecovery), + } +} + +func (s *VaultSubResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultSubResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultSubResourceType(input string) (*VaultSubResourceType, error) { + vals := map[string]VaultSubResourceType{ + "azurebackup": VaultSubResourceTypeAzureBackup, + "azurebackup_secondary": VaultSubResourceTypeAzureBackupSecondary, + "azuresiterecovery": VaultSubResourceTypeAzureSiteRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultSubResourceType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location.go new file mode 100644 index 00000000000..1fd49c9d992 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location.go @@ -0,0 +1,121 @@ +package recoveryservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location_test.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location_test.go new file mode 100644 index 00000000000..3c75d278a94 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_location_test.go @@ -0,0 +1,237 @@ +package recoveryservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation.go new file mode 100644 index 00000000000..33d3548750d --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation.go @@ -0,0 +1,130 @@ +package recoveryservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation_test.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation_test.go new file mode 100644 index 00000000000..28405ec9bd8 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package recoveryservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/method_capabilities.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/method_capabilities.go new file mode 100644 index 00000000000..5864d60faeb --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/method_capabilities.go @@ -0,0 +1,59 @@ +package recoveryservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapabilitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CapabilitiesResponse +} + +// Capabilities ... +func (c RecoveryServicesClient) Capabilities(ctx context.Context, id LocationId, input ResourceCapabilities) (result CapabilitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/capabilities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CapabilitiesResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/method_checknameavailability.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/method_checknameavailability.go new file mode 100644 index 00000000000..3512794c701 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/method_checknameavailability.go @@ -0,0 +1,59 @@ +package recoveryservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CheckNameAvailabilityResult +} + +// CheckNameAvailability ... +func (c RecoveryServicesClient) CheckNameAvailability(ctx context.Context, id ProviderLocationId, input CheckNameAvailabilityParameters) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CheckNameAvailabilityResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesproperties.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesproperties.go new file mode 100644 index 00000000000..3698ddb8850 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesproperties.go @@ -0,0 +1,8 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapabilitiesProperties struct { + DnsZones *[]DNSZone `json:"dnsZones,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponse.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponse.go new file mode 100644 index 00000000000..47e4997660f --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponse.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapabilitiesResponse struct { + Properties *CapabilitiesResponseProperties `json:"properties,omitempty"` + Type string `json:"type"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponseproperties.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponseproperties.go new file mode 100644 index 00000000000..8c1bfbcac8d --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_capabilitiesresponseproperties.go @@ -0,0 +1,8 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CapabilitiesResponseProperties struct { + DnsZones *[]DNSZoneResponse `json:"dnsZones,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityparameters.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityparameters.go new file mode 100644 index 00000000000..e6c5aff2402 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityparameters.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityParameters struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityresult.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityresult.go new file mode 100644 index 00000000000..d2840ec335e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_checknameavailabilityresult.go @@ -0,0 +1,10 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityResult struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *string `json:"reason,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszone.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszone.go new file mode 100644 index 00000000000..34952cfbd7e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszone.go @@ -0,0 +1,8 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DNSZone struct { + SubResource *VaultSubResourceType `json:"subResource,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszoneresponse.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszoneresponse.go new file mode 100644 index 00000000000..4aabe0bd6d4 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_dnszoneresponse.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DNSZoneResponse struct { + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` + SubResource *VaultSubResourceType `json:"subResource,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_resourcecapabilities.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_resourcecapabilities.go new file mode 100644 index 00000000000..16d3a668058 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/model_resourcecapabilities.go @@ -0,0 +1,9 @@ +package recoveryservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceCapabilities struct { + Properties *CapabilitiesProperties `json:"properties,omitempty"` + Type string `json:"type"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/recoveryservices/version.go b/resource-manager/recoveryservices/2024-04-01/recoveryservices/version.go new file mode 100644 index 00000000000..af1f4581f5a --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/recoveryservices/version.go @@ -0,0 +1,12 @@ +package recoveryservices + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoveryservices/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/registeredidentities/client.go b/resource-manager/recoveryservices/2024-04-01/registeredidentities/client.go new file mode 100644 index 00000000000..36b4015e582 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/registeredidentities/client.go @@ -0,0 +1,26 @@ +package registeredidentities + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisteredIdentitiesClient struct { + Client *resourcemanager.Client +} + +func NewRegisteredIdentitiesClientWithBaseURI(sdkApi sdkEnv.Api) (*RegisteredIdentitiesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "registeredidentities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RegisteredIdentitiesClient: %+v", err) + } + + return &RegisteredIdentitiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity.go b/resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity.go new file mode 100644 index 00000000000..147a6d0d6e3 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity.go @@ -0,0 +1,139 @@ +package registeredidentities + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegisteredIdentityId{}) +} + +var _ resourceids.ResourceId = &RegisteredIdentityId{} + +// RegisteredIdentityId is a struct representing the Resource ID for a Registered Identity +type RegisteredIdentityId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + RegisteredIdentityName string +} + +// NewRegisteredIdentityID returns a new RegisteredIdentityId struct +func NewRegisteredIdentityID(subscriptionId string, resourceGroupName string, vaultName string, registeredIdentityName string) RegisteredIdentityId { + return RegisteredIdentityId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + RegisteredIdentityName: registeredIdentityName, + } +} + +// ParseRegisteredIdentityID parses 'input' into a RegisteredIdentityId +func ParseRegisteredIdentityID(input string) (*RegisteredIdentityId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegisteredIdentityId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegisteredIdentityId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegisteredIdentityIDInsensitively parses 'input' case-insensitively into a RegisteredIdentityId +// note: this method should only be used for API response data and not user input +func ParseRegisteredIdentityIDInsensitively(input string) (*RegisteredIdentityId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegisteredIdentityId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegisteredIdentityId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegisteredIdentityId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.RegisteredIdentityName, ok = input.Parsed["registeredIdentityName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registeredIdentityName", input) + } + + return nil +} + +// ValidateRegisteredIdentityID checks that 'input' can be parsed as a Registered Identity ID +func ValidateRegisteredIdentityID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegisteredIdentityID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registered Identity ID +func (id RegisteredIdentityId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/registeredIdentities/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.RegisteredIdentityName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registered Identity ID +func (id RegisteredIdentityId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticRegisteredIdentities", "registeredIdentities", "registeredIdentities"), + resourceids.UserSpecifiedSegment("registeredIdentityName", "registeredIdentityValue"), + } +} + +// String returns a human-readable description of this Registered Identity ID +func (id RegisteredIdentityId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Registered Identity Name: %q", id.RegisteredIdentityName), + } + return fmt.Sprintf("Registered Identity (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity_test.go b/resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity_test.go new file mode 100644 index 00000000000..6857bb4f14e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/registeredidentities/id_registeredidentity_test.go @@ -0,0 +1,327 @@ +package registeredidentities + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegisteredIdentityId{} + +func TestNewRegisteredIdentityID(t *testing.T) { + id := NewRegisteredIdentityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "registeredIdentityValue") + + 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.RegisteredIdentityName != "registeredIdentityValue" { + t.Fatalf("Expected %q but got %q for Segment 'RegisteredIdentityName'", id.RegisteredIdentityName, "registeredIdentityValue") + } +} + +func TestFormatRegisteredIdentityID(t *testing.T) { + actual := NewRegisteredIdentityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "registeredIdentityValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/registeredIdentities/registeredIdentityValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegisteredIdentityID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegisteredIdentityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/registeredIdentities", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/registeredIdentities/registeredIdentityValue", + Expected: &RegisteredIdentityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + RegisteredIdentityName: "registeredIdentityValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/registeredIdentities/registeredIdentityValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegisteredIdentityID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.RegisteredIdentityName != v.Expected.RegisteredIdentityName { + t.Fatalf("Expected %q but got %q for RegisteredIdentityName", v.Expected.RegisteredIdentityName, actual.RegisteredIdentityName) + } + + } +} + +func TestParseRegisteredIdentityIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegisteredIdentityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/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/registeredIdentities", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/rEgIsTeReDiDeNtItIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/registeredIdentities/registeredIdentityValue", + Expected: &RegisteredIdentityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + RegisteredIdentityName: "registeredIdentityValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/registeredIdentities/registeredIdentityValue/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/rEgIsTeReDiDeNtItIeS/rEgIsTeReDiDeNtItYvAlUe", + Expected: &RegisteredIdentityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + RegisteredIdentityName: "rEgIsTeReDiDeNtItYvAlUe", + }, + }, + { + // 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/rEgIsTeReDiDeNtItIeS/rEgIsTeReDiDeNtItYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegisteredIdentityIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.RegisteredIdentityName != v.Expected.RegisteredIdentityName { + t.Fatalf("Expected %q but got %q for RegisteredIdentityName", v.Expected.RegisteredIdentityName, actual.RegisteredIdentityName) + } + + } +} + +func TestSegmentsForRegisteredIdentityId(t *testing.T) { + segments := RegisteredIdentityId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegisteredIdentityId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-04-01/registeredidentities/method_delete.go b/resource-manager/recoveryservices/2024-04-01/registeredidentities/method_delete.go new file mode 100644 index 00000000000..16a5301af92 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/registeredidentities/method_delete.go @@ -0,0 +1,46 @@ +package registeredidentities + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RegisteredIdentitiesClient) Delete(ctx context.Context, id RegisteredIdentityId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/registeredidentities/version.go b/resource-manager/recoveryservices/2024-04-01/registeredidentities/version.go new file mode 100644 index 00000000000..9a09e3c0d27 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/registeredidentities/version.go @@ -0,0 +1,12 @@ +package registeredidentities + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/registeredidentities/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/README.md b/resource-manager/recoveryservices/2024-04-01/replicationusages/README.md new file mode 100644 index 00000000000..38a19def949 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/replicationusages` Documentation + +The `replicationusages` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/replicationusages" +``` + + +### Client Initialization + +```go +client := replicationusages.NewReplicationUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReplicationUsagesClient.List` + +```go +ctx := context.TODO() +id := replicationusages.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/client.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/client.go new file mode 100644 index 00000000000..40ebde8ba63 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/client.go @@ -0,0 +1,26 @@ +package replicationusages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationUsagesClient struct { + Client *resourcemanager.Client +} + +func NewReplicationUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*ReplicationUsagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "replicationusages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReplicationUsagesClient: %+v", err) + } + + return &ReplicationUsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/id_vault.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/id_vault.go new file mode 100644 index 00000000000..338b117c7be --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/id_vault.go @@ -0,0 +1,130 @@ +package replicationusages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "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/recoveryservices/2024-04-01/replicationusages/id_vault_test.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/id_vault_test.go new file mode 100644 index 00000000000..679ad2eacfb --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/id_vault_test.go @@ -0,0 +1,282 @@ +package replicationusages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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/recoveryservices/2024-04-01/replicationusages/method_list.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/method_list.go new file mode 100644 index 00000000000..67aa893023e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/method_list.go @@ -0,0 +1,55 @@ +package replicationusages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReplicationUsageList +} + +// List ... +func (c ReplicationUsagesClient) List(ctx context.Context, id VaultId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/replicationUsages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReplicationUsageList + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/model_jobssummary.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_jobssummary.go new file mode 100644 index 00000000000..b4e8997b7d2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_jobssummary.go @@ -0,0 +1,10 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobsSummary struct { + FailedJobs *int64 `json:"failedJobs,omitempty"` + InProgressJobs *int64 `json:"inProgressJobs,omitempty"` + SuspendedJobs *int64 `json:"suspendedJobs,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/model_monitoringsummary.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_monitoringsummary.go new file mode 100644 index 00000000000..fbf4ba89507 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_monitoringsummary.go @@ -0,0 +1,13 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringSummary struct { + DeprecatedProviderCount *int64 `json:"deprecatedProviderCount,omitempty"` + EventsCount *int64 `json:"eventsCount,omitempty"` + SupportedProviderCount *int64 `json:"supportedProviderCount,omitempty"` + UnHealthyProviderCount *int64 `json:"unHealthyProviderCount,omitempty"` + UnHealthyVMCount *int64 `json:"unHealthyVmCount,omitempty"` + UnsupportedProviderCount *int64 `json:"unsupportedProviderCount,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusage.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusage.go new file mode 100644 index 00000000000..0842f810533 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusage.go @@ -0,0 +1,13 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationUsage struct { + JobsSummary *JobsSummary `json:"jobsSummary,omitempty"` + MonitoringSummary *MonitoringSummary `json:"monitoringSummary,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + RecoveryPlanCount *int64 `json:"recoveryPlanCount,omitempty"` + RecoveryServicesProviderAuthType *int64 `json:"recoveryServicesProviderAuthType,omitempty"` + RegisteredServersCount *int64 `json:"registeredServersCount,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusagelist.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusagelist.go new file mode 100644 index 00000000000..11300c459d2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/model_replicationusagelist.go @@ -0,0 +1,8 @@ +package replicationusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReplicationUsageList struct { + Value *[]ReplicationUsage `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/replicationusages/version.go b/resource-manager/recoveryservices/2024-04-01/replicationusages/version.go new file mode 100644 index 00000000000..33e15efda72 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/replicationusages/version.go @@ -0,0 +1,12 @@ +package replicationusages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/replicationusages/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/README.md b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/README.md new file mode 100644 index 00000000000..ab60878eff1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultcertificates` Documentation + +The `vaultcertificates` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultcertificates" +``` + + +### Client Initialization + +```go +client := vaultcertificates.NewVaultCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultCertificatesClient.Create` + +```go +ctx := context.TODO() +id := vaultcertificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "certificateValue") + +payload := vaultcertificates.CertificateRequest{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/client.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/client.go new file mode 100644 index 00000000000..f25a5998dcc --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/client.go @@ -0,0 +1,26 @@ +package vaultcertificates + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultCertificatesClient struct { + Client *resourcemanager.Client +} + +func NewVaultCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultCertificatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "vaultcertificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultCertificatesClient: %+v", err) + } + + return &VaultCertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/constants.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/constants.go new file mode 100644 index 00000000000..66072e83ada --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/constants.go @@ -0,0 +1,60 @@ +package vaultcertificates + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthType string + +const ( + AuthTypeAAD AuthType = "AAD" + AuthTypeACS AuthType = "ACS" + AuthTypeAccessControlService AuthType = "AccessControlService" + AuthTypeAzureActiveDirectory AuthType = "AzureActiveDirectory" + AuthTypeInvalid AuthType = "Invalid" +) + +func PossibleValuesForAuthType() []string { + return []string{ + string(AuthTypeAAD), + string(AuthTypeACS), + string(AuthTypeAccessControlService), + string(AuthTypeAzureActiveDirectory), + string(AuthTypeInvalid), + } +} + +func (s *AuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthType(input string) (*AuthType, error) { + vals := map[string]AuthType{ + "aad": AuthTypeAAD, + "acs": AuthTypeACS, + "accesscontrolservice": AuthTypeAccessControlService, + "azureactivedirectory": AuthTypeAzureActiveDirectory, + "invalid": AuthTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate.go new file mode 100644 index 00000000000..1a998266e49 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate.go @@ -0,0 +1,139 @@ +package vaultcertificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, vaultName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate_test.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate_test.go new file mode 100644 index 00000000000..2e113a065ed --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/id_certificate_test.go @@ -0,0 +1,327 @@ +package vaultcertificates + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "certificateValue") + + 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.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/certificates/certificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/certificates/certificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/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/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/certificates/certificateValue/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/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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/cErTiFiCaTeS/cErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/method_create.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/method_create.go new file mode 100644 index 00000000000..1be290d4f6b --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/method_create.go @@ -0,0 +1,58 @@ +package vaultcertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultCertificateResponse +} + +// Create ... +func (c VaultCertificatesClient) Create(ctx context.Context, id CertificateId, input CertificateRequest) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultCertificateResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_certificaterequest.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_certificaterequest.go new file mode 100644 index 00000000000..64984a9fb6e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_certificaterequest.go @@ -0,0 +1,8 @@ +package vaultcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateRequest struct { + Properties *RawCertificateData `json:"properties,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_rawcertificatedata.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_rawcertificatedata.go new file mode 100644 index 00000000000..2b6657d3813 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_rawcertificatedata.go @@ -0,0 +1,9 @@ +package vaultcertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RawCertificateData struct { + AuthType *AuthType `json:"authType,omitempty"` + Certificate *string `json:"certificate,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandaaddetails.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandaaddetails.go new file mode 100644 index 00000000000..59f9a303924 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandaaddetails.go @@ -0,0 +1,82 @@ +package vaultcertificates + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResourceCertificateDetails = ResourceCertificateAndAadDetails{} + +type ResourceCertificateAndAadDetails struct { + AadAudience *string `json:"aadAudience,omitempty"` + AadAuthority string `json:"aadAuthority"` + AadTenantId string `json:"aadTenantId"` + AzureManagementEndpointAudience string `json:"azureManagementEndpointAudience"` + ServicePrincipalClientId string `json:"servicePrincipalClientId"` + ServicePrincipalObjectId string `json:"servicePrincipalObjectId"` + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + + // Fields inherited from ResourceCertificateDetails + Certificate *string `json:"certificate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Issuer *string `json:"issuer,omitempty"` + ResourceId *int64 `json:"resourceId,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ValidFrom *string `json:"validFrom,omitempty"` + ValidTo *string `json:"validTo,omitempty"` +} + +func (o *ResourceCertificateAndAadDetails) GetValidFromAsTime() (*time.Time, error) { + if o.ValidFrom == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidFrom, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAadDetails) SetValidFromAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidFrom = &formatted +} + +func (o *ResourceCertificateAndAadDetails) GetValidToAsTime() (*time.Time, error) { + if o.ValidTo == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidTo, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAadDetails) SetValidToAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidTo = &formatted +} + +var _ json.Marshaler = ResourceCertificateAndAadDetails{} + +func (s ResourceCertificateAndAadDetails) MarshalJSON() ([]byte, error) { + type wrapper ResourceCertificateAndAadDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ResourceCertificateAndAadDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ResourceCertificateAndAadDetails: %+v", err) + } + decoded["authType"] = "AzureActiveDirectory" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ResourceCertificateAndAadDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandacsdetails.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandacsdetails.go new file mode 100644 index 00000000000..f0a2484e123 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificateandacsdetails.go @@ -0,0 +1,78 @@ +package vaultcertificates + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ResourceCertificateDetails = ResourceCertificateAndAcsDetails{} + +type ResourceCertificateAndAcsDetails struct { + GlobalAcsHostName string `json:"globalAcsHostName"` + GlobalAcsNamespace string `json:"globalAcsNamespace"` + GlobalAcsRPRealm string `json:"globalAcsRPRealm"` + + // Fields inherited from ResourceCertificateDetails + Certificate *string `json:"certificate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + Issuer *string `json:"issuer,omitempty"` + ResourceId *int64 `json:"resourceId,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ValidFrom *string `json:"validFrom,omitempty"` + ValidTo *string `json:"validTo,omitempty"` +} + +func (o *ResourceCertificateAndAcsDetails) GetValidFromAsTime() (*time.Time, error) { + if o.ValidFrom == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidFrom, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAcsDetails) SetValidFromAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidFrom = &formatted +} + +func (o *ResourceCertificateAndAcsDetails) GetValidToAsTime() (*time.Time, error) { + if o.ValidTo == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ValidTo, "2006-01-02T15:04:05Z07:00") +} + +func (o *ResourceCertificateAndAcsDetails) SetValidToAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ValidTo = &formatted +} + +var _ json.Marshaler = ResourceCertificateAndAcsDetails{} + +func (s ResourceCertificateAndAcsDetails) MarshalJSON() ([]byte, error) { + type wrapper ResourceCertificateAndAcsDetails + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ResourceCertificateAndAcsDetails: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ResourceCertificateAndAcsDetails: %+v", err) + } + decoded["authType"] = "AccessControlService" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ResourceCertificateAndAcsDetails: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificatedetails.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificatedetails.go new file mode 100644 index 00000000000..4057ff8ccdd --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_resourcecertificatedetails.go @@ -0,0 +1,61 @@ +package vaultcertificates + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceCertificateDetails interface { +} + +// RawResourceCertificateDetailsImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawResourceCertificateDetailsImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalResourceCertificateDetailsImplementation(input []byte) (ResourceCertificateDetails, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ResourceCertificateDetails into map[string]interface: %+v", err) + } + + value, ok := temp["authType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureActiveDirectory") { + var out ResourceCertificateAndAadDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ResourceCertificateAndAadDetails: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AccessControlService") { + var out ResourceCertificateAndAcsDetails + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ResourceCertificateAndAcsDetails: %+v", err) + } + return out, nil + } + + out := RawResourceCertificateDetailsImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_vaultcertificateresponse.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_vaultcertificateresponse.go new file mode 100644 index 00000000000..f5f8f52cf03 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/model_vaultcertificateresponse.go @@ -0,0 +1,44 @@ +package vaultcertificates + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultCertificateResponse struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ResourceCertificateDetails `json:"properties"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &VaultCertificateResponse{} + +func (s *VaultCertificateResponse) UnmarshalJSON(bytes []byte) error { + type alias VaultCertificateResponse + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into VaultCertificateResponse: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling VaultCertificateResponse into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalResourceCertificateDetailsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'VaultCertificateResponse': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultcertificates/version.go b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/version.go new file mode 100644 index 00000000000..1b2b2c0b44b --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultcertificates/version.go @@ -0,0 +1,12 @@ +package vaultcertificates + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/vaultcertificates/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/README.md b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/README.md new file mode 100644 index 00000000000..4c2701f1c73 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo` Documentation + +The `vaultextendedinfo` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo" +``` + + +### Client Initialization + +```go +client := vaultextendedinfo.NewVaultExtendedInfoClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultExtendedInfoClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := vaultextendedinfo.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := vaultextendedinfo.VaultExtendedInfoResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VaultExtendedInfoClient.Get` + +```go +ctx := context.TODO() +id := vaultextendedinfo.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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: `VaultExtendedInfoClient.Update` + +```go +ctx := context.TODO() +id := vaultextendedinfo.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := vaultextendedinfo.VaultExtendedInfoResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/client.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/client.go new file mode 100644 index 00000000000..d977cd83af4 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/client.go @@ -0,0 +1,26 @@ +package vaultextendedinfo + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultExtendedInfoClient struct { + Client *resourcemanager.Client +} + +func NewVaultExtendedInfoClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultExtendedInfoClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "vaultextendedinfo", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultExtendedInfoClient: %+v", err) + } + + return &VaultExtendedInfoClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/id_vault.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/id_vault.go new file mode 100644 index 00000000000..383129a1d1e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/id_vault.go @@ -0,0 +1,130 @@ +package vaultextendedinfo + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "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/recoveryservices/2024-04-01/vaultextendedinfo/id_vault_test.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/id_vault_test.go new file mode 100644 index 00000000000..cd8a330cad3 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/id_vault_test.go @@ -0,0 +1,282 @@ +package vaultextendedinfo + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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/recoveryservices/2024-04-01/vaultextendedinfo/method_createorupdate.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_createorupdate.go new file mode 100644 index 00000000000..46299e1c76a --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_createorupdate.go @@ -0,0 +1,59 @@ +package vaultextendedinfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultExtendedInfoResource +} + +// CreateOrUpdate ... +func (c VaultExtendedInfoClient) CreateOrUpdate(ctx context.Context, id VaultId, input VaultExtendedInfoResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extendedInformation/vaultExtendedInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultExtendedInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_get.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_get.go new file mode 100644 index 00000000000..63222675990 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_get.go @@ -0,0 +1,55 @@ +package vaultextendedinfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultExtendedInfoResource +} + +// Get ... +func (c VaultExtendedInfoClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extendedInformation/vaultExtendedInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultExtendedInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_update.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_update.go new file mode 100644 index 00000000000..74d9926995b --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/method_update.go @@ -0,0 +1,59 @@ +package vaultextendedinfo + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultExtendedInfoResource +} + +// Update ... +func (c VaultExtendedInfoClient) Update(ctx context.Context, id VaultId, input VaultExtendedInfoResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/extendedInformation/vaultExtendedInfo", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultExtendedInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinfo.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinfo.go new file mode 100644 index 00000000000..a1514fbe948 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinfo.go @@ -0,0 +1,11 @@ +package vaultextendedinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultExtendedInfo struct { + Algorithm *string `json:"algorithm,omitempty"` + EncryptionKey *string `json:"encryptionKey,omitempty"` + EncryptionKeyThumbprint *string `json:"encryptionKeyThumbprint,omitempty"` + IntegrityKey *string `json:"integrityKey,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinforesource.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinforesource.go new file mode 100644 index 00000000000..ee148aba996 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/model_vaultextendedinforesource.go @@ -0,0 +1,12 @@ +package vaultextendedinfo + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultExtendedInfoResource struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultExtendedInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/version.go b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/version.go new file mode 100644 index 00000000000..0fda634b732 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultextendedinfo/version.go @@ -0,0 +1,12 @@ +package vaultextendedinfo + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/vaultextendedinfo/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/README.md b/resource-manager/recoveryservices/2024-04-01/vaults/README.md new file mode 100644 index 00000000000..b9b3671f9a5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaults` Documentation + +The `vaults` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaults" +``` + + +### Client Initialization + +```go +client := vaults.NewVaultsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := vaults.Vault{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, vaults.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VaultsClient.Delete` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VaultsClient.Get` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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: `VaultsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VaultsClient.ListBySubscriptionId` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscriptionId(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionIdComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VaultsClient.Update` + +```go +ctx := context.TODO() +id := vaults.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := vaults.PatchVault{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload, vaults.DefaultUpdateOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/client.go b/resource-manager/recoveryservices/2024-04-01/vaults/client.go new file mode 100644 index 00000000000..1ddc5db936e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/client.go @@ -0,0 +1,26 @@ +package vaults + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultsClient struct { + Client *resourcemanager.Client +} + +func NewVaultsClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "vaults", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultsClient: %+v", err) + } + + return &VaultsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/constants.go b/resource-manager/recoveryservices/2024-04-01/vaults/constants.go new file mode 100644 index 00000000000..f9cf9b3216b --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/constants.go @@ -0,0 +1,958 @@ +package vaults + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AlertsState string + +const ( + AlertsStateDisabled AlertsState = "Disabled" + AlertsStateEnabled AlertsState = "Enabled" +) + +func PossibleValuesForAlertsState() []string { + return []string{ + string(AlertsStateDisabled), + string(AlertsStateEnabled), + } +} + +func (s *AlertsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAlertsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAlertsState(input string) (*AlertsState, error) { + vals := map[string]AlertsState{ + "disabled": AlertsStateDisabled, + "enabled": AlertsStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AlertsState(input) + return &out, nil +} + +type BCDRSecurityLevel string + +const ( + BCDRSecurityLevelExcellent BCDRSecurityLevel = "Excellent" + BCDRSecurityLevelFair BCDRSecurityLevel = "Fair" + BCDRSecurityLevelGood BCDRSecurityLevel = "Good" + BCDRSecurityLevelPoor BCDRSecurityLevel = "Poor" +) + +func PossibleValuesForBCDRSecurityLevel() []string { + return []string{ + string(BCDRSecurityLevelExcellent), + string(BCDRSecurityLevelFair), + string(BCDRSecurityLevelGood), + string(BCDRSecurityLevelPoor), + } +} + +func (s *BCDRSecurityLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBCDRSecurityLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBCDRSecurityLevel(input string) (*BCDRSecurityLevel, error) { + vals := map[string]BCDRSecurityLevel{ + "excellent": BCDRSecurityLevelExcellent, + "fair": BCDRSecurityLevelFair, + "good": BCDRSecurityLevelGood, + "poor": BCDRSecurityLevelPoor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BCDRSecurityLevel(input) + return &out, nil +} + +type BackupStorageVersion string + +const ( + BackupStorageVersionUnassigned BackupStorageVersion = "Unassigned" + BackupStorageVersionVOne BackupStorageVersion = "V1" + BackupStorageVersionVTwo BackupStorageVersion = "V2" +) + +func PossibleValuesForBackupStorageVersion() []string { + return []string{ + string(BackupStorageVersionUnassigned), + string(BackupStorageVersionVOne), + string(BackupStorageVersionVTwo), + } +} + +func (s *BackupStorageVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupStorageVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupStorageVersion(input string) (*BackupStorageVersion, error) { + vals := map[string]BackupStorageVersion{ + "unassigned": BackupStorageVersionUnassigned, + "v1": BackupStorageVersionVOne, + "v2": BackupStorageVersionVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupStorageVersion(input) + return &out, nil +} + +type CrossRegionRestore string + +const ( + CrossRegionRestoreDisabled CrossRegionRestore = "Disabled" + CrossRegionRestoreEnabled CrossRegionRestore = "Enabled" +) + +func PossibleValuesForCrossRegionRestore() []string { + return []string{ + string(CrossRegionRestoreDisabled), + string(CrossRegionRestoreEnabled), + } +} + +func (s *CrossRegionRestore) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCrossRegionRestore(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCrossRegionRestore(input string) (*CrossRegionRestore, error) { + vals := map[string]CrossRegionRestore{ + "disabled": CrossRegionRestoreDisabled, + "enabled": CrossRegionRestoreEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CrossRegionRestore(input) + return &out, nil +} + +type CrossSubscriptionRestoreState string + +const ( + CrossSubscriptionRestoreStateDisabled CrossSubscriptionRestoreState = "Disabled" + CrossSubscriptionRestoreStateEnabled CrossSubscriptionRestoreState = "Enabled" + CrossSubscriptionRestoreStatePermanentlyDisabled CrossSubscriptionRestoreState = "PermanentlyDisabled" +) + +func PossibleValuesForCrossSubscriptionRestoreState() []string { + return []string{ + string(CrossSubscriptionRestoreStateDisabled), + string(CrossSubscriptionRestoreStateEnabled), + string(CrossSubscriptionRestoreStatePermanentlyDisabled), + } +} + +func (s *CrossSubscriptionRestoreState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCrossSubscriptionRestoreState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCrossSubscriptionRestoreState(input string) (*CrossSubscriptionRestoreState, error) { + vals := map[string]CrossSubscriptionRestoreState{ + "disabled": CrossSubscriptionRestoreStateDisabled, + "enabled": CrossSubscriptionRestoreStateEnabled, + "permanentlydisabled": CrossSubscriptionRestoreStatePermanentlyDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CrossSubscriptionRestoreState(input) + return &out, nil +} + +type EnhancedSecurityState string + +const ( + EnhancedSecurityStateAlwaysON EnhancedSecurityState = "AlwaysON" + EnhancedSecurityStateDisabled EnhancedSecurityState = "Disabled" + EnhancedSecurityStateEnabled EnhancedSecurityState = "Enabled" + EnhancedSecurityStateInvalid EnhancedSecurityState = "Invalid" +) + +func PossibleValuesForEnhancedSecurityState() []string { + return []string{ + string(EnhancedSecurityStateAlwaysON), + string(EnhancedSecurityStateDisabled), + string(EnhancedSecurityStateEnabled), + string(EnhancedSecurityStateInvalid), + } +} + +func (s *EnhancedSecurityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnhancedSecurityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnhancedSecurityState(input string) (*EnhancedSecurityState, error) { + vals := map[string]EnhancedSecurityState{ + "alwayson": EnhancedSecurityStateAlwaysON, + "disabled": EnhancedSecurityStateDisabled, + "enabled": EnhancedSecurityStateEnabled, + "invalid": EnhancedSecurityStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnhancedSecurityState(input) + return &out, nil +} + +type ImmutabilityState string + +const ( + ImmutabilityStateDisabled ImmutabilityState = "Disabled" + ImmutabilityStateLocked ImmutabilityState = "Locked" + ImmutabilityStateUnlocked ImmutabilityState = "Unlocked" +) + +func PossibleValuesForImmutabilityState() []string { + return []string{ + string(ImmutabilityStateDisabled), + string(ImmutabilityStateLocked), + string(ImmutabilityStateUnlocked), + } +} + +func (s *ImmutabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImmutabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseImmutabilityState(input string) (*ImmutabilityState, error) { + vals := map[string]ImmutabilityState{ + "disabled": ImmutabilityStateDisabled, + "locked": ImmutabilityStateLocked, + "unlocked": ImmutabilityStateUnlocked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ImmutabilityState(input) + return &out, nil +} + +type InfrastructureEncryptionState string + +const ( + InfrastructureEncryptionStateDisabled InfrastructureEncryptionState = "Disabled" + InfrastructureEncryptionStateEnabled InfrastructureEncryptionState = "Enabled" +) + +func PossibleValuesForInfrastructureEncryptionState() []string { + return []string{ + string(InfrastructureEncryptionStateDisabled), + string(InfrastructureEncryptionStateEnabled), + } +} + +func (s *InfrastructureEncryptionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInfrastructureEncryptionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInfrastructureEncryptionState(input string) (*InfrastructureEncryptionState, error) { + vals := map[string]InfrastructureEncryptionState{ + "disabled": InfrastructureEncryptionStateDisabled, + "enabled": InfrastructureEncryptionStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InfrastructureEncryptionState(input) + return &out, nil +} + +type MultiUserAuthorization string + +const ( + MultiUserAuthorizationDisabled MultiUserAuthorization = "Disabled" + MultiUserAuthorizationEnabled MultiUserAuthorization = "Enabled" + MultiUserAuthorizationInvalid MultiUserAuthorization = "Invalid" +) + +func PossibleValuesForMultiUserAuthorization() []string { + return []string{ + string(MultiUserAuthorizationDisabled), + string(MultiUserAuthorizationEnabled), + string(MultiUserAuthorizationInvalid), + } +} + +func (s *MultiUserAuthorization) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMultiUserAuthorization(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMultiUserAuthorization(input string) (*MultiUserAuthorization, error) { + vals := map[string]MultiUserAuthorization{ + "disabled": MultiUserAuthorizationDisabled, + "enabled": MultiUserAuthorizationEnabled, + "invalid": MultiUserAuthorizationInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MultiUserAuthorization(input) + return &out, nil +} + +type PrivateEndpointConnectionStatus string + +const ( + PrivateEndpointConnectionStatusApproved PrivateEndpointConnectionStatus = "Approved" + PrivateEndpointConnectionStatusDisconnected PrivateEndpointConnectionStatus = "Disconnected" + PrivateEndpointConnectionStatusPending PrivateEndpointConnectionStatus = "Pending" + PrivateEndpointConnectionStatusRejected PrivateEndpointConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointConnectionStatus() []string { + return []string{ + string(PrivateEndpointConnectionStatusApproved), + string(PrivateEndpointConnectionStatusDisconnected), + string(PrivateEndpointConnectionStatusPending), + string(PrivateEndpointConnectionStatusRejected), + } +} + +func (s *PrivateEndpointConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionStatus(input string) (*PrivateEndpointConnectionStatus, error) { + vals := map[string]PrivateEndpointConnectionStatus{ + "approved": PrivateEndpointConnectionStatusApproved, + "disconnected": PrivateEndpointConnectionStatusDisconnected, + "pending": PrivateEndpointConnectionStatusPending, + "rejected": PrivateEndpointConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStatePending ProvisioningState = "Pending" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStatePending), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "pending": ProvisioningStatePending, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type ResourceMoveState string + +const ( + ResourceMoveStateCommitFailed ResourceMoveState = "CommitFailed" + ResourceMoveStateCommitTimedout ResourceMoveState = "CommitTimedout" + ResourceMoveStateCriticalFailure ResourceMoveState = "CriticalFailure" + ResourceMoveStateFailure ResourceMoveState = "Failure" + ResourceMoveStateInProgress ResourceMoveState = "InProgress" + ResourceMoveStateMoveSucceeded ResourceMoveState = "MoveSucceeded" + ResourceMoveStatePartialSuccess ResourceMoveState = "PartialSuccess" + ResourceMoveStatePrepareFailed ResourceMoveState = "PrepareFailed" + ResourceMoveStatePrepareTimedout ResourceMoveState = "PrepareTimedout" + ResourceMoveStateUnknown ResourceMoveState = "Unknown" +) + +func PossibleValuesForResourceMoveState() []string { + return []string{ + string(ResourceMoveStateCommitFailed), + string(ResourceMoveStateCommitTimedout), + string(ResourceMoveStateCriticalFailure), + string(ResourceMoveStateFailure), + string(ResourceMoveStateInProgress), + string(ResourceMoveStateMoveSucceeded), + string(ResourceMoveStatePartialSuccess), + string(ResourceMoveStatePrepareFailed), + string(ResourceMoveStatePrepareTimedout), + string(ResourceMoveStateUnknown), + } +} + +func (s *ResourceMoveState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceMoveState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceMoveState(input string) (*ResourceMoveState, error) { + vals := map[string]ResourceMoveState{ + "commitfailed": ResourceMoveStateCommitFailed, + "committimedout": ResourceMoveStateCommitTimedout, + "criticalfailure": ResourceMoveStateCriticalFailure, + "failure": ResourceMoveStateFailure, + "inprogress": ResourceMoveStateInProgress, + "movesucceeded": ResourceMoveStateMoveSucceeded, + "partialsuccess": ResourceMoveStatePartialSuccess, + "preparefailed": ResourceMoveStatePrepareFailed, + "preparetimedout": ResourceMoveStatePrepareTimedout, + "unknown": ResourceMoveStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceMoveState(input) + return &out, nil +} + +type SecureScoreLevel string + +const ( + SecureScoreLevelAdequate SecureScoreLevel = "Adequate" + SecureScoreLevelMaximum SecureScoreLevel = "Maximum" + SecureScoreLevelMinimum SecureScoreLevel = "Minimum" + SecureScoreLevelNone SecureScoreLevel = "None" +) + +func PossibleValuesForSecureScoreLevel() []string { + return []string{ + string(SecureScoreLevelAdequate), + string(SecureScoreLevelMaximum), + string(SecureScoreLevelMinimum), + string(SecureScoreLevelNone), + } +} + +func (s *SecureScoreLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecureScoreLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecureScoreLevel(input string) (*SecureScoreLevel, error) { + vals := map[string]SecureScoreLevel{ + "adequate": SecureScoreLevelAdequate, + "maximum": SecureScoreLevelMaximum, + "minimum": SecureScoreLevelMinimum, + "none": SecureScoreLevelNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecureScoreLevel(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameRSZero SkuName = "RS0" + SkuNameStandard SkuName = "Standard" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameRSZero), + string(SkuNameStandard), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "rs0": SkuNameRSZero, + "standard": SkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type SoftDeleteState string + +const ( + SoftDeleteStateAlwaysON SoftDeleteState = "AlwaysON" + SoftDeleteStateDisabled SoftDeleteState = "Disabled" + SoftDeleteStateEnabled SoftDeleteState = "Enabled" + SoftDeleteStateInvalid SoftDeleteState = "Invalid" +) + +func PossibleValuesForSoftDeleteState() []string { + return []string{ + string(SoftDeleteStateAlwaysON), + string(SoftDeleteStateDisabled), + string(SoftDeleteStateEnabled), + string(SoftDeleteStateInvalid), + } +} + +func (s *SoftDeleteState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSoftDeleteState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSoftDeleteState(input string) (*SoftDeleteState, error) { + vals := map[string]SoftDeleteState{ + "alwayson": SoftDeleteStateAlwaysON, + "disabled": SoftDeleteStateDisabled, + "enabled": SoftDeleteStateEnabled, + "invalid": SoftDeleteStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SoftDeleteState(input) + return &out, nil +} + +type StandardTierStorageRedundancy string + +const ( + StandardTierStorageRedundancyGeoRedundant StandardTierStorageRedundancy = "GeoRedundant" + StandardTierStorageRedundancyInvalid StandardTierStorageRedundancy = "Invalid" + StandardTierStorageRedundancyLocallyRedundant StandardTierStorageRedundancy = "LocallyRedundant" + StandardTierStorageRedundancyZoneRedundant StandardTierStorageRedundancy = "ZoneRedundant" +) + +func PossibleValuesForStandardTierStorageRedundancy() []string { + return []string{ + string(StandardTierStorageRedundancyGeoRedundant), + string(StandardTierStorageRedundancyInvalid), + string(StandardTierStorageRedundancyLocallyRedundant), + string(StandardTierStorageRedundancyZoneRedundant), + } +} + +func (s *StandardTierStorageRedundancy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStandardTierStorageRedundancy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStandardTierStorageRedundancy(input string) (*StandardTierStorageRedundancy, error) { + vals := map[string]StandardTierStorageRedundancy{ + "georedundant": StandardTierStorageRedundancyGeoRedundant, + "invalid": StandardTierStorageRedundancyInvalid, + "locallyredundant": StandardTierStorageRedundancyLocallyRedundant, + "zoneredundant": StandardTierStorageRedundancyZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StandardTierStorageRedundancy(input) + return &out, nil +} + +type TriggerType string + +const ( + TriggerTypeForcedUpgrade TriggerType = "ForcedUpgrade" + TriggerTypeUserTriggered TriggerType = "UserTriggered" +) + +func PossibleValuesForTriggerType() []string { + return []string{ + string(TriggerTypeForcedUpgrade), + string(TriggerTypeUserTriggered), + } +} + +func (s *TriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerType(input string) (*TriggerType, error) { + vals := map[string]TriggerType{ + "forcedupgrade": TriggerTypeForcedUpgrade, + "usertriggered": TriggerTypeUserTriggered, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerType(input) + return &out, nil +} + +type VaultPrivateEndpointState string + +const ( + VaultPrivateEndpointStateEnabled VaultPrivateEndpointState = "Enabled" + VaultPrivateEndpointStateNone VaultPrivateEndpointState = "None" +) + +func PossibleValuesForVaultPrivateEndpointState() []string { + return []string{ + string(VaultPrivateEndpointStateEnabled), + string(VaultPrivateEndpointStateNone), + } +} + +func (s *VaultPrivateEndpointState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultPrivateEndpointState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultPrivateEndpointState(input string) (*VaultPrivateEndpointState, error) { + vals := map[string]VaultPrivateEndpointState{ + "enabled": VaultPrivateEndpointStateEnabled, + "none": VaultPrivateEndpointStateNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultPrivateEndpointState(input) + return &out, nil +} + +type VaultSubResourceType string + +const ( + VaultSubResourceTypeAzureBackup VaultSubResourceType = "AzureBackup" + VaultSubResourceTypeAzureBackupSecondary VaultSubResourceType = "AzureBackup_secondary" + VaultSubResourceTypeAzureSiteRecovery VaultSubResourceType = "AzureSiteRecovery" +) + +func PossibleValuesForVaultSubResourceType() []string { + return []string{ + string(VaultSubResourceTypeAzureBackup), + string(VaultSubResourceTypeAzureBackupSecondary), + string(VaultSubResourceTypeAzureSiteRecovery), + } +} + +func (s *VaultSubResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultSubResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultSubResourceType(input string) (*VaultSubResourceType, error) { + vals := map[string]VaultSubResourceType{ + "azurebackup": VaultSubResourceTypeAzureBackup, + "azurebackup_secondary": VaultSubResourceTypeAzureBackupSecondary, + "azuresiterecovery": VaultSubResourceTypeAzureSiteRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultSubResourceType(input) + return &out, nil +} + +type VaultUpgradeState string + +const ( + VaultUpgradeStateFailed VaultUpgradeState = "Failed" + VaultUpgradeStateInProgress VaultUpgradeState = "InProgress" + VaultUpgradeStateUnknown VaultUpgradeState = "Unknown" + VaultUpgradeStateUpgraded VaultUpgradeState = "Upgraded" +) + +func PossibleValuesForVaultUpgradeState() []string { + return []string{ + string(VaultUpgradeStateFailed), + string(VaultUpgradeStateInProgress), + string(VaultUpgradeStateUnknown), + string(VaultUpgradeStateUpgraded), + } +} + +func (s *VaultUpgradeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVaultUpgradeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVaultUpgradeState(input string) (*VaultUpgradeState, error) { + vals := map[string]VaultUpgradeState{ + "failed": VaultUpgradeStateFailed, + "inprogress": VaultUpgradeStateInProgress, + "unknown": VaultUpgradeStateUnknown, + "upgraded": VaultUpgradeStateUpgraded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultUpgradeState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/id_vault.go b/resource-manager/recoveryservices/2024-04-01/vaults/id_vault.go new file mode 100644 index 00000000000..1cb6def7087 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/id_vault.go @@ -0,0 +1,130 @@ +package vaults + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "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/recoveryservices/2024-04-01/vaults/id_vault_test.go b/resource-manager/recoveryservices/2024-04-01/vaults/id_vault_test.go new file mode 100644 index 00000000000..d99d7310acc --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/id_vault_test.go @@ -0,0 +1,282 @@ +package vaults + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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/recoveryservices/2024-04-01/vaults/method_createorupdate.go b/resource-manager/recoveryservices/2024-04-01/vaults/method_createorupdate.go new file mode 100644 index 00000000000..8e33ddb554d --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/method_createorupdate.go @@ -0,0 +1,103 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c VaultsClient) CreateOrUpdate(ctx context.Context, id VaultId, input Vault, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VaultsClient) CreateOrUpdateThenPoll(ctx context.Context, id VaultId, input Vault, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/method_delete.go b/resource-manager/recoveryservices/2024-04-01/vaults/method_delete.go new file mode 100644 index 00000000000..2b8f5be41af --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/method_delete.go @@ -0,0 +1,70 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VaultsClient) Delete(ctx context.Context, id VaultId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VaultsClient) DeleteThenPoll(ctx context.Context, id VaultId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/method_get.go b/resource-manager/recoveryservices/2024-04-01/vaults/method_get.go new file mode 100644 index 00000000000..181926c5390 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/method_get.go @@ -0,0 +1,54 @@ +package vaults + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +// Get ... +func (c VaultsClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Vault + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/method_listbyresourcegroup.go b/resource-manager/recoveryservices/2024-04-01/vaults/method_listbyresourcegroup.go new file mode 100644 index 00000000000..09ba434e931 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Vault +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Vault +} + +// ListByResourceGroup ... +func (c VaultsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/vaults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Vault `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c VaultsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, VaultOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VaultOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Vault, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/method_listbysubscriptionid.go b/resource-manager/recoveryservices/2024-04-01/vaults/method_listbysubscriptionid.go new file mode 100644 index 00000000000..e1f63694b10 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/method_listbysubscriptionid.go @@ -0,0 +1,92 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Vault +} + +type ListBySubscriptionIdCompleteResult struct { + LatestHttpResponse *http.Response + Items []Vault +} + +// ListBySubscriptionId ... +func (c VaultsClient) ListBySubscriptionId(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.RecoveryServices/vaults", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Vault `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionIdComplete retrieves all the results into a single object +func (c VaultsClient) ListBySubscriptionIdComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionIdCompleteResult, error) { + return c.ListBySubscriptionIdCompleteMatchingPredicate(ctx, id, VaultOperationPredicate{}) +} + +// ListBySubscriptionIdCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VaultsClient) ListBySubscriptionIdCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VaultOperationPredicate) (result ListBySubscriptionIdCompleteResult, err error) { + items := make([]Vault, 0) + + resp, err := c.ListBySubscriptionId(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionIdCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/method_update.go b/resource-manager/recoveryservices/2024-04-01/vaults/method_update.go new file mode 100644 index 00000000000..c14ddaa07fb --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/method_update.go @@ -0,0 +1,103 @@ +package vaults + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Vault +} + +type UpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.XMsAuthorizationAuxiliary != nil { + out.Append("x-ms-authorization-auxiliary", fmt.Sprintf("%v", *o.XMsAuthorizationAuxiliary)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c VaultsClient) Update(ctx context.Context, id VaultId, input PatchVault, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c VaultsClient) UpdateThenPoll(ctx context.Context, id VaultId, input PatchVault, options UpdateOperationOptions) error { + result, err := c.Update(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_azuremonitoralertsettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_azuremonitoralertsettings.go new file mode 100644 index 00000000000..3f36e0be907 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_azuremonitoralertsettings.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureMonitorAlertSettings struct { + AlertsForAllFailoverIssues *AlertsState `json:"alertsForAllFailoverIssues,omitempty"` + AlertsForAllJobFailures *AlertsState `json:"alertsForAllJobFailures,omitempty"` + AlertsForAllReplicationIssues *AlertsState `json:"alertsForAllReplicationIssues,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_classicalertsettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_classicalertsettings.go new file mode 100644 index 00000000000..bf08cd1a80e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_classicalertsettings.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClassicAlertSettings struct { + AlertsForCriticalOperations *AlertsState `json:"alertsForCriticalOperations,omitempty"` + EmailNotificationsForSiteRecovery *AlertsState `json:"emailNotificationsForSiteRecovery,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkekidentity.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkekidentity.go new file mode 100644 index 00000000000..1e5e7be3d2d --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkekidentity.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkKekIdentity struct { + UseSystemAssignedIdentity *bool `json:"useSystemAssignedIdentity,omitempty"` + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkeyvaultproperties.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkeyvaultproperties.go new file mode 100644 index 00000000000..c53f530b9f5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_cmkkeyvaultproperties.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CmkKeyVaultProperties struct { + KeyUri *string `json:"keyUri,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_crosssubscriptionrestoresettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_crosssubscriptionrestoresettings.go new file mode 100644 index 00000000000..4a4fecb8bdd --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_crosssubscriptionrestoresettings.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossSubscriptionRestoreSettings struct { + CrossSubscriptionRestoreState *CrossSubscriptionRestoreState `json:"crossSubscriptionRestoreState,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_immutabilitysettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_immutabilitysettings.go new file mode 100644 index 00000000000..f52ae97a4c3 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_immutabilitysettings.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImmutabilitySettings struct { + State *ImmutabilityState `json:"state,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_monitoringsettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_monitoringsettings.go new file mode 100644 index 00000000000..391ede46ae2 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_monitoringsettings.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringSettings struct { + AzureMonitorAlertSettings *AzureMonitorAlertSettings `json:"azureMonitorAlertSettings,omitempty"` + ClassicAlertSettings *ClassicAlertSettings `json:"classicAlertSettings,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_patchvault.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_patchvault.go new file mode 100644 index 00000000000..5ffc9615bc5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_patchvault.go @@ -0,0 +1,20 @@ +package vaults + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchVault struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VaultProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpoint.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpoint.go new file mode 100644 index 00000000000..64ce35a3d98 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpoint.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnection.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnection.go new file mode 100644 index 00000000000..687aefc111c --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + GroupIds *[]VaultSubResourceType `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnectionvaultproperties.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnectionvaultproperties.go new file mode 100644 index 00000000000..5758db1bfa3 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_privateendpointconnectionvaultproperties.go @@ -0,0 +1,12 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionVaultProperties struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnection `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_privatelinkserviceconnectionstate.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..b07724e0e27 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_restoresettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_restoresettings.go new file mode 100644 index 00000000000..b5126dbe263 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_restoresettings.go @@ -0,0 +1,8 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreSettings struct { + CrossSubscriptionRestoreSettings *CrossSubscriptionRestoreSettings `json:"crossSubscriptionRestoreSettings,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_securitysettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_securitysettings.go new file mode 100644 index 00000000000..b5c9821e944 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_securitysettings.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuritySettings struct { + ImmutabilitySettings *ImmutabilitySettings `json:"immutabilitySettings,omitempty"` + MultiUserAuthorization *MultiUserAuthorization `json:"multiUserAuthorization,omitempty"` + SoftDeleteSettings *SoftDeleteSettings `json:"softDeleteSettings,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_sku.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_sku.go new file mode 100644 index 00000000000..d89e1340ee6 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_sku.go @@ -0,0 +1,12 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *string `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name SkuName `json:"name"` + Size *string `json:"size,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_softdeletesettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_softdeletesettings.go new file mode 100644 index 00000000000..fb257ac28c7 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_softdeletesettings.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SoftDeleteSettings struct { + EnhancedSecurityState *EnhancedSecurityState `json:"enhancedSecurityState,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SoftDeleteState *SoftDeleteState `json:"softDeleteState,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_upgradedetails.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_upgradedetails.go new file mode 100644 index 00000000000..f5e021983ab --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_upgradedetails.go @@ -0,0 +1,58 @@ +package vaults + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeDetails struct { + EndTimeUtc *string `json:"endTimeUtc,omitempty"` + LastUpdatedTimeUtc *string `json:"lastUpdatedTimeUtc,omitempty"` + Message *string `json:"message,omitempty"` + OperationId *string `json:"operationId,omitempty"` + PreviousResourceId *string `json:"previousResourceId,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + Status *VaultUpgradeState `json:"status,omitempty"` + TriggerType *TriggerType `json:"triggerType,omitempty"` + UpgradedResourceId *string `json:"upgradedResourceId,omitempty"` +} + +func (o *UpgradeDetails) GetEndTimeUtcAsTime() (*time.Time, error) { + if o.EndTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeDetails) SetEndTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTimeUtc = &formatted +} + +func (o *UpgradeDetails) GetLastUpdatedTimeUtcAsTime() (*time.Time, error) { + if o.LastUpdatedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeDetails) SetLastUpdatedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedTimeUtc = &formatted +} + +func (o *UpgradeDetails) GetStartTimeUtcAsTime() (*time.Time, error) { + if o.StartTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeDetails) SetStartTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_vault.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_vault.go new file mode 100644 index 00000000000..dc5d7d049c1 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_vault.go @@ -0,0 +1,22 @@ +package vaults + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Vault struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *VaultProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultproperties.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultproperties.go new file mode 100644 index 00000000000..5942dc4f409 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultproperties.go @@ -0,0 +1,24 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultProperties struct { + BackupStorageVersion *BackupStorageVersion `json:"backupStorageVersion,omitempty"` + BcdrSecurityLevel *BCDRSecurityLevel `json:"bcdrSecurityLevel,omitempty"` + Encryption *VaultPropertiesEncryption `json:"encryption,omitempty"` + MonitoringSettings *MonitoringSettings `json:"monitoringSettings,omitempty"` + MoveDetails *VaultPropertiesMoveDetails `json:"moveDetails,omitempty"` + MoveState *ResourceMoveState `json:"moveState,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnectionVaultProperties `json:"privateEndpointConnections,omitempty"` + PrivateEndpointStateForBackup *VaultPrivateEndpointState `json:"privateEndpointStateForBackup,omitempty"` + PrivateEndpointStateForSiteRecovery *VaultPrivateEndpointState `json:"privateEndpointStateForSiteRecovery,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + RedundancySettings *VaultPropertiesRedundancySettings `json:"redundancySettings,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + RestoreSettings *RestoreSettings `json:"restoreSettings,omitempty"` + SecureScore *SecureScoreLevel `json:"secureScore,omitempty"` + SecuritySettings *SecuritySettings `json:"securitySettings,omitempty"` + UpgradeDetails *UpgradeDetails `json:"upgradeDetails,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesencryption.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesencryption.go new file mode 100644 index 00000000000..05c6effec1d --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesencryption.go @@ -0,0 +1,10 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultPropertiesEncryption struct { + InfrastructureEncryption *InfrastructureEncryptionState `json:"infrastructureEncryption,omitempty"` + KekIdentity *CmkKekIdentity `json:"kekIdentity,omitempty"` + KeyVaultProperties *CmkKeyVaultProperties `json:"keyVaultProperties,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesmovedetails.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesmovedetails.go new file mode 100644 index 00000000000..b65be5a0669 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesmovedetails.go @@ -0,0 +1,42 @@ +package vaults + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultPropertiesMoveDetails struct { + CompletionTimeUtc *string `json:"completionTimeUtc,omitempty"` + OperationId *string `json:"operationId,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} + +func (o *VaultPropertiesMoveDetails) GetCompletionTimeUtcAsTime() (*time.Time, error) { + if o.CompletionTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CompletionTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultPropertiesMoveDetails) SetCompletionTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CompletionTimeUtc = &formatted +} + +func (o *VaultPropertiesMoveDetails) GetStartTimeUtcAsTime() (*time.Time, error) { + if o.StartTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultPropertiesMoveDetails) SetStartTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeUtc = &formatted +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesredundancysettings.go b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesredundancysettings.go new file mode 100644 index 00000000000..2d1174f221f --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/model_vaultpropertiesredundancysettings.go @@ -0,0 +1,9 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultPropertiesRedundancySettings struct { + CrossRegionRestore *CrossRegionRestore `json:"crossRegionRestore,omitempty"` + StandardTierStorageRedundancy *StandardTierStorageRedundancy `json:"standardTierStorageRedundancy,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/predicates.go b/resource-manager/recoveryservices/2024-04-01/vaults/predicates.go new file mode 100644 index 00000000000..1039a9afe4e --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/predicates.go @@ -0,0 +1,37 @@ +package vaults + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VaultOperationPredicate) Matches(input Vault) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaults/version.go b/resource-manager/recoveryservices/2024-04-01/vaults/version.go new file mode 100644 index 00000000000..4c95299dd5c --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaults/version.go @@ -0,0 +1,12 @@ +package vaults + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/vaults/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/README.md b/resource-manager/recoveryservices/2024-04-01/vaultusages/README.md new file mode 100644 index 00000000000..e6f3425f6c4 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultusages` Documentation + +The `vaultusages` SDK allows for interaction with the Azure Resource Manager Service `recoveryservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservices/2024-04-01/vaultusages" +``` + + +### Client Initialization + +```go +client := vaultusages.NewVaultUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VaultUsagesClient.UsagesListByVaults` + +```go +ctx := context.TODO() +id := vaultusages.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +read, err := client.UsagesListByVaults(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/client.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/client.go new file mode 100644 index 00000000000..625eba65044 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/client.go @@ -0,0 +1,26 @@ +package vaultusages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultUsagesClient struct { + Client *resourcemanager.Client +} + +func NewVaultUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*VaultUsagesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "vaultusages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VaultUsagesClient: %+v", err) + } + + return &VaultUsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/constants.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/constants.go new file mode 100644 index 00000000000..333eba1e6c6 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/constants.go @@ -0,0 +1,63 @@ +package vaultusages + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesUnit string + +const ( + UsagesUnitBytes UsagesUnit = "Bytes" + UsagesUnitBytesPerSecond UsagesUnit = "BytesPerSecond" + UsagesUnitCount UsagesUnit = "Count" + UsagesUnitCountPerSecond UsagesUnit = "CountPerSecond" + UsagesUnitPercent UsagesUnit = "Percent" + UsagesUnitSeconds UsagesUnit = "Seconds" +) + +func PossibleValuesForUsagesUnit() []string { + return []string{ + string(UsagesUnitBytes), + string(UsagesUnitBytesPerSecond), + string(UsagesUnitCount), + string(UsagesUnitCountPerSecond), + string(UsagesUnitPercent), + string(UsagesUnitSeconds), + } +} + +func (s *UsagesUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsagesUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsagesUnit(input string) (*UsagesUnit, error) { + vals := map[string]UsagesUnit{ + "bytes": UsagesUnitBytes, + "bytespersecond": UsagesUnitBytesPerSecond, + "count": UsagesUnitCount, + "countpersecond": UsagesUnitCountPerSecond, + "percent": UsagesUnitPercent, + "seconds": UsagesUnitSeconds, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsagesUnit(input) + return &out, nil +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/id_vault.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/id_vault.go new file mode 100644 index 00000000000..b455e8760a5 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/id_vault.go @@ -0,0 +1,130 @@ +package vaultusages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "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/recoveryservices/2024-04-01/vaultusages/id_vault_test.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/id_vault_test.go new file mode 100644 index 00000000000..9ef11c18ec0 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/id_vault_test.go @@ -0,0 +1,282 @@ +package vaultusages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "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/recoveryservices/2024-04-01/vaultusages/method_usageslistbyvaults.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/method_usageslistbyvaults.go new file mode 100644 index 00000000000..258a5d0bb75 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/method_usageslistbyvaults.go @@ -0,0 +1,55 @@ +package vaultusages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesListByVaultsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VaultUsageList +} + +// UsagesListByVaults ... +func (c VaultUsagesClient) UsagesListByVaults(ctx context.Context, id VaultId) (result UsagesListByVaultsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VaultUsageList + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/model_nameinfo.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/model_nameinfo.go new file mode 100644 index 00000000000..974668c26f9 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/model_nameinfo.go @@ -0,0 +1,9 @@ +package vaultusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameInfo struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusage.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusage.go new file mode 100644 index 00000000000..6b7bc2b68d8 --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusage.go @@ -0,0 +1,31 @@ +package vaultusages + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *NameInfo `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *UsagesUnit `json:"unit,omitempty"` +} + +func (o *VaultUsage) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultUsage) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusagelist.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusagelist.go new file mode 100644 index 00000000000..aa529e6fcbf --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/model_vaultusagelist.go @@ -0,0 +1,8 @@ +package vaultusages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultUsageList struct { + Value *[]VaultUsage `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservices/2024-04-01/vaultusages/version.go b/resource-manager/recoveryservices/2024-04-01/vaultusages/version.go new file mode 100644 index 00000000000..854fb2abffa --- /dev/null +++ b/resource-manager/recoveryservices/2024-04-01/vaultusages/version.go @@ -0,0 +1,12 @@ +package vaultusages + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/vaultusages/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/README.md new file mode 100644 index 00000000000..7f1d3714324 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupengines` Documentation + +The `backupengines` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupengines" +``` + + +### Client Initialization + +```go +client := backupengines.NewBackupEnginesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupEnginesClient.Get` + +```go +ctx := context.TODO() +id := backupengines.NewBackupEngineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupEngineValue") + +read, err := client.Get(ctx, id, backupengines.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupEnginesClient.List` + +```go +ctx := context.TODO() +id := backupengines.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupengines.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupengines.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/client.go new file mode 100644 index 00000000000..3f415af9d81 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/client.go @@ -0,0 +1,18 @@ +package backupengines + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupEnginesClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupEnginesClientWithBaseURI(endpoint string) BackupEnginesClient { + return BackupEnginesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/constants.go new file mode 100644 index 00000000000..0b1ec0205b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/constants.go @@ -0,0 +1,86 @@ +package backupengines + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupEngineType string + +const ( + BackupEngineTypeAzureBackupServerEngine BackupEngineType = "AzureBackupServerEngine" + BackupEngineTypeDpmBackupEngine BackupEngineType = "DpmBackupEngine" + BackupEngineTypeInvalid BackupEngineType = "Invalid" +) + +func PossibleValuesForBackupEngineType() []string { + return []string{ + string(BackupEngineTypeAzureBackupServerEngine), + string(BackupEngineTypeDpmBackupEngine), + string(BackupEngineTypeInvalid), + } +} + +func parseBackupEngineType(input string) (*BackupEngineType, error) { + vals := map[string]BackupEngineType{ + "azurebackupserverengine": BackupEngineTypeAzureBackupServerEngine, + "dpmbackupengine": BackupEngineTypeDpmBackupEngine, + "invalid": BackupEngineTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupEngineType(input) + return &out, nil +} + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine.go new file mode 100644 index 00000000000..2ccbb34b327 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine.go @@ -0,0 +1,139 @@ +package backupengines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupEngineId{}) +} + +var _ resourceids.ResourceId = &BackupEngineId{} + +// BackupEngineId is a struct representing the Resource ID for a Backup Engine +type BackupEngineId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupEngineName string +} + +// NewBackupEngineID returns a new BackupEngineId struct +func NewBackupEngineID(subscriptionId string, resourceGroupName string, vaultName string, backupEngineName string) BackupEngineId { + return BackupEngineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupEngineName: backupEngineName, + } +} + +// ParseBackupEngineID parses 'input' into a BackupEngineId +func ParseBackupEngineID(input string) (*BackupEngineId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupEngineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupEngineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupEngineIDInsensitively parses 'input' case-insensitively into a BackupEngineId +// note: this method should only be used for API response data and not user input +func ParseBackupEngineIDInsensitively(input string) (*BackupEngineId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupEngineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupEngineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupEngineId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupEngineName, ok = input.Parsed["backupEngineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupEngineName", input) + } + + return nil +} + +// ValidateBackupEngineID checks that 'input' can be parsed as a Backup Engine ID +func ValidateBackupEngineID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupEngineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Engine ID +func (id BackupEngineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupEngines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupEngineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Engine ID +func (id BackupEngineId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupEngines", "backupEngines", "backupEngines"), + resourceids.UserSpecifiedSegment("backupEngineName", "backupEngineValue"), + } +} + +// String returns a human-readable description of this Backup Engine ID +func (id BackupEngineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Engine Name: %q", id.BackupEngineName), + } + return fmt.Sprintf("Backup Engine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine_test.go new file mode 100644 index 00000000000..e3ded7159ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_backupengine_test.go @@ -0,0 +1,327 @@ +package backupengines + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupEngineId{} + +func TestNewBackupEngineID(t *testing.T) { + id := NewBackupEngineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupEngineValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupEngineName != "backupEngineValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupEngineName'", id.BackupEngineName, "backupEngineValue") + } +} + +func TestFormatBackupEngineID(t *testing.T) { + actual := NewBackupEngineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupEngineValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupEngineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupEngineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupEngineName: "backupEngineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupEngineID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupEngineName != v.Expected.BackupEngineName { + t.Fatalf("Expected %q but got %q for BackupEngineName", v.Expected.BackupEngineName, actual.BackupEngineName) + } + + } +} + +func TestParseBackupEngineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupEngineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPeNgInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupEngineName: "backupEngineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupEngines/backupEngineValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPeNgInEs/bAcKuPeNgInEvAlUe", + Expected: &BackupEngineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupEngineName: "bAcKuPeNgInEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPeNgInEs/bAcKuPeNgInEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupEngineIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupEngineName != v.Expected.BackupEngineName { + t.Fatalf("Expected %q but got %q for BackupEngineName", v.Expected.BackupEngineName, actual.BackupEngineName) + } + + } +} + +func TestSegmentsForBackupEngineId(t *testing.T) { + segments := BackupEngineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupEngineId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault.go new file mode 100644 index 00000000000..6092f91bf70 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault.go @@ -0,0 +1,130 @@ +package backupengines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault_test.go new file mode 100644 index 00000000000..1a7a230545a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/id_vault_test.go @@ -0,0 +1,282 @@ +package backupengines + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_get_autorest.go new file mode 100644 index 00000000000..e4493845ef2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_get_autorest.go @@ -0,0 +1,97 @@ +package backupengines + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupEngineBaseResource +} + +type GetOperationOptions struct { + Filter *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o GetOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Get ... +func (c BackupEnginesClient) Get(ctx context.Context, id BackupEngineId, options GetOperationOptions) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupEnginesClient) preparerForGet(ctx context.Context, id BackupEngineId, options GetOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c BackupEnginesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_list_autorest.go new file mode 100644 index 00000000000..bfc2eb661b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupengines + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]BackupEngineBaseResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []BackupEngineBaseResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupEnginesClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupEnginesClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupEngines", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupEnginesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupEnginesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []BackupEngineBaseResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupengines.BackupEnginesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupEnginesClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, BackupEngineBaseResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupEnginesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate BackupEngineBaseResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]BackupEngineBaseResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_azurebackupserverengine.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_azurebackupserverengine.go new file mode 100644 index 00000000000..af20b6e3719 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_azurebackupserverengine.go @@ -0,0 +1,52 @@ +package backupengines + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupEngineBase = AzureBackupServerEngine{} + +type AzureBackupServerEngine struct { + + // Fields inherited from BackupEngineBase + AzureBackupAgentVersion *string `json:"azureBackupAgentVersion,omitempty"` + BackupEngineId *string `json:"backupEngineId,omitempty"` + BackupEngineState *string `json:"backupEngineState,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + DpmVersion *string `json:"dpmVersion,omitempty"` + ExtendedInfo *BackupEngineExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + IsAzureBackupAgentUpgradeAvailable *bool `json:"isAzureBackupAgentUpgradeAvailable,omitempty"` + IsDpmUpgradeAvailable *bool `json:"isDpmUpgradeAvailable,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerEngine{} + +func (s AzureBackupServerEngine) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerEngine + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerEngine: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerEngine: %+v", err) + } + decoded["backupEngineType"] = "AzureBackupServerEngine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerEngine: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebase.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebase.go new file mode 100644 index 00000000000..d80588db3b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebase.go @@ -0,0 +1,61 @@ +package backupengines + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupEngineBase interface { +} + +// RawBackupEngineBaseImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawBackupEngineBaseImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBackupEngineBaseImplementation(input []byte) (BackupEngineBase, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling BackupEngineBase into map[string]interface: %+v", err) + } + + value, ok := temp["backupEngineType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerEngine") { + var out AzureBackupServerEngine + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerEngine: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DpmBackupEngine") { + var out DpmBackupEngine + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmBackupEngine: %+v", err) + } + return out, nil + } + + out := RawBackupEngineBaseImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebaseresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebaseresource.go new file mode 100644 index 00000000000..d7eac2e8d35 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupenginebaseresource.go @@ -0,0 +1,50 @@ +package backupengines + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupEngineBaseResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties BackupEngineBase `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &BackupEngineBaseResource{} + +func (s *BackupEngineBaseResource) UnmarshalJSON(bytes []byte) error { + type alias BackupEngineBaseResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BackupEngineBaseResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BackupEngineBaseResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalBackupEngineBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'BackupEngineBaseResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupengineextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupengineextendedinfo.go new file mode 100644 index 00000000000..cf19ed8a259 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_backupengineextendedinfo.go @@ -0,0 +1,33 @@ +package backupengines + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupEngineExtendedInfo struct { + AvailableDiskSpace *float64 `json:"availableDiskSpace,omitempty"` + AzureProtectedInstances *int64 `json:"azureProtectedInstances,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + DiskCount *int64 `json:"diskCount,omitempty"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ProtectedServersCount *int64 `json:"protectedServersCount,omitempty"` + RefreshedAt *string `json:"refreshedAt,omitempty"` + UsedDiskSpace *float64 `json:"usedDiskSpace,omitempty"` +} + +func (o *BackupEngineExtendedInfo) GetRefreshedAtAsTime() (*time.Time, error) { + if o.RefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupEngineExtendedInfo) SetRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_dpmbackupengine.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_dpmbackupengine.go new file mode 100644 index 00000000000..5d5df373244 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/model_dpmbackupengine.go @@ -0,0 +1,52 @@ +package backupengines + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupEngineBase = DpmBackupEngine{} + +type DpmBackupEngine struct { + + // Fields inherited from BackupEngineBase + AzureBackupAgentVersion *string `json:"azureBackupAgentVersion,omitempty"` + BackupEngineId *string `json:"backupEngineId,omitempty"` + BackupEngineState *string `json:"backupEngineState,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + DpmVersion *string `json:"dpmVersion,omitempty"` + ExtendedInfo *BackupEngineExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + IsAzureBackupAgentUpgradeAvailable *bool `json:"isAzureBackupAgentUpgradeAvailable,omitempty"` + IsDpmUpgradeAvailable *bool `json:"isDpmUpgradeAvailable,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmBackupEngine{} + +func (s DpmBackupEngine) MarshalJSON() ([]byte, error) { + type wrapper DpmBackupEngine + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmBackupEngine: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmBackupEngine: %+v", err) + } + decoded["backupEngineType"] = "DpmBackupEngine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmBackupEngine: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/predicates.go new file mode 100644 index 00000000000..5d9e2bfd1f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/predicates.go @@ -0,0 +1,37 @@ +package backupengines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupEngineBaseResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p BackupEngineBaseResourceOperationPredicate) Matches(input BackupEngineBaseResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/version.go new file mode 100644 index 00000000000..3e04e96caeb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupengines/version.go @@ -0,0 +1,12 @@ +package backupengines + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupengines/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/README.md new file mode 100644 index 00000000000..61c025701e0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs` Documentation + +The `backupjobs` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs" +``` + + +### Client Initialization + +```go +client := backupjobs.NewBackupJobsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupJobsClient.List` + +```go +ctx := context.TODO() +id := backupjobs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupjobs.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupjobs.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/client.go new file mode 100644 index 00000000000..79d95da7560 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/client.go @@ -0,0 +1,18 @@ +package backupjobs + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupJobsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupJobsClientWithBaseURI(endpoint string) BackupJobsClient { + return BackupJobsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/constants.go new file mode 100644 index 00000000000..15209b39988 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/constants.go @@ -0,0 +1,223 @@ +package backupjobs + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type JobSupportedAction string + +const ( + JobSupportedActionCancellable JobSupportedAction = "Cancellable" + JobSupportedActionInvalid JobSupportedAction = "Invalid" + JobSupportedActionRetriable JobSupportedAction = "Retriable" +) + +func PossibleValuesForJobSupportedAction() []string { + return []string{ + string(JobSupportedActionCancellable), + string(JobSupportedActionInvalid), + string(JobSupportedActionRetriable), + } +} + +func parseJobSupportedAction(input string) (*JobSupportedAction, error) { + vals := map[string]JobSupportedAction{ + "cancellable": JobSupportedActionCancellable, + "invalid": JobSupportedActionInvalid, + "retriable": JobSupportedActionRetriable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobSupportedAction(input) + return &out, nil +} + +type MabServerType string + +const ( + MabServerTypeAzureBackupServerContainer MabServerType = "AzureBackupServerContainer" + MabServerTypeAzureSqlContainer MabServerType = "AzureSqlContainer" + MabServerTypeCluster MabServerType = "Cluster" + MabServerTypeDPMContainer MabServerType = "DPMContainer" + MabServerTypeGenericContainer MabServerType = "GenericContainer" + MabServerTypeIaasVMContainer MabServerType = "IaasVMContainer" + MabServerTypeIaasVMServiceContainer MabServerType = "IaasVMServiceContainer" + MabServerTypeInvalid MabServerType = "Invalid" + MabServerTypeMABContainer MabServerType = "MABContainer" + MabServerTypeSQLAGWorkLoadContainer MabServerType = "SQLAGWorkLoadContainer" + MabServerTypeStorageContainer MabServerType = "StorageContainer" + MabServerTypeUnknown MabServerType = "Unknown" + MabServerTypeVCenter MabServerType = "VCenter" + MabServerTypeVMAppContainer MabServerType = "VMAppContainer" + MabServerTypeWindows MabServerType = "Windows" +) + +func PossibleValuesForMabServerType() []string { + return []string{ + string(MabServerTypeAzureBackupServerContainer), + string(MabServerTypeAzureSqlContainer), + string(MabServerTypeCluster), + string(MabServerTypeDPMContainer), + string(MabServerTypeGenericContainer), + string(MabServerTypeIaasVMContainer), + string(MabServerTypeIaasVMServiceContainer), + string(MabServerTypeInvalid), + string(MabServerTypeMABContainer), + string(MabServerTypeSQLAGWorkLoadContainer), + string(MabServerTypeStorageContainer), + string(MabServerTypeUnknown), + string(MabServerTypeVCenter), + string(MabServerTypeVMAppContainer), + string(MabServerTypeWindows), + } +} + +func parseMabServerType(input string) (*MabServerType, error) { + vals := map[string]MabServerType{ + "azurebackupservercontainer": MabServerTypeAzureBackupServerContainer, + "azuresqlcontainer": MabServerTypeAzureSqlContainer, + "cluster": MabServerTypeCluster, + "dpmcontainer": MabServerTypeDPMContainer, + "genericcontainer": MabServerTypeGenericContainer, + "iaasvmcontainer": MabServerTypeIaasVMContainer, + "iaasvmservicecontainer": MabServerTypeIaasVMServiceContainer, + "invalid": MabServerTypeInvalid, + "mabcontainer": MabServerTypeMABContainer, + "sqlagworkloadcontainer": MabServerTypeSQLAGWorkLoadContainer, + "storagecontainer": MabServerTypeStorageContainer, + "unknown": MabServerTypeUnknown, + "vcenter": MabServerTypeVCenter, + "vmappcontainer": MabServerTypeVMAppContainer, + "windows": MabServerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MabServerType(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDBInstance), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault.go new file mode 100644 index 00000000000..a51564e9571 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault.go @@ -0,0 +1,130 @@ +package backupjobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault_test.go new file mode 100644 index 00000000000..6b0c70de2b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/id_vault_test.go @@ -0,0 +1,282 @@ +package backupjobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/method_list_autorest.go new file mode 100644 index 00000000000..81e1c19dc60 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupjobs + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]JobResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []JobResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupJobsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupJobsClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupJobs", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupJobsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupJobsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []JobResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupjobs.BackupJobsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupJobsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, JobResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupJobsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate JobResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]JobResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmerrorinfo.go new file mode 100644 index 00000000000..d9fe5b31814 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmerrorinfo.go @@ -0,0 +1,11 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjob.go new file mode 100644 index 00000000000..7bf1b7e0e61 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjob.go @@ -0,0 +1,81 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureIaaSVMJob{} + +type AzureIaaSVMJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureIaaSVMJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJob{} + +func (s AzureIaaSVMJob) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJob: %+v", err) + } + decoded["jobType"] = "AzureIaaSVMJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobextendedinfo.go new file mode 100644 index 00000000000..8fd0ef0f439 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobextendedinfo.go @@ -0,0 +1,13 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + EstimatedRemainingDuration *string `json:"estimatedRemainingDuration,omitempty"` + InternalPropertyBag *map[string]string `json:"internalPropertyBag,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureIaaSVMJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobtaskdetails.go new file mode 100644 index 00000000000..dad4a07a3ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobtaskdetails.go @@ -0,0 +1,45 @@ +package backupjobs + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + InstanceId *string `json:"instanceId,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskExecutionDetails *string `json:"taskExecutionDetails,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *AzureIaaSVMJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobv2.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobv2.go new file mode 100644 index 00000000000..8512e3d4550 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureiaasvmjobv2.go @@ -0,0 +1,80 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureIaaSVMJobV2{} + +type AzureIaaSVMJobV2 struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureIaaSVMJobV2) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobV2) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJobV2{} + +func (s AzureIaaSVMJobV2) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJobV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJobV2: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJobV2: %+v", err) + } + decoded["jobType"] = "AzureIaaSVMJobV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJobV2: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestorageerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestorageerrorinfo.go new file mode 100644 index 00000000000..9a52a41965c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestorageerrorinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejob.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejob.go new file mode 100644 index 00000000000..d0ea1e45479 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejob.go @@ -0,0 +1,81 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureStorageJob{} + +type AzureStorageJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureStorageErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureStorageJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureStorageJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureStorageJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureStorageJob{} + +func (s AzureStorageJob) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageJob: %+v", err) + } + decoded["jobType"] = "AzureStorageJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobextendedinfo.go new file mode 100644 index 00000000000..22b7d4107d7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureStorageJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobtaskdetails.go new file mode 100644 index 00000000000..9b9bb298d99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azurestoragejobtaskdetails.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloaderrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloaderrorinfo.go new file mode 100644 index 00000000000..edc953a540c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloaderrorinfo.go @@ -0,0 +1,12 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadErrorInfo struct { + AdditionalDetails *string `json:"additionalDetails,omitempty"` + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjob.go new file mode 100644 index 00000000000..5432c48ce4f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjob.go @@ -0,0 +1,79 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureWorkloadJob{} + +type AzureWorkloadJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureWorkloadErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureWorkloadJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureWorkloadJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureWorkloadJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureWorkloadJob{} + +func (s AzureWorkloadJob) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadJob: %+v", err) + } + decoded["jobType"] = "AzureWorkloadJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobextendedinfo.go new file mode 100644 index 00000000000..160a414f7f3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureWorkloadJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobtaskdetails.go new file mode 100644 index 00000000000..0757ffec0fb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_azureworkloadjobtaskdetails.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmerrorinfo.go new file mode 100644 index 00000000000..091cf8f3157 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmerrorinfo.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjob.go new file mode 100644 index 00000000000..ceabc044801 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjob.go @@ -0,0 +1,82 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = DpmJob{} + +type DpmJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + ContainerType *string `json:"containerType,omitempty"` + DpmServerName *string `json:"dpmServerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]DpmErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *DpmJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *DpmJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = DpmJob{} + +func (s DpmJob) MarshalJSON() ([]byte, error) { + type wrapper DpmJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmJob: %+v", err) + } + decoded["jobType"] = "DpmJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobextendedinfo.go new file mode 100644 index 00000000000..6d4f63a2296 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]DpmJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobtaskdetails.go new file mode 100644 index 00000000000..ebf8a7cd691 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_dpmjobtaskdetails.go @@ -0,0 +1,42 @@ +package backupjobs + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *DpmJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_job.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_job.go new file mode 100644 index 00000000000..edb0e57dd4a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_job.go @@ -0,0 +1,101 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Job interface { +} + +// RawJobImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawJobImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalJobImplementation(input []byte) (Job, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling Job into map[string]interface: %+v", err) + } + + value, ok := temp["jobType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureIaaSVMJob") { + var out AzureIaaSVMJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMJobV2") { + var out AzureIaaSVMJobV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJobV2: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureStorageJob") { + var out AzureStorageJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadJob") { + var out AzureWorkloadJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DpmJob") { + var out DpmJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabJob") { + var out MabJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VaultJob") { + var out VaultJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VaultJob: %+v", err) + } + return out, nil + } + + out := RawJobImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_jobresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_jobresource.go new file mode 100644 index 00000000000..cb6a61ab28c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_jobresource.go @@ -0,0 +1,50 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties Job `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &JobResource{} + +func (s *JobResource) UnmarshalJSON(bytes []byte) error { + type alias JobResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into JobResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalJobImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'JobResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_maberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_maberrorinfo.go new file mode 100644 index 00000000000..9c3668d2bd5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_maberrorinfo.go @@ -0,0 +1,9 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjob.go new file mode 100644 index 00000000000..d1e4eda593c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjob.go @@ -0,0 +1,81 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = MabJob{} + +type MabJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]MabErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *MabJobExtendedInfo `json:"extendedInfo,omitempty"` + MabServerName *string `json:"mabServerName,omitempty"` + MabServerType *MabServerType `json:"mabServerType,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *MabJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = MabJob{} + +func (s MabJob) MarshalJSON() ([]byte, error) { + type wrapper MabJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabJob: %+v", err) + } + decoded["jobType"] = "MabJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobextendedinfo.go new file mode 100644 index 00000000000..eb61f914ed9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobextendedinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]MabJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobtaskdetails.go new file mode 100644 index 00000000000..15efde49be8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_mabjobtaskdetails.go @@ -0,0 +1,42 @@ +package backupjobs + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *MabJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjob.go new file mode 100644 index 00000000000..ac59fa1e242 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjob.go @@ -0,0 +1,78 @@ +package backupjobs + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = VaultJob{} + +type VaultJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]VaultJobErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *VaultJobExtendedInfo `json:"extendedInfo,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *VaultJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *VaultJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = VaultJob{} + +func (s VaultJob) MarshalJSON() ([]byte, error) { + type wrapper VaultJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VaultJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VaultJob: %+v", err) + } + decoded["jobType"] = "VaultJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VaultJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjoberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjoberrorinfo.go new file mode 100644 index 00000000000..cca822b6d80 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjoberrorinfo.go @@ -0,0 +1,10 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjobextendedinfo.go new file mode 100644 index 00000000000..ad9c628fcf1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/model_vaultjobextendedinfo.go @@ -0,0 +1,8 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobExtendedInfo struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/predicates.go new file mode 100644 index 00000000000..f8942840380 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/predicates.go @@ -0,0 +1,37 @@ +package backupjobs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p JobResourceOperationPredicate) Matches(input JobResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/version.go new file mode 100644 index 00000000000..8961923ef1b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs/version.go @@ -0,0 +1,12 @@ +package backupjobs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupjobs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/README.md new file mode 100644 index 00000000000..bba46c2ff64 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies` Documentation + +The `backuppolicies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies" +``` + + +### Client Initialization + +```go +client := backuppolicies.NewBackupPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupPoliciesClient.List` + +```go +ctx := context.TODO() +id := backuppolicies.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backuppolicies.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backuppolicies.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/client.go new file mode 100644 index 00000000000..c8b3aad1674 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/client.go @@ -0,0 +1,18 @@ +package backuppolicies + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupPoliciesClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupPoliciesClientWithBaseURI(endpoint string) BackupPoliciesClient { + return BackupPoliciesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/constants.go new file mode 100644 index 00000000000..195142cbae0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/constants.go @@ -0,0 +1,458 @@ +package backuppolicies + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type IAASVMPolicyType string + +const ( + IAASVMPolicyTypeInvalid IAASVMPolicyType = "Invalid" + IAASVMPolicyTypeVOne IAASVMPolicyType = "V1" + IAASVMPolicyTypeVTwo IAASVMPolicyType = "V2" +) + +func PossibleValuesForIAASVMPolicyType() []string { + return []string{ + string(IAASVMPolicyTypeInvalid), + string(IAASVMPolicyTypeVOne), + string(IAASVMPolicyTypeVTwo), + } +} + +func parseIAASVMPolicyType(input string) (*IAASVMPolicyType, error) { + vals := map[string]IAASVMPolicyType{ + "invalid": IAASVMPolicyTypeInvalid, + "v1": IAASVMPolicyTypeVOne, + "v2": IAASVMPolicyTypeVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IAASVMPolicyType(input) + return &out, nil +} + +type IaasVMSnapshotConsistencyType string + +const ( + IaasVMSnapshotConsistencyTypeOnlyCrashConsistent IaasVMSnapshotConsistencyType = "OnlyCrashConsistent" +) + +func PossibleValuesForIaasVMSnapshotConsistencyType() []string { + return []string{ + string(IaasVMSnapshotConsistencyTypeOnlyCrashConsistent), + } +} + +func parseIaasVMSnapshotConsistencyType(input string) (*IaasVMSnapshotConsistencyType, error) { + vals := map[string]IaasVMSnapshotConsistencyType{ + "onlycrashconsistent": IaasVMSnapshotConsistencyTypeOnlyCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IaasVMSnapshotConsistencyType(input) + return &out, nil +} + +type MonthOfYear string + +const ( + MonthOfYearApril MonthOfYear = "April" + MonthOfYearAugust MonthOfYear = "August" + MonthOfYearDecember MonthOfYear = "December" + MonthOfYearFebruary MonthOfYear = "February" + MonthOfYearInvalid MonthOfYear = "Invalid" + MonthOfYearJanuary MonthOfYear = "January" + MonthOfYearJuly MonthOfYear = "July" + MonthOfYearJune MonthOfYear = "June" + MonthOfYearMarch MonthOfYear = "March" + MonthOfYearMay MonthOfYear = "May" + MonthOfYearNovember MonthOfYear = "November" + MonthOfYearOctober MonthOfYear = "October" + MonthOfYearSeptember MonthOfYear = "September" +) + +func PossibleValuesForMonthOfYear() []string { + return []string{ + string(MonthOfYearApril), + string(MonthOfYearAugust), + string(MonthOfYearDecember), + string(MonthOfYearFebruary), + string(MonthOfYearInvalid), + string(MonthOfYearJanuary), + string(MonthOfYearJuly), + string(MonthOfYearJune), + string(MonthOfYearMarch), + string(MonthOfYearMay), + string(MonthOfYearNovember), + string(MonthOfYearOctober), + string(MonthOfYearSeptember), + } +} + +func parseMonthOfYear(input string) (*MonthOfYear, error) { + vals := map[string]MonthOfYear{ + "april": MonthOfYearApril, + "august": MonthOfYearAugust, + "december": MonthOfYearDecember, + "february": MonthOfYearFebruary, + "invalid": MonthOfYearInvalid, + "january": MonthOfYearJanuary, + "july": MonthOfYearJuly, + "june": MonthOfYearJune, + "march": MonthOfYearMarch, + "may": MonthOfYearMay, + "november": MonthOfYearNovember, + "october": MonthOfYearOctober, + "september": MonthOfYearSeptember, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonthOfYear(input) + return &out, nil +} + +type PolicyType string + +const ( + PolicyTypeCopyOnlyFull PolicyType = "CopyOnlyFull" + PolicyTypeDifferential PolicyType = "Differential" + PolicyTypeFull PolicyType = "Full" + PolicyTypeIncremental PolicyType = "Incremental" + PolicyTypeInvalid PolicyType = "Invalid" + PolicyTypeLog PolicyType = "Log" + PolicyTypeSnapshotCopyOnlyFull PolicyType = "SnapshotCopyOnlyFull" + PolicyTypeSnapshotFull PolicyType = "SnapshotFull" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeCopyOnlyFull), + string(PolicyTypeDifferential), + string(PolicyTypeFull), + string(PolicyTypeIncremental), + string(PolicyTypeInvalid), + string(PolicyTypeLog), + string(PolicyTypeSnapshotCopyOnlyFull), + string(PolicyTypeSnapshotFull), + } +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "copyonlyfull": PolicyTypeCopyOnlyFull, + "differential": PolicyTypeDifferential, + "full": PolicyTypeFull, + "incremental": PolicyTypeIncremental, + "invalid": PolicyTypeInvalid, + "log": PolicyTypeLog, + "snapshotcopyonlyfull": PolicyTypeSnapshotCopyOnlyFull, + "snapshotfull": PolicyTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyType(input) + return &out, nil +} + +type RetentionDurationType string + +const ( + RetentionDurationTypeDays RetentionDurationType = "Days" + RetentionDurationTypeInvalid RetentionDurationType = "Invalid" + RetentionDurationTypeMonths RetentionDurationType = "Months" + RetentionDurationTypeWeeks RetentionDurationType = "Weeks" + RetentionDurationTypeYears RetentionDurationType = "Years" +) + +func PossibleValuesForRetentionDurationType() []string { + return []string{ + string(RetentionDurationTypeDays), + string(RetentionDurationTypeInvalid), + string(RetentionDurationTypeMonths), + string(RetentionDurationTypeWeeks), + string(RetentionDurationTypeYears), + } +} + +func parseRetentionDurationType(input string) (*RetentionDurationType, error) { + vals := map[string]RetentionDurationType{ + "days": RetentionDurationTypeDays, + "invalid": RetentionDurationTypeInvalid, + "months": RetentionDurationTypeMonths, + "weeks": RetentionDurationTypeWeeks, + "years": RetentionDurationTypeYears, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RetentionDurationType(input) + return &out, nil +} + +type RetentionScheduleFormat string + +const ( + RetentionScheduleFormatDaily RetentionScheduleFormat = "Daily" + RetentionScheduleFormatInvalid RetentionScheduleFormat = "Invalid" + RetentionScheduleFormatWeekly RetentionScheduleFormat = "Weekly" +) + +func PossibleValuesForRetentionScheduleFormat() []string { + return []string{ + string(RetentionScheduleFormatDaily), + string(RetentionScheduleFormatInvalid), + string(RetentionScheduleFormatWeekly), + } +} + +func parseRetentionScheduleFormat(input string) (*RetentionScheduleFormat, error) { + vals := map[string]RetentionScheduleFormat{ + "daily": RetentionScheduleFormatDaily, + "invalid": RetentionScheduleFormatInvalid, + "weekly": RetentionScheduleFormatWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RetentionScheduleFormat(input) + return &out, nil +} + +type ScheduleRunType string + +const ( + ScheduleRunTypeDaily ScheduleRunType = "Daily" + ScheduleRunTypeHourly ScheduleRunType = "Hourly" + ScheduleRunTypeInvalid ScheduleRunType = "Invalid" + ScheduleRunTypeWeekly ScheduleRunType = "Weekly" +) + +func PossibleValuesForScheduleRunType() []string { + return []string{ + string(ScheduleRunTypeDaily), + string(ScheduleRunTypeHourly), + string(ScheduleRunTypeInvalid), + string(ScheduleRunTypeWeekly), + } +} + +func parseScheduleRunType(input string) (*ScheduleRunType, error) { + vals := map[string]ScheduleRunType{ + "daily": ScheduleRunTypeDaily, + "hourly": ScheduleRunTypeHourly, + "invalid": ScheduleRunTypeInvalid, + "weekly": ScheduleRunTypeWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleRunType(input) + return &out, nil +} + +type TieringMode string + +const ( + TieringModeDoNotTier TieringMode = "DoNotTier" + TieringModeInvalid TieringMode = "Invalid" + TieringModeTierAfter TieringMode = "TierAfter" + TieringModeTierRecommended TieringMode = "TierRecommended" +) + +func PossibleValuesForTieringMode() []string { + return []string{ + string(TieringModeDoNotTier), + string(TieringModeInvalid), + string(TieringModeTierAfter), + string(TieringModeTierRecommended), + } +} + +func parseTieringMode(input string) (*TieringMode, error) { + vals := map[string]TieringMode{ + "donottier": TieringModeDoNotTier, + "invalid": TieringModeInvalid, + "tierafter": TieringModeTierAfter, + "tierrecommended": TieringModeTierRecommended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TieringMode(input) + return &out, nil +} + +type WeekOfMonth string + +const ( + WeekOfMonthFirst WeekOfMonth = "First" + WeekOfMonthFourth WeekOfMonth = "Fourth" + WeekOfMonthInvalid WeekOfMonth = "Invalid" + WeekOfMonthLast WeekOfMonth = "Last" + WeekOfMonthSecond WeekOfMonth = "Second" + WeekOfMonthThird WeekOfMonth = "Third" +) + +func PossibleValuesForWeekOfMonth() []string { + return []string{ + string(WeekOfMonthFirst), + string(WeekOfMonthFourth), + string(WeekOfMonthInvalid), + string(WeekOfMonthLast), + string(WeekOfMonthSecond), + string(WeekOfMonthThird), + } +} + +func parseWeekOfMonth(input string) (*WeekOfMonth, error) { + vals := map[string]WeekOfMonth{ + "first": WeekOfMonthFirst, + "fourth": WeekOfMonthFourth, + "invalid": WeekOfMonthInvalid, + "last": WeekOfMonthLast, + "second": WeekOfMonthSecond, + "third": WeekOfMonthThird, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WeekOfMonth(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDBInstance), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault.go new file mode 100644 index 00000000000..6a0280f2aa9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault.go @@ -0,0 +1,130 @@ +package backuppolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault_test.go new file mode 100644 index 00000000000..0dfc82aa97f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/id_vault_test.go @@ -0,0 +1,282 @@ +package backuppolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/method_list_autorest.go new file mode 100644 index 00000000000..094b05fed04 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/method_list_autorest.go @@ -0,0 +1,215 @@ +package backuppolicies + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectionPolicyResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectionPolicyResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupPoliciesClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupPoliciesClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupPolicies", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupPoliciesClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupPoliciesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectionPolicyResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backuppolicies.BackupPoliciesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupPoliciesClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectionPolicyResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectionPolicyResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectionPolicyResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurefileshareprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurefileshareprotectionpolicy.go new file mode 100644 index 00000000000..b2a087a993d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurefileshareprotectionpolicy.go @@ -0,0 +1,85 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureFileShareProtectionPolicy{} + +type AzureFileShareProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + TimeZone *string `json:"timeZone,omitempty"` + VaultRetentionPolicy *VaultRetentionPolicy `json:"vaultRetentionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectionPolicy{} + +func (s AzureFileShareProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureStorage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureFileShareProtectionPolicy{} + +func (s *AzureFileShareProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureFileShareProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.TimeZone = decoded.TimeZone + s.VaultRetentionPolicy = decoded.VaultRetentionPolicy + s.WorkLoadType = decoded.WorkLoadType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azureiaasvmprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azureiaasvmprotectionpolicy.go new file mode 100644 index 00000000000..690b63e51c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azureiaasvmprotectionpolicy.go @@ -0,0 +1,91 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureIaaSVMProtectionPolicy{} + +type AzureIaaSVMProtectionPolicy struct { + InstantRPDetails *InstantRPAdditionalDetails `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + PolicyType *IAASVMPolicyType `json:"policyType,omitempty"` + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + SnapshotConsistencyType *IaasVMSnapshotConsistencyType `json:"snapshotConsistencyType,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureIaaSVMProtectionPolicy{} + +func (s AzureIaaSVMProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureIaasVM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureIaaSVMProtectionPolicy{} + +func (s *AzureIaaSVMProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureIaaSVMProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + + s.InstantRPDetails = decoded.InstantRPDetails + s.InstantRpRetentionRangeInDays = decoded.InstantRpRetentionRangeInDays + s.PolicyType = decoded.PolicyType + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.SnapshotConsistencyType = decoded.SnapshotConsistencyType + s.TieringPolicy = decoded.TieringPolicy + s.TimeZone = decoded.TimeZone + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azuresqlprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azuresqlprotectionpolicy.go new file mode 100644 index 00000000000..81c80d157da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azuresqlprotectionpolicy.go @@ -0,0 +1,70 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureSqlProtectionPolicy{} + +type AzureSqlProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureSqlProtectionPolicy{} + +func (s AzureSqlProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureSql" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureSqlProtectionPolicy{} + +func (s *AzureSqlProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureSqlProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureSqlProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureSqlProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go new file mode 100644 index 00000000000..0e318d65945 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_azurevmworkloadprotectionpolicy.go @@ -0,0 +1,46 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureVMWorkloadProtectionPolicy{} + +type AzureVMWorkloadProtectionPolicy struct { + MakePolicyConsistent *bool `json:"makePolicyConsistent,omitempty"` + Settings *Settings `json:"settings,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectionPolicy{} + +func (s AzureVMWorkloadProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureWorkload" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionformat.go new file mode 100644 index 00000000000..1c5f0a22c9b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionformat.go @@ -0,0 +1,8 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailyRetentionFormat struct { + DaysOfTheMonth *[]Day `json:"daysOfTheMonth,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionschedule.go new file mode 100644 index 00000000000..581a2b22ed5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyretentionschedule.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailyRetentionSchedule struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyschedule.go new file mode 100644 index 00000000000..34b307b9262 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_dailyschedule.go @@ -0,0 +1,8 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailySchedule struct { + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_day.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_day.go new file mode 100644 index 00000000000..c46c7f57129 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_day.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Day struct { + Date *int64 `json:"date,omitempty"` + IsLast *bool `json:"isLast,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_genericprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_genericprotectionpolicy.go new file mode 100644 index 00000000000..16227cb1edd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_genericprotectionpolicy.go @@ -0,0 +1,45 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = GenericProtectionPolicy{} + +type GenericProtectionPolicy struct { + FabricName *string `json:"fabricName,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = GenericProtectionPolicy{} + +func (s GenericProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "GenericProtectionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_hourlyschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_hourlyschedule.go new file mode 100644 index 00000000000..f9f1a5a1d3c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_hourlyschedule.go @@ -0,0 +1,28 @@ +package backuppolicies + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HourlySchedule struct { + Interval *int64 `json:"interval,omitempty"` + ScheduleWindowDuration *int64 `json:"scheduleWindowDuration,omitempty"` + ScheduleWindowStartTime *string `json:"scheduleWindowStartTime,omitempty"` +} + +func (o *HourlySchedule) GetScheduleWindowStartTimeAsTime() (*time.Time, error) { + if o.ScheduleWindowStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduleWindowStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *HourlySchedule) SetScheduleWindowStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduleWindowStartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_instantrpadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_instantrpadditionaldetails.go new file mode 100644 index 00000000000..f70f265dc45 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_instantrpadditionaldetails.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstantRPAdditionalDetails struct { + AzureBackupRGNamePrefix *string `json:"azureBackupRGNamePrefix,omitempty"` + AzureBackupRGNameSuffix *string `json:"azureBackupRGNameSuffix,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_logschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_logschedulepolicy.go new file mode 100644 index 00000000000..b4c2dd2d4f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_logschedulepolicy.go @@ -0,0 +1,41 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LogSchedulePolicy{} + +type LogSchedulePolicy struct { + ScheduleFrequencyInMins *int64 `json:"scheduleFrequencyInMins,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LogSchedulePolicy{} + +func (s LogSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LogSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LogSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LogSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LogSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LogSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermretentionpolicy.go new file mode 100644 index 00000000000..4f27496b945 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermretentionpolicy.go @@ -0,0 +1,44 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = LongTermRetentionPolicy{} + +type LongTermRetentionPolicy struct { + DailySchedule *DailyRetentionSchedule `json:"dailySchedule,omitempty"` + MonthlySchedule *MonthlyRetentionSchedule `json:"monthlySchedule,omitempty"` + WeeklySchedule *WeeklyRetentionSchedule `json:"weeklySchedule,omitempty"` + YearlySchedule *YearlyRetentionSchedule `json:"yearlySchedule,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = LongTermRetentionPolicy{} + +func (s LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "LongTermRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermschedulepolicy.go new file mode 100644 index 00000000000..00b2bec7ab3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_longtermschedulepolicy.go @@ -0,0 +1,40 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LongTermSchedulePolicy{} + +type LongTermSchedulePolicy struct { + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LongTermSchedulePolicy{} + +func (s LongTermSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LongTermSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_mabprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_mabprotectionpolicy.go new file mode 100644 index 00000000000..066b0138a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_mabprotectionpolicy.go @@ -0,0 +1,79 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = MabProtectionPolicy{} + +type MabProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = MabProtectionPolicy{} + +func (s MabProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper MabProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "MAB" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &MabProtectionPolicy{} + +func (s *MabProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias MabProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MabProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'MabProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'MabProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_monthlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_monthlyretentionschedule.go new file mode 100644 index 00000000000..8b8118cc9ee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_monthlyretentionschedule.go @@ -0,0 +1,12 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonthlyRetentionSchedule struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionScheduleDaily *DailyRetentionFormat `json:"retentionScheduleDaily,omitempty"` + RetentionScheduleFormatType *RetentionScheduleFormat `json:"retentionScheduleFormatType,omitempty"` + RetentionScheduleWeekly *WeeklyRetentionFormat `json:"retentionScheduleWeekly,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicy.go new file mode 100644 index 00000000000..d3fdb550ef9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicy.go @@ -0,0 +1,93 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicy interface { +} + +// RawProtectionPolicyImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionPolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionPolicyImplementation(input []byte) (ProtectionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["backupManagementType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureStorage") { + var out AzureFileShareProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaasVM") { + var out AzureIaaSVMProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSql") { + var out AzureSqlProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkload") { + var out AzureVMWorkloadProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectionPolicy") { + var out GenericProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MAB") { + var out MabProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + return out, nil + } + + out := RawProtectionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicyresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicyresource.go new file mode 100644 index 00000000000..6af342ec8f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_protectionpolicyresource.go @@ -0,0 +1,50 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicyResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionPolicy `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionPolicyResource{} + +func (s *ProtectionPolicyResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionPolicyResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionPolicyResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionPolicyResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionPolicyResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionduration.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionduration.go new file mode 100644 index 00000000000..60ecd1bea07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionduration.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionDuration struct { + Count *int64 `json:"count,omitempty"` + DurationType *RetentionDurationType `json:"durationType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionpolicy.go new file mode 100644 index 00000000000..515fe95872e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_retentionpolicy.go @@ -0,0 +1,61 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicy interface { +} + +// RawRetentionPolicyImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRetentionPolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRetentionPolicyImplementation(input []byte) (RetentionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RetentionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["retentionPolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LongTermRetentionPolicy") { + var out LongTermRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermRetentionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleRetentionPolicy") { + var out SimpleRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleRetentionPolicy: %+v", err) + } + return out, nil + } + + out := RawRetentionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_schedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_schedulepolicy.go new file mode 100644 index 00000000000..83aeb4b2344 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_schedulepolicy.go @@ -0,0 +1,77 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchedulePolicy interface { +} + +// RawSchedulePolicyImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSchedulePolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalSchedulePolicyImplementation(input []byte) (SchedulePolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SchedulePolicy into map[string]interface: %+v", err) + } + + value, ok := temp["schedulePolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LogSchedulePolicy") { + var out LogSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LogSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "LongTermSchedulePolicy") { + var out LongTermSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicy") { + var out SimpleSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicyV2") { + var out SimpleSchedulePolicyV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicyV2: %+v", err) + } + return out, nil + } + + out := RawSchedulePolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_settings.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_settings.go new file mode 100644 index 00000000000..c59cc13bdbe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_settings.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Settings struct { + IsCompression *bool `json:"isCompression,omitempty"` + Issqlcompression *bool `json:"issqlcompression,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleretentionpolicy.go new file mode 100644 index 00000000000..6355b65c8af --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleretentionpolicy.go @@ -0,0 +1,41 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = SimpleRetentionPolicy{} + +type SimpleRetentionPolicy struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = SimpleRetentionPolicy{} + +func (s SimpleRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "SimpleRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicy.go new file mode 100644 index 00000000000..cf047b354c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicy.go @@ -0,0 +1,45 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicy{} + +type SimpleSchedulePolicy struct { + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunDays *[]DayOfWeek `json:"scheduleRunDays,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` + ScheduleWeeklyFrequency *int64 `json:"scheduleWeeklyFrequency,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicy{} + +func (s SimpleSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicyv2.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicyv2.go new file mode 100644 index 00000000000..f8324d396c2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_simpleschedulepolicyv2.go @@ -0,0 +1,44 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicyV2{} + +type SimpleSchedulePolicyV2 struct { + DailySchedule *DailySchedule `json:"dailySchedule,omitempty"` + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + WeeklySchedule *WeeklySchedule `json:"weeklySchedule,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicyV2{} + +func (s SimpleSchedulePolicyV2) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicyV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicyV2: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicyV2: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicyV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicyV2: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_snapshotbackupadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_snapshotbackupadditionaldetails.go new file mode 100644 index 00000000000..33761b836e4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_snapshotbackupadditionaldetails.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotBackupAdditionalDetails struct { + InstantRPDetails *string `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_subprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_subprotectionpolicy.go new file mode 100644 index 00000000000..a60dd15ec41 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_subprotectionpolicy.go @@ -0,0 +1,53 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubProtectionPolicy struct { + PolicyType *PolicyType `json:"policyType,omitempty"` + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + SnapshotBackupAdditionalDetails *SnapshotBackupAdditionalDetails `json:"snapshotBackupAdditionalDetails,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` +} + +var _ json.Unmarshaler = &SubProtectionPolicy{} + +func (s *SubProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias SubProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SubProtectionPolicy: %+v", err) + } + + s.PolicyType = decoded.PolicyType + s.SnapshotBackupAdditionalDetails = decoded.SnapshotBackupAdditionalDetails + s.TieringPolicy = decoded.TieringPolicy + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SubProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'SubProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'SubProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_tieringpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_tieringpolicy.go new file mode 100644 index 00000000000..6075f6ce494 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_tieringpolicy.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TieringPolicy struct { + Duration *int64 `json:"duration,omitempty"` + DurationType *RetentionDurationType `json:"durationType,omitempty"` + TieringMode *TieringMode `json:"tieringMode,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..7f80e2e49db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..562196aa29d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_vaultretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_vaultretentionpolicy.go new file mode 100644 index 00000000000..7520633b946 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_vaultretentionpolicy.go @@ -0,0 +1,40 @@ +package backuppolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultRetentionPolicy struct { + SnapshotRetentionInDays int64 `json:"snapshotRetentionInDays"` + VaultRetention RetentionPolicy `json:"vaultRetention"` +} + +var _ json.Unmarshaler = &VaultRetentionPolicy{} + +func (s *VaultRetentionPolicy) UnmarshalJSON(bytes []byte) error { + type alias VaultRetentionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into VaultRetentionPolicy: %+v", err) + } + + s.SnapshotRetentionInDays = decoded.SnapshotRetentionInDays + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling VaultRetentionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["vaultRetention"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'VaultRetention' for 'VaultRetentionPolicy': %+v", err) + } + s.VaultRetention = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionformat.go new file mode 100644 index 00000000000..33dbf7e202c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionformat.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklyRetentionFormat struct { + DaysOfTheWeek *[]DayOfWeek `json:"daysOfTheWeek,omitempty"` + WeeksOfTheMonth *[]WeekOfMonth `json:"weeksOfTheMonth,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionschedule.go new file mode 100644 index 00000000000..edfa118dffc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyretentionschedule.go @@ -0,0 +1,10 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklyRetentionSchedule struct { + DaysOfTheWeek *[]DayOfWeek `json:"daysOfTheWeek,omitempty"` + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyschedule.go new file mode 100644 index 00000000000..93dcb41a53c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_weeklyschedule.go @@ -0,0 +1,9 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklySchedule struct { + ScheduleRunDays *[]DayOfWeek `json:"scheduleRunDays,omitempty"` + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_yearlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_yearlyretentionschedule.go new file mode 100644 index 00000000000..f2c784a79d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/model_yearlyretentionschedule.go @@ -0,0 +1,13 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type YearlyRetentionSchedule struct { + MonthsOfYear *[]MonthOfYear `json:"monthsOfYear,omitempty"` + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionScheduleDaily *DailyRetentionFormat `json:"retentionScheduleDaily,omitempty"` + RetentionScheduleFormatType *RetentionScheduleFormat `json:"retentionScheduleFormatType,omitempty"` + RetentionScheduleWeekly *WeeklyRetentionFormat `json:"retentionScheduleWeekly,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/predicates.go new file mode 100644 index 00000000000..cdc446bbcfb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/predicates.go @@ -0,0 +1,37 @@ +package backuppolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicyResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionPolicyResourceOperationPredicate) Matches(input ProtectionPolicyResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/version.go new file mode 100644 index 00000000000..30df912a279 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies/version.go @@ -0,0 +1,12 @@ +package backuppolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backuppolicies/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/README.md new file mode 100644 index 00000000000..8be88e6581c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems` Documentation + +The `backupprotectableitems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems" +``` + + +### Client Initialization + +```go +client := backupprotectableitems.NewBackupProtectableItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectableItemsClient.List` + +```go +ctx := context.TODO() +id := backupprotectableitems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotectableitems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotectableitems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/client.go new file mode 100644 index 00000000000..a30b2396b90 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/client.go @@ -0,0 +1,18 @@ +package backupprotectableitems + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupProtectableItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectableItemsClientWithBaseURI(endpoint string) BackupProtectableItemsClient { + return BackupProtectableItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/constants.go new file mode 100644 index 00000000000..4707e9072d4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/constants.go @@ -0,0 +1,105 @@ +package backupprotectableitems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileShareType string + +const ( + AzureFileShareTypeInvalid AzureFileShareType = "Invalid" + AzureFileShareTypeXSMB AzureFileShareType = "XSMB" + AzureFileShareTypeXSync AzureFileShareType = "XSync" +) + +func PossibleValuesForAzureFileShareType() []string { + return []string{ + string(AzureFileShareTypeInvalid), + string(AzureFileShareTypeXSMB), + string(AzureFileShareTypeXSync), + } +} + +func parseAzureFileShareType(input string) (*AzureFileShareType, error) { + vals := map[string]AzureFileShareType{ + "invalid": AzureFileShareTypeInvalid, + "xsmb": AzureFileShareTypeXSMB, + "xsync": AzureFileShareTypeXSync, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFileShareType(input) + return &out, nil +} + +type InquiryStatus string + +const ( + InquiryStatusFailed InquiryStatus = "Failed" + InquiryStatusInvalid InquiryStatus = "Invalid" + InquiryStatusSuccess InquiryStatus = "Success" +) + +func PossibleValuesForInquiryStatus() []string { + return []string{ + string(InquiryStatusFailed), + string(InquiryStatusInvalid), + string(InquiryStatusSuccess), + } +} + +func parseInquiryStatus(input string) (*InquiryStatus, error) { + vals := map[string]InquiryStatus{ + "failed": InquiryStatusFailed, + "invalid": InquiryStatusInvalid, + "success": InquiryStatusSuccess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InquiryStatus(input) + return &out, nil +} + +type ProtectionStatus string + +const ( + ProtectionStatusInvalid ProtectionStatus = "Invalid" + ProtectionStatusNotProtected ProtectionStatus = "NotProtected" + ProtectionStatusProtected ProtectionStatus = "Protected" + ProtectionStatusProtecting ProtectionStatus = "Protecting" + ProtectionStatusProtectionFailed ProtectionStatus = "ProtectionFailed" +) + +func PossibleValuesForProtectionStatus() []string { + return []string{ + string(ProtectionStatusInvalid), + string(ProtectionStatusNotProtected), + string(ProtectionStatusProtected), + string(ProtectionStatusProtecting), + string(ProtectionStatusProtectionFailed), + } +} + +func parseProtectionStatus(input string) (*ProtectionStatus, error) { + vals := map[string]ProtectionStatus{ + "invalid": ProtectionStatusInvalid, + "notprotected": ProtectionStatusNotProtected, + "protected": ProtectionStatusProtected, + "protecting": ProtectionStatusProtecting, + "protectionfailed": ProtectionStatusProtectionFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault.go new file mode 100644 index 00000000000..226b52b919b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault.go @@ -0,0 +1,130 @@ +package backupprotectableitems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault_test.go new file mode 100644 index 00000000000..bd20ab17bf4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotectableitems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/method_list_autorest.go new file mode 100644 index 00000000000..7e33743e477 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotectableitems + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]WorkloadProtectableItemResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []WorkloadProtectableItemResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupProtectableItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectableItemsClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupProtectableItems", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectableItemsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupProtectableItemsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []WorkloadProtectableItemResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectableitems.BackupProtectableItemsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectableItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkloadProtectableItemResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectableItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate WorkloadProtectableItemResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]WorkloadProtectableItemResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurefileshareprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurefileshareprotectableitem.go new file mode 100644 index 00000000000..609db8fe641 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurefileshareprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureFileShareProtectableItem{} + +type AzureFileShareProtectableItem struct { + AzureFileShareType *AzureFileShareType `json:"azureFileShareType,omitempty"` + ParentContainerFabricId *string `json:"parentContainerFabricId,omitempty"` + ParentContainerFriendlyName *string `json:"parentContainerFriendlyName,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectableItem{} + +func (s AzureFileShareProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "AzureFileShare" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go new file mode 100644 index 00000000000..14d4cde39da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaasclassiccomputevmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureIaaSClassicComputeVMProtectableItem{} + +type AzureIaaSClassicComputeVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectableItem{} + +func (s AzureIaaSClassicComputeVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go new file mode 100644 index 00000000000..13c811a243b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azureiaascomputevmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureIaaSComputeVMProtectableItem{} + +type AzureIaaSComputeVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectableItem{} + +func (s AzureIaaSComputeVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go new file mode 100644 index 00000000000..09d4180bc8b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadprotectableitem.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadProtectableItem{} + +type AzureVMWorkloadProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectableItem{} + +func (s AzureVMWorkloadProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "AzureVmWorkloadProtectableItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go new file mode 100644 index 00000000000..e8c296b457a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsapasesystemprotectableitem.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPAseSystemProtectableItem{} + +type AzureVMWorkloadSAPAseSystemProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseSystemProtectableItem{} + +func (s AzureVMWorkloadSAPAseSystemProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseSystemProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPAseSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go new file mode 100644 index 00000000000..cc7165679d2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadatabaseprotectableitem.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPHanaDatabaseProtectableItem{} + +type AzureVMWorkloadSAPHanaDatabaseProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseProtectableItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go new file mode 100644 index 00000000000..0008fcf4e42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanadbinstance.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPHanaDBInstance{} + +type AzureVMWorkloadSAPHanaDBInstance struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDBInstance{} + +func (s AzureVMWorkloadSAPHanaDBInstance) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDBInstance + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDBInstance: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDBInstance: %+v", err) + } + decoded["protectableItemType"] = "SAPHanaDBInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDBInstance: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go new file mode 100644 index 00000000000..77c1a0ac05f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanahsrprotectableitem.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPHanaHSRProtectableItem{} + +type AzureVMWorkloadSAPHanaHSRProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaHSRProtectableItem{} + +func (s AzureVMWorkloadSAPHanaHSRProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaHSRProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaHSRProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaHSRProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "HanaHSRContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaHSRProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go new file mode 100644 index 00000000000..c190e0aab39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsaphanasystemprotectableitem.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSAPHanaSystemProtectableItem{} + +type AzureVMWorkloadSAPHanaSystemProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaSystemProtectableItem{} + +func (s AzureVMWorkloadSAPHanaSystemProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaSystemProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SAPHanaSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go new file mode 100644 index 00000000000..9e5b0a12699 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlavailabilitygroupprotectableitem.go @@ -0,0 +1,54 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSQLAvailabilityGroupProtectableItem{} + +type AzureVMWorkloadSQLAvailabilityGroupProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLAvailabilityGroupProtectableItem{} + +func (s AzureVMWorkloadSQLAvailabilityGroupProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLAvailabilityGroupProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLAvailabilityGroupContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go new file mode 100644 index 00000000000..87ce15895d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqldatabaseprotectableitem.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSQLDatabaseProtectableItem{} + +type AzureVMWorkloadSQLDatabaseProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseProtectableItem{} + +func (s AzureVMWorkloadSQLDatabaseProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLDataBase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go new file mode 100644 index 00000000000..f963bac71b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_azurevmworkloadsqlinstanceprotectableitem.go @@ -0,0 +1,53 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = AzureVMWorkloadSQLInstanceProtectableItem{} + +type AzureVMWorkloadSQLInstanceProtectableItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + IsAutoProtected *bool `json:"isAutoProtected,omitempty"` + IsProtectable *bool `json:"isProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentUniqueName *string `json:"parentUniqueName,omitempty"` + Prebackupvalidation *PreBackupValidation `json:"prebackupvalidation,omitempty"` + ServerName *string `json:"serverName,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + Subprotectableitemcount *int64 `json:"subprotectableitemcount,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLInstanceProtectableItem{} + +func (s AzureVMWorkloadSQLInstanceProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLInstanceProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "SQLInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_distributednodesinfo.go new file mode 100644 index 00000000000..6e96dfe461c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package backupprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_errordetail.go new file mode 100644 index 00000000000..1c3fd85652e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_errordetail.go @@ -0,0 +1,10 @@ +package backupprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_iaasvmprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_iaasvmprotectableitem.go new file mode 100644 index 00000000000..c05ab27225f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_iaasvmprotectableitem.go @@ -0,0 +1,47 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadProtectableItem = IaaSVMProtectableItem{} + +type IaaSVMProtectableItem struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from WorkloadProtectableItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = IaaSVMProtectableItem{} + +func (s IaaSVMProtectableItem) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMProtectableItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMProtectableItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMProtectableItem: %+v", err) + } + decoded["protectableItemType"] = "IaaSVMProtectableItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMProtectableItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_prebackupvalidation.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_prebackupvalidation.go new file mode 100644 index 00000000000..955dd612808 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_prebackupvalidation.go @@ -0,0 +1,10 @@ +package backupprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreBackupValidation struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Status *InquiryStatus `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitem.go new file mode 100644 index 00000000000..91f978fc79b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitem.go @@ -0,0 +1,149 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProtectableItem interface { +} + +// RawWorkloadProtectableItemImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawWorkloadProtectableItemImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalWorkloadProtectableItemImplementation(input []byte) (WorkloadProtectableItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling WorkloadProtectableItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectableItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShare") { + var out AzureFileShareProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectableItem") { + var out AzureVMWorkloadProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPAseSystem") { + var out AzureVMWorkloadSAPAseSystemProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseSystemProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaDBInstance") { + var out AzureVMWorkloadSAPHanaDBInstance + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDBInstance: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HanaHSRContainer") { + var out AzureVMWorkloadSAPHanaHSRProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaHSRProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaSystem") { + var out AzureVMWorkloadSAPHanaSystemProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaSystemProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAvailabilityGroupContainer") { + var out AzureVMWorkloadSQLAvailabilityGroupProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLAvailabilityGroupProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLDataBase") { + var out AzureVMWorkloadSQLDatabaseProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLInstance") { + var out AzureVMWorkloadSQLInstanceProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLInstanceProtectableItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaaSVMProtectableItem") { + var out IaaSVMProtectableItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMProtectableItem: %+v", err) + } + return out, nil + } + + out := RawWorkloadProtectableItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitemresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitemresource.go new file mode 100644 index 00000000000..3f03589ca2d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/model_workloadprotectableitemresource.go @@ -0,0 +1,50 @@ +package backupprotectableitems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProtectableItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkloadProtectableItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &WorkloadProtectableItemResource{} + +func (s *WorkloadProtectableItemResource) UnmarshalJSON(bytes []byte) error { + type alias WorkloadProtectableItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into WorkloadProtectableItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling WorkloadProtectableItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalWorkloadProtectableItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'WorkloadProtectableItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/predicates.go new file mode 100644 index 00000000000..464f22ae33b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/predicates.go @@ -0,0 +1,37 @@ +package backupprotectableitems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadProtectableItemResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkloadProtectableItemResourceOperationPredicate) Matches(input WorkloadProtectableItemResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/version.go new file mode 100644 index 00000000000..c55540a252e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems/version.go @@ -0,0 +1,12 @@ +package backupprotectableitems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotectableitems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/README.md new file mode 100644 index 00000000000..35aef5d3abf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems` Documentation + +The `backupprotecteditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems" +``` + + +### Client Initialization + +```go +client := backupprotecteditems.NewBackupProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectedItemsClient.List` + +```go +ctx := context.TODO() +id := backupprotecteditems.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotecteditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotecteditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/client.go new file mode 100644 index 00000000000..7bb37dd5d36 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/client.go @@ -0,0 +1,18 @@ +package backupprotecteditems + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupProtectedItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectedItemsClientWithBaseURI(endpoint string) BackupProtectedItemsClient { + return BackupProtectedItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/constants.go new file mode 100644 index 00000000000..a0cadc76937 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/constants.go @@ -0,0 +1,387 @@ +package backupprotecteditems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeDefault CreateMode = "Default" + CreateModeInvalid CreateMode = "Invalid" + CreateModeRecover CreateMode = "Recover" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeDefault), + string(CreateModeInvalid), + string(CreateModeRecover), + } +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "default": CreateModeDefault, + "invalid": CreateModeInvalid, + "recover": CreateModeRecover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type DataSourceType string + +const ( + DataSourceTypeAzureFileShare DataSourceType = "AzureFileShare" + DataSourceTypeAzureSqlDb DataSourceType = "AzureSqlDb" + DataSourceTypeClient DataSourceType = "Client" + DataSourceTypeExchange DataSourceType = "Exchange" + DataSourceTypeFileFolder DataSourceType = "FileFolder" + DataSourceTypeGenericDataSource DataSourceType = "GenericDataSource" + DataSourceTypeInvalid DataSourceType = "Invalid" + DataSourceTypeSAPAseDatabase DataSourceType = "SAPAseDatabase" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + DataSourceTypeSAPHanaDatabase DataSourceType = "SAPHanaDatabase" + DataSourceTypeSQLDB DataSourceType = "SQLDB" + DataSourceTypeSQLDataBase DataSourceType = "SQLDataBase" + DataSourceTypeSharepoint DataSourceType = "Sharepoint" + DataSourceTypeSystemState DataSourceType = "SystemState" + DataSourceTypeVM DataSourceType = "VM" + DataSourceTypeVMwareVM DataSourceType = "VMwareVM" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAzureFileShare), + string(DataSourceTypeAzureSqlDb), + string(DataSourceTypeClient), + string(DataSourceTypeExchange), + string(DataSourceTypeFileFolder), + string(DataSourceTypeGenericDataSource), + string(DataSourceTypeInvalid), + string(DataSourceTypeSAPAseDatabase), + string(DataSourceTypeSAPHanaDBInstance), + string(DataSourceTypeSAPHanaDatabase), + string(DataSourceTypeSQLDB), + string(DataSourceTypeSQLDataBase), + string(DataSourceTypeSharepoint), + string(DataSourceTypeSystemState), + string(DataSourceTypeVM), + string(DataSourceTypeVMwareVM), + } +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "azurefileshare": DataSourceTypeAzureFileShare, + "azuresqldb": DataSourceTypeAzureSqlDb, + "client": DataSourceTypeClient, + "exchange": DataSourceTypeExchange, + "filefolder": DataSourceTypeFileFolder, + "genericdatasource": DataSourceTypeGenericDataSource, + "invalid": DataSourceTypeInvalid, + "sapasedatabase": DataSourceTypeSAPAseDatabase, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "saphanadatabase": DataSourceTypeSAPHanaDatabase, + "sqldb": DataSourceTypeSQLDB, + "sqldatabase": DataSourceTypeSQLDataBase, + "sharepoint": DataSourceTypeSharepoint, + "systemstate": DataSourceTypeSystemState, + "vm": DataSourceTypeVM, + "vmwarevm": DataSourceTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} + +type HealthStatus string + +const ( + HealthStatusActionRequired HealthStatus = "ActionRequired" + HealthStatusActionSuggested HealthStatus = "ActionSuggested" + HealthStatusInvalid HealthStatus = "Invalid" + HealthStatusPassed HealthStatus = "Passed" +) + +func PossibleValuesForHealthStatus() []string { + return []string{ + string(HealthStatusActionRequired), + string(HealthStatusActionSuggested), + string(HealthStatusInvalid), + string(HealthStatusPassed), + } +} + +func parseHealthStatus(input string) (*HealthStatus, error) { + vals := map[string]HealthStatus{ + "actionrequired": HealthStatusActionRequired, + "actionsuggested": HealthStatusActionSuggested, + "invalid": HealthStatusInvalid, + "passed": HealthStatusPassed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthStatus(input) + return &out, nil +} + +type LastBackupStatus string + +const ( + LastBackupStatusHealthy LastBackupStatus = "Healthy" + LastBackupStatusIRPending LastBackupStatus = "IRPending" + LastBackupStatusInvalid LastBackupStatus = "Invalid" + LastBackupStatusUnhealthy LastBackupStatus = "Unhealthy" +) + +func PossibleValuesForLastBackupStatus() []string { + return []string{ + string(LastBackupStatusHealthy), + string(LastBackupStatusIRPending), + string(LastBackupStatusInvalid), + string(LastBackupStatusUnhealthy), + } +} + +func parseLastBackupStatus(input string) (*LastBackupStatus, error) { + vals := map[string]LastBackupStatus{ + "healthy": LastBackupStatusHealthy, + "irpending": LastBackupStatusIRPending, + "invalid": LastBackupStatusInvalid, + "unhealthy": LastBackupStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LastBackupStatus(input) + return &out, nil +} + +type ProtectedItemHealthStatus string + +const ( + ProtectedItemHealthStatusHealthy ProtectedItemHealthStatus = "Healthy" + ProtectedItemHealthStatusIRPending ProtectedItemHealthStatus = "IRPending" + ProtectedItemHealthStatusInvalid ProtectedItemHealthStatus = "Invalid" + ProtectedItemHealthStatusNotReachable ProtectedItemHealthStatus = "NotReachable" + ProtectedItemHealthStatusUnhealthy ProtectedItemHealthStatus = "Unhealthy" +) + +func PossibleValuesForProtectedItemHealthStatus() []string { + return []string{ + string(ProtectedItemHealthStatusHealthy), + string(ProtectedItemHealthStatusIRPending), + string(ProtectedItemHealthStatusInvalid), + string(ProtectedItemHealthStatusNotReachable), + string(ProtectedItemHealthStatusUnhealthy), + } +} + +func parseProtectedItemHealthStatus(input string) (*ProtectedItemHealthStatus, error) { + vals := map[string]ProtectedItemHealthStatus{ + "healthy": ProtectedItemHealthStatusHealthy, + "irpending": ProtectedItemHealthStatusIRPending, + "invalid": ProtectedItemHealthStatusInvalid, + "notreachable": ProtectedItemHealthStatusNotReachable, + "unhealthy": ProtectedItemHealthStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemHealthStatus(input) + return &out, nil +} + +type ProtectedItemState string + +const ( + ProtectedItemStateBackupsSuspended ProtectedItemState = "BackupsSuspended" + ProtectedItemStateIRPending ProtectedItemState = "IRPending" + ProtectedItemStateInvalid ProtectedItemState = "Invalid" + ProtectedItemStateProtected ProtectedItemState = "Protected" + ProtectedItemStateProtectionError ProtectedItemState = "ProtectionError" + ProtectedItemStateProtectionPaused ProtectedItemState = "ProtectionPaused" + ProtectedItemStateProtectionStopped ProtectedItemState = "ProtectionStopped" +) + +func PossibleValuesForProtectedItemState() []string { + return []string{ + string(ProtectedItemStateBackupsSuspended), + string(ProtectedItemStateIRPending), + string(ProtectedItemStateInvalid), + string(ProtectedItemStateProtected), + string(ProtectedItemStateProtectionError), + string(ProtectedItemStateProtectionPaused), + string(ProtectedItemStateProtectionStopped), + } +} + +func parseProtectedItemState(input string) (*ProtectedItemState, error) { + vals := map[string]ProtectedItemState{ + "backupssuspended": ProtectedItemStateBackupsSuspended, + "irpending": ProtectedItemStateIRPending, + "invalid": ProtectedItemStateInvalid, + "protected": ProtectedItemStateProtected, + "protectionerror": ProtectedItemStateProtectionError, + "protectionpaused": ProtectedItemStateProtectionPaused, + "protectionstopped": ProtectedItemStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemState(input) + return &out, nil +} + +type ProtectionState string + +const ( + ProtectionStateBackupsSuspended ProtectionState = "BackupsSuspended" + ProtectionStateIRPending ProtectionState = "IRPending" + ProtectionStateInvalid ProtectionState = "Invalid" + ProtectionStateProtected ProtectionState = "Protected" + ProtectionStateProtectionError ProtectionState = "ProtectionError" + ProtectionStateProtectionPaused ProtectionState = "ProtectionPaused" + ProtectionStateProtectionStopped ProtectionState = "ProtectionStopped" +) + +func PossibleValuesForProtectionState() []string { + return []string{ + string(ProtectionStateBackupsSuspended), + string(ProtectionStateIRPending), + string(ProtectionStateInvalid), + string(ProtectionStateProtected), + string(ProtectionStateProtectionError), + string(ProtectionStateProtectionPaused), + string(ProtectionStateProtectionStopped), + } +} + +func parseProtectionState(input string) (*ProtectionState, error) { + vals := map[string]ProtectionState{ + "backupssuspended": ProtectionStateBackupsSuspended, + "irpending": ProtectionStateIRPending, + "invalid": ProtectionStateInvalid, + "protected": ProtectionStateProtected, + "protectionerror": ProtectionStateProtectionError, + "protectionpaused": ProtectionStateProtectionPaused, + "protectionstopped": ProtectionStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionState(input) + return &out, nil +} + +type ResourceHealthStatus string + +const ( + ResourceHealthStatusHealthy ResourceHealthStatus = "Healthy" + ResourceHealthStatusInvalid ResourceHealthStatus = "Invalid" + ResourceHealthStatusPersistentDegraded ResourceHealthStatus = "PersistentDegraded" + ResourceHealthStatusPersistentUnhealthy ResourceHealthStatus = "PersistentUnhealthy" + ResourceHealthStatusTransientDegraded ResourceHealthStatus = "TransientDegraded" + ResourceHealthStatusTransientUnhealthy ResourceHealthStatus = "TransientUnhealthy" +) + +func PossibleValuesForResourceHealthStatus() []string { + return []string{ + string(ResourceHealthStatusHealthy), + string(ResourceHealthStatusInvalid), + string(ResourceHealthStatusPersistentDegraded), + string(ResourceHealthStatusPersistentUnhealthy), + string(ResourceHealthStatusTransientDegraded), + string(ResourceHealthStatusTransientUnhealthy), + } +} + +func parseResourceHealthStatus(input string) (*ResourceHealthStatus, error) { + vals := map[string]ResourceHealthStatus{ + "healthy": ResourceHealthStatusHealthy, + "invalid": ResourceHealthStatusInvalid, + "persistentdegraded": ResourceHealthStatusPersistentDegraded, + "persistentunhealthy": ResourceHealthStatusPersistentUnhealthy, + "transientdegraded": ResourceHealthStatusTransientDegraded, + "transientunhealthy": ResourceHealthStatusTransientUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceHealthStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault.go new file mode 100644 index 00000000000..d1d3f88fdc4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault.go @@ -0,0 +1,130 @@ +package backupprotecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault_test.go new file mode 100644 index 00000000000..605452dfc17 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotecteditems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/method_list_autorest.go new file mode 100644 index 00000000000..5b5c8cd79c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotecteditems + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectedItemResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectedItemResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupProtectedItemsClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectedItemsClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupProtectedItems", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectedItemsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupProtectedItemsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectedItemResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotecteditems.BackupProtectedItemsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectedItemsClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectedItemResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectedItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectedItemResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectedItemResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 00000000000..c3298a1bd0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,92 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureFileshareProtectedItem{} + +type AzureFileshareProtectedItem struct { + ExtendedInfo *AzureFileshareProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureFileshareProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureFileshareProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureFileshareProtectedItem{} + +func (s AzureFileshareProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileshareProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileshareProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileshareProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureFileShareProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileshareProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 00000000000..784dbda1d5d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurefileshareprotecteditemextendedinfo.go @@ -0,0 +1,42 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileshareProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + ResourceState *string `json:"resourceState,omitempty"` + ResourceStateSyncTime *string `json:"resourceStateSyncTime,omitempty"` +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetResourceStateSyncTimeAsTime() (*time.Time, error) { + if o.ResourceStateSyncTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResourceStateSyncTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetResourceStateSyncTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResourceStateSyncTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 00000000000..02fc57f6284 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSClassicComputeVMProtectedItem{} + +type AzureIaaSClassicComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectedItem{} + +func (s AzureIaaSClassicComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 00000000000..cd68214dabe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSComputeVMProtectedItem{} + +type AzureIaaSComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectedItem{} + +func (s AzureIaaSComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 00000000000..1af736c9ff1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,97 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSVMProtectedItem{} + +type AzureIaaSVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSVMProtectedItem{} + +func (s AzureIaaSVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureIaaSVMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..f9bd89ad856 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azureiaasvmprotecteditemextendedinfo.go @@ -0,0 +1,67 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyInconsistent *bool `json:"policyInconsistent,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 00000000000..57afd68710c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,88 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureSqlProtectedItem{} + +type AzureSqlProtectedItem struct { + ExtendedInfo *AzureSqlProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureSqlProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureSqlProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureSqlProtectedItem{} + +func (s AzureSqlProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Sql/servers/databases" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 00000000000..1f95cebc98c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azuresqlprotecteditemextendedinfo.go @@ -0,0 +1,28 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureSqlProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureSqlProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 00000000000..3a61cfb08ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,99 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadProtectedItem{} + +type AzureVMWorkloadProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadProtectedItem{} + +func (s AzureVMWorkloadProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 00000000000..4ad1e158847 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadprotecteditemextendedinfo.go @@ -0,0 +1,68 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMWorkloadProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryModel *string `json:"recoveryModel,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 00000000000..1f562982e49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,99 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +type AzureVMWorkloadSAPAseDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPAseDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPAseDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 00000000000..f5ad71c3f66 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,99 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +type AzureVMWorkloadSAPHanaDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go new file mode 100644 index 00000000000..a26f205aef2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go @@ -0,0 +1,99 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +type AzureVMWorkloadSAPHanaDBInstanceProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDBInstanceProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDBInstanceProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDBInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 00000000000..df776fba105 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,99 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSQLDatabaseProtectedItem{} + +type AzureVMWorkloadSQLDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseProtectedItem{} + +func (s AzureVMWorkloadSQLDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSQLDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_diskexclusionproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_diskexclusionproperties.go new file mode 100644 index 00000000000..f12fc0030e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_diskexclusionproperties.go @@ -0,0 +1,9 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskExclusionProperties struct { + DiskLunList *[]int64 `json:"diskLunList,omitempty"` + IsInclusionList *bool `json:"isInclusionList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_distributednodesinfo.go new file mode 100644 index 00000000000..739b4bcf82a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditem.go new file mode 100644 index 00000000000..e17a5b340fc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditem.go @@ -0,0 +1,89 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = DPMProtectedItem{} + +type DPMProtectedItem struct { + BackupEngineName *string `json:"backupEngineName,omitempty"` + ExtendedInfo *DPMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *DPMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *DPMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = DPMProtectedItem{} + +func (s DPMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper DPMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DPMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DPMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "DPMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DPMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..c28c138b06e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_dpmprotecteditemextendedinfo.go @@ -0,0 +1,75 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMProtectedItemExtendedInfo struct { + DiskStorageUsedInBytes *string `json:"diskStorageUsedInBytes,omitempty"` + IsCollocated *bool `json:"isCollocated,omitempty"` + IsPresentOnCloud *bool `json:"isPresentOnCloud,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OnPremiseLatestRecoveryPoint *string `json:"onPremiseLatestRecoveryPoint,omitempty"` + OnPremiseOldestRecoveryPoint *string `json:"onPremiseOldestRecoveryPoint,omitempty"` + OnPremiseRecoveryPointCount *int64 `json:"onPremiseRecoveryPointCount,omitempty"` + ProtectableObjectLoadPath *map[string]string `json:"protectableObjectLoadPath,omitempty"` + Protected *bool `json:"protected,omitempty"` + ProtectionGroupName *string `json:"protectionGroupName,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + TotalDiskStorageSizeInBytes *string `json:"totalDiskStorageSizeInBytes,omitempty"` +} + +func (o *DPMProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseLatestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseLatestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseLatestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseLatestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseLatestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseOldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseOldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseOldestRecoveryPoint = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_errordetail.go new file mode 100644 index 00000000000..c55cc388bf9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_errordetail.go @@ -0,0 +1,10 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_extendedproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_extendedproperties.go new file mode 100644 index 00000000000..bd52e28b60e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_extendedproperties.go @@ -0,0 +1,9 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedProperties struct { + DiskExclusionProperties *DiskExclusionProperties `json:"diskExclusionProperties,omitempty"` + LinuxVMApplicationName *string `json:"linuxVmApplicationName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_genericprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_genericprotecteditem.go new file mode 100644 index 00000000000..98ab0962040 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_genericprotecteditem.go @@ -0,0 +1,91 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = GenericProtectedItem{} + +type GenericProtectedItem struct { + FabricName *string `json:"fabricName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + ProtectedItemId *int64 `json:"protectedItemId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + SourceAssociations *map[string]string `json:"sourceAssociations,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *GenericProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *GenericProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = GenericProtectedItem{} + +func (s GenericProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "GenericProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_kpiresourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 00000000000..42a11e535b9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_kpiresourcehealthdetails.go @@ -0,0 +1,9 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KPIResourceHealthDetails struct { + ResourceHealthDetails *[]ResourceHealthDetails `json:"resourceHealthDetails,omitempty"` + ResourceHealthStatus *ResourceHealthStatus `json:"resourceHealthStatus,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 00000000000..800796cc649 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,92 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = MabFileFolderProtectedItem{} + +type MabFileFolderProtectedItem struct { + ComputerName *string `json:"computerName,omitempty"` + DeferredDeleteSyncTimeInUTC *int64 `json:"deferredDeleteSyncTimeInUTC,omitempty"` + ExtendedInfo *MabFileFolderProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *MabFileFolderProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *MabFileFolderProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = MabFileFolderProtectedItem{} + +func (s MabFileFolderProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper MabFileFolderProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabFileFolderProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabFileFolderProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "MabFileFolderProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabFileFolderProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 00000000000..30f88b5c2ac --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_mabfilefolderprotecteditemextendedinfo.go @@ -0,0 +1,40 @@ +package backupprotecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabFileFolderProtectedItemExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditem.go new file mode 100644 index 00000000000..c0293f0a808 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditem.go @@ -0,0 +1,149 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItem interface { +} + +// RawProtectedItemImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectedItemImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectedItemImplementation(input []byte) (ProtectedItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectedItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectedItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareProtectedItem") { + var out AzureFileshareProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileshareProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMProtectedItem") { + var out AzureIaaSVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Sql/servers/databases") { + var out AzureSqlProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectedItem") { + var out AzureVMWorkloadProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPHanaDBInstance") { + var out AzureVMWorkloadSAPHanaDBInstanceProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSQLDatabase") { + var out AzureVMWorkloadSQLDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMProtectedItem") { + var out DPMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DPMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectedItem") { + var out GenericProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabFileFolderProtectedItem") { + var out MabFileFolderProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabFileFolderProtectedItem: %+v", err) + } + return out, nil + } + + out := RawProtectedItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditemresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditemresource.go new file mode 100644 index 00000000000..cf1da7db76f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_protecteditemresource.go @@ -0,0 +1,50 @@ +package backupprotecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectedItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectedItemResource{} + +func (s *ProtectedItemResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectedItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectedItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectedItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectedItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectedItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_resourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_resourcehealthdetails.go new file mode 100644 index 00000000000..34cb35fbf15 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/model_resourcehealthdetails.go @@ -0,0 +1,11 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/predicates.go new file mode 100644 index 00000000000..92b0067d35e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/predicates.go @@ -0,0 +1,37 @@ +package backupprotecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectedItemResourceOperationPredicate) Matches(input ProtectedItemResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/version.go new file mode 100644 index 00000000000..973669c5211 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems/version.go @@ -0,0 +1,12 @@ +package backupprotecteditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotecteditems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/README.md new file mode 100644 index 00000000000..9f71d5f8cb3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers` Documentation + +The `backupprotectioncontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers" +``` + + +### Client Initialization + +```go +client := backupprotectioncontainers.NewBackupProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectionContainersClient.List` + +```go +ctx := context.TODO() +id := backupprotectioncontainers.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotectioncontainers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotectioncontainers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/client.go new file mode 100644 index 00000000000..80d302c783e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/client.go @@ -0,0 +1,18 @@ +package backupprotectioncontainers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupProtectionContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectionContainersClientWithBaseURI(endpoint string) BackupProtectionContainersClient { + return BackupProtectionContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/constants.go new file mode 100644 index 00000000000..80a7af4df07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/constants.go @@ -0,0 +1,330 @@ +package backupprotectioncontainers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AcquireStorageAccountLock string + +const ( + AcquireStorageAccountLockAcquire AcquireStorageAccountLock = "Acquire" + AcquireStorageAccountLockNotAcquire AcquireStorageAccountLock = "NotAcquire" +) + +func PossibleValuesForAcquireStorageAccountLock() []string { + return []string{ + string(AcquireStorageAccountLockAcquire), + string(AcquireStorageAccountLockNotAcquire), + } +} + +func parseAcquireStorageAccountLock(input string) (*AcquireStorageAccountLock, error) { + vals := map[string]AcquireStorageAccountLock{ + "acquire": AcquireStorageAccountLockAcquire, + "notacquire": AcquireStorageAccountLockNotAcquire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AcquireStorageAccountLock(input) + return &out, nil +} + +type BackupItemType string + +const ( + BackupItemTypeAzureFileShare BackupItemType = "AzureFileShare" + BackupItemTypeAzureSqlDb BackupItemType = "AzureSqlDb" + BackupItemTypeClient BackupItemType = "Client" + BackupItemTypeExchange BackupItemType = "Exchange" + BackupItemTypeFileFolder BackupItemType = "FileFolder" + BackupItemTypeGenericDataSource BackupItemType = "GenericDataSource" + BackupItemTypeInvalid BackupItemType = "Invalid" + BackupItemTypeSAPAseDatabase BackupItemType = "SAPAseDatabase" + BackupItemTypeSAPHanaDBInstance BackupItemType = "SAPHanaDBInstance" + BackupItemTypeSAPHanaDatabase BackupItemType = "SAPHanaDatabase" + BackupItemTypeSQLDB BackupItemType = "SQLDB" + BackupItemTypeSQLDataBase BackupItemType = "SQLDataBase" + BackupItemTypeSharepoint BackupItemType = "Sharepoint" + BackupItemTypeSystemState BackupItemType = "SystemState" + BackupItemTypeVM BackupItemType = "VM" + BackupItemTypeVMwareVM BackupItemType = "VMwareVM" +) + +func PossibleValuesForBackupItemType() []string { + return []string{ + string(BackupItemTypeAzureFileShare), + string(BackupItemTypeAzureSqlDb), + string(BackupItemTypeClient), + string(BackupItemTypeExchange), + string(BackupItemTypeFileFolder), + string(BackupItemTypeGenericDataSource), + string(BackupItemTypeInvalid), + string(BackupItemTypeSAPAseDatabase), + string(BackupItemTypeSAPHanaDBInstance), + string(BackupItemTypeSAPHanaDatabase), + string(BackupItemTypeSQLDB), + string(BackupItemTypeSQLDataBase), + string(BackupItemTypeSharepoint), + string(BackupItemTypeSystemState), + string(BackupItemTypeVM), + string(BackupItemTypeVMwareVM), + } +} + +func parseBackupItemType(input string) (*BackupItemType, error) { + vals := map[string]BackupItemType{ + "azurefileshare": BackupItemTypeAzureFileShare, + "azuresqldb": BackupItemTypeAzureSqlDb, + "client": BackupItemTypeClient, + "exchange": BackupItemTypeExchange, + "filefolder": BackupItemTypeFileFolder, + "genericdatasource": BackupItemTypeGenericDataSource, + "invalid": BackupItemTypeInvalid, + "sapasedatabase": BackupItemTypeSAPAseDatabase, + "saphanadbinstance": BackupItemTypeSAPHanaDBInstance, + "saphanadatabase": BackupItemTypeSAPHanaDatabase, + "sqldb": BackupItemTypeSQLDB, + "sqldatabase": BackupItemTypeSQLDataBase, + "sharepoint": BackupItemTypeSharepoint, + "systemstate": BackupItemTypeSystemState, + "vm": BackupItemTypeVM, + "vmwarevm": BackupItemTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupItemType(input) + return &out, nil +} + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type OperationType string + +const ( + OperationTypeInvalid OperationType = "Invalid" + OperationTypeRegister OperationType = "Register" + OperationTypeReregister OperationType = "Reregister" +) + +func PossibleValuesForOperationType() []string { + return []string{ + string(OperationTypeInvalid), + string(OperationTypeRegister), + string(OperationTypeReregister), + } +} + +func parseOperationType(input string) (*OperationType, error) { + vals := map[string]OperationType{ + "invalid": OperationTypeInvalid, + "register": OperationTypeRegister, + "reregister": OperationTypeReregister, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationType(input) + return &out, nil +} + +type ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDBInstance), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault.go new file mode 100644 index 00000000000..814f8fd9a8a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault.go @@ -0,0 +1,130 @@ +package backupprotectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault_test.go new file mode 100644 index 00000000000..bb4ab374fbf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotectioncontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/method_list_autorest.go new file mode 100644 index 00000000000..2395d76d2f4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotectioncontainers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectionContainerResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectionContainerResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupProtectionContainersClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectionContainersClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupProtectionContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectionContainersClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupProtectionContainersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectionContainerResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectioncontainers.BackupProtectionContainersClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectionContainersClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectionContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectionContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectionContainerResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectionContainerResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..491a5d88bc7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurebackupservercontainer.go @@ -0,0 +1,53 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureBackupServerContainer{} + +type AzureBackupServerContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerContainer{} + +func (s AzureBackupServerContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerContainer: %+v", err) + } + decoded["containerType"] = "AzureBackupServerContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..65ce2a73e0e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,48 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSClassicComputeVMContainer{} + +type AzureIaaSClassicComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMContainer{} + +func (s AzureIaaSClassicComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..2cc11651a91 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,48 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSComputeVMContainer{} + +type AzureIaaSComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMContainer{} + +func (s AzureIaaSComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..0c3557434a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSQLAGWorkloadContainerProtectionContainer{} + +type AzureSQLAGWorkloadContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSQLAGWorkloadContainerProtectionContainer{} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSQLAGWorkloadContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "SQLAGWorkLoadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..6a6ebd42209 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azuresqlcontainer.go @@ -0,0 +1,45 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSqlContainer{} + +type AzureSqlContainer struct { + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSqlContainer{} + +func (s AzureSqlContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlContainer: %+v", err) + } + decoded["containerType"] = "AzureSqlContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..2517538ab11 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurestoragecontainer.go @@ -0,0 +1,50 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureStorageContainer{} + +type AzureStorageContainer struct { + AcquireStorageAccountLock *AcquireStorageAccountLock `json:"acquireStorageAccountLock,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageContainer{} + +func (s AzureStorageContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageContainer: %+v", err) + } + decoded["containerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..791890dda6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureVMAppContainerProtectionContainer{} + +type AzureVMAppContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectionContainer{} + +func (s AzureVMAppContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..4bd85bb2f86 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainer.go @@ -0,0 +1,50 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureWorkloadContainer{} + +type AzureWorkloadContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainer{} + +func (s AzureWorkloadContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainer: %+v", err) + } + decoded["containerType"] = "AzureWorkloadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..4e6205329b2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_azureworkloadcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadContainerExtendedInfo struct { + HostServerName *string `json:"hostServerName,omitempty"` + InquiryInfo *InquiryInfo `json:"inquiryInfo,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..8cff0e16315 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_containeridentityinfo.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerIdentityInfo struct { + AadTenantId *string `json:"aadTenantId,omitempty"` + Audience *string `json:"audience,omitempty"` + ServicePrincipalClientId *string `json:"servicePrincipalClientId,omitempty"` + UniqueName *string `json:"uniqueName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..88d6fe5dcf8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..d8f981a383a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainer.go @@ -0,0 +1,53 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = DpmContainer{} + +type DpmContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmContainer{} + +func (s DpmContainer) MarshalJSON() ([]byte, error) { + type wrapper DpmContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmContainer: %+v", err) + } + decoded["containerType"] = "DPMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..62c9b305962 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_dpmcontainerextendedinfo.go @@ -0,0 +1,26 @@ +package backupprotectioncontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMContainerExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` +} + +func (o *DPMContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_errordetail.go new file mode 100644 index 00000000000..86008b3edcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_errordetail.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainer.go new file mode 100644 index 00000000000..1b4450ed88f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainer.go @@ -0,0 +1,47 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = GenericContainer{} + +type GenericContainer struct { + ExtendedInformation *GenericContainerExtendedInfo `json:"extendedInformation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = GenericContainer{} + +func (s GenericContainer) MarshalJSON() ([]byte, error) { + type wrapper GenericContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericContainer: %+v", err) + } + decoded["containerType"] = "GenericContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..82f18cd823f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_genericcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenericContainerExtendedInfo struct { + ContainerIdentityInfo *ContainerIdentityInfo `json:"containerIdentityInfo,omitempty"` + RawCertData *string `json:"rawCertData,omitempty"` + ServiceEndpoints *map[string]string `json:"serviceEndpoints,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..442fd35fe13 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_iaasvmcontainer.go @@ -0,0 +1,48 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = IaaSVMContainer{} + +type IaaSVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = IaaSVMContainer{} + +func (s IaaSVMContainer) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMContainer: %+v", err) + } + decoded["containerType"] = "IaasVMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..93ec19a6ba0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryinfo.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + InquiryDetails *[]WorkloadInquiryDetails `json:"inquiryDetails,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..f33ed3584b2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_inquiryvalidation.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryValidation struct { + AdditionalDetail *string `json:"additionalDetail,omitempty"` + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + ProtectableItemCount *interface{} `json:"protectableItemCount,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainer.go new file mode 100644 index 00000000000..d9cd5599d7e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainer.go @@ -0,0 +1,52 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = MabContainer{} + +type MabContainer struct { + AgentVersion *string `json:"agentVersion,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerHealthState *string `json:"containerHealthState,omitempty"` + ContainerId *int64 `json:"containerId,omitempty"` + ExtendedInfo *MabContainerExtendedInfo `json:"extendedInfo,omitempty"` + MabContainerHealthDetails *[]MABContainerHealthDetails `json:"mabContainerHealthDetails,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = MabContainer{} + +func (s MabContainer) MarshalJSON() ([]byte, error) { + type wrapper MabContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabContainer: %+v", err) + } + decoded["containerType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..b23e3796a39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerextendedinfo.go @@ -0,0 +1,30 @@ +package backupprotectioncontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabContainerExtendedInfo struct { + BackupItemType *BackupItemType `json:"backupItemType,omitempty"` + BackupItems *[]string `json:"backupItems,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + PolicyName *string `json:"policyName,omitempty"` +} + +func (o *MabContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..7c04be9060e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_mabcontainerhealthdetails.go @@ -0,0 +1,11 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MABContainerHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..a675bf0357d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainer.go @@ -0,0 +1,141 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainer interface { +} + +// RawProtectionContainerImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionContainerImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionContainerImplementation(input []byte) (ProtectionContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionContainer into map[string]interface: %+v", err) + } + + value, ok := temp["containerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerContainer") { + var out AzureBackupServerContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAGWorkLoadContainer") { + var out AzureSQLAGWorkloadContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSqlContainer") { + var out AzureSqlContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainer") { + var out AzureWorkloadContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMContainer") { + var out DpmContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericContainer") { + var out GenericContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMContainer") { + var out IaaSVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out MabContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabContainer: %+v", err) + } + return out, nil + } + + out := RawProtectionContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..c112fdde08b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_protectioncontainerresource.go @@ -0,0 +1,50 @@ +package backupprotectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionContainer `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerResource{} + +func (s *ProtectionContainerResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..fd796f17a93 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/model_workloadinquirydetails.go @@ -0,0 +1,10 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadInquiryDetails struct { + InquiryValidation *InquiryValidation `json:"inquiryValidation,omitempty"` + ItemCount *int64 `json:"itemCount,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/predicates.go new file mode 100644 index 00000000000..2c7170b0702 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/predicates.go @@ -0,0 +1,37 @@ +package backupprotectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerResourceOperationPredicate) Matches(input ProtectionContainerResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/version.go new file mode 100644 index 00000000000..033048ef214 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers/version.go @@ -0,0 +1,12 @@ +package backupprotectioncontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotectioncontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/README.md new file mode 100644 index 00000000000..3a47284db49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent` Documentation + +The `backupprotectionintent` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent" +``` + + +### Client Initialization + +```go +client := backupprotectionintent.NewBackupProtectionIntentClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupProtectionIntentClient.List` + +```go +ctx := context.TODO() +id := backupprotectionintent.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.List(ctx, id, backupprotectionintent.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupprotectionintent.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/client.go new file mode 100644 index 00000000000..10dc6db01e1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/client.go @@ -0,0 +1,18 @@ +package backupprotectionintent + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupProtectionIntentClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupProtectionIntentClientWithBaseURI(endpoint string) BackupProtectionIntentClient { + return BackupProtectionIntentClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/constants.go new file mode 100644 index 00000000000..3329c4a8723 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/constants.go @@ -0,0 +1,178 @@ +package backupprotectionintent + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type ProtectionIntentItemType string + +const ( + ProtectionIntentItemTypeAzureResourceItem ProtectionIntentItemType = "AzureResourceItem" + ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadContainerAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadSQLAutoProtectionIntent" + ProtectionIntentItemTypeInvalid ProtectionIntentItemType = "Invalid" + ProtectionIntentItemTypeRecoveryServiceVaultItem ProtectionIntentItemType = "RecoveryServiceVaultItem" +) + +func PossibleValuesForProtectionIntentItemType() []string { + return []string{ + string(ProtectionIntentItemTypeAzureResourceItem), + string(ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent), + string(ProtectionIntentItemTypeInvalid), + string(ProtectionIntentItemTypeRecoveryServiceVaultItem), + } +} + +func parseProtectionIntentItemType(input string) (*ProtectionIntentItemType, error) { + vals := map[string]ProtectionIntentItemType{ + "azureresourceitem": ProtectionIntentItemTypeAzureResourceItem, + "azureworkloadautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent, + "azureworkloadcontainerautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent, + "azureworkloadsqlautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent, + "invalid": ProtectionIntentItemTypeInvalid, + "recoveryservicevaultitem": ProtectionIntentItemTypeRecoveryServiceVaultItem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionIntentItemType(input) + return &out, nil +} + +type ProtectionStatus string + +const ( + ProtectionStatusInvalid ProtectionStatus = "Invalid" + ProtectionStatusNotProtected ProtectionStatus = "NotProtected" + ProtectionStatusProtected ProtectionStatus = "Protected" + ProtectionStatusProtecting ProtectionStatus = "Protecting" + ProtectionStatusProtectionFailed ProtectionStatus = "ProtectionFailed" +) + +func PossibleValuesForProtectionStatus() []string { + return []string{ + string(ProtectionStatusInvalid), + string(ProtectionStatusNotProtected), + string(ProtectionStatusProtected), + string(ProtectionStatusProtecting), + string(ProtectionStatusProtectionFailed), + } +} + +func parseProtectionStatus(input string) (*ProtectionStatus, error) { + vals := map[string]ProtectionStatus{ + "invalid": ProtectionStatusInvalid, + "notprotected": ProtectionStatusNotProtected, + "protected": ProtectionStatusProtected, + "protecting": ProtectionStatusProtecting, + "protectionfailed": ProtectionStatusProtectionFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionStatus(input) + return &out, nil +} + +type WorkloadItemType string + +const ( + WorkloadItemTypeInvalid WorkloadItemType = "Invalid" + WorkloadItemTypeSAPAseDatabase WorkloadItemType = "SAPAseDatabase" + WorkloadItemTypeSAPAseSystem WorkloadItemType = "SAPAseSystem" + WorkloadItemTypeSAPHanaDBInstance WorkloadItemType = "SAPHanaDBInstance" + WorkloadItemTypeSAPHanaDatabase WorkloadItemType = "SAPHanaDatabase" + WorkloadItemTypeSAPHanaSystem WorkloadItemType = "SAPHanaSystem" + WorkloadItemTypeSQLDataBase WorkloadItemType = "SQLDataBase" + WorkloadItemTypeSQLInstance WorkloadItemType = "SQLInstance" +) + +func PossibleValuesForWorkloadItemType() []string { + return []string{ + string(WorkloadItemTypeInvalid), + string(WorkloadItemTypeSAPAseDatabase), + string(WorkloadItemTypeSAPAseSystem), + string(WorkloadItemTypeSAPHanaDBInstance), + string(WorkloadItemTypeSAPHanaDatabase), + string(WorkloadItemTypeSAPHanaSystem), + string(WorkloadItemTypeSQLDataBase), + string(WorkloadItemTypeSQLInstance), + } +} + +func parseWorkloadItemType(input string) (*WorkloadItemType, error) { + vals := map[string]WorkloadItemType{ + "invalid": WorkloadItemTypeInvalid, + "sapasedatabase": WorkloadItemTypeSAPAseDatabase, + "sapasesystem": WorkloadItemTypeSAPAseSystem, + "saphanadbinstance": WorkloadItemTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadItemTypeSAPHanaDatabase, + "saphanasystem": WorkloadItemTypeSAPHanaSystem, + "sqldatabase": WorkloadItemTypeSQLDataBase, + "sqlinstance": WorkloadItemTypeSQLInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadItemType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault.go new file mode 100644 index 00000000000..4dc6bb96ab6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault.go @@ -0,0 +1,130 @@ +package backupprotectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault_test.go new file mode 100644 index 00000000000..a898fa26800 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/id_vault_test.go @@ -0,0 +1,282 @@ +package backupprotectionintent + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/method_list_autorest.go new file mode 100644 index 00000000000..9e4e60e7b48 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupprotectionintent + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectionIntentResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectionIntentResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupProtectionIntentClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupProtectionIntentClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupProtectionIntents", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupProtectionIntentClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupProtectionIntentClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectionIntentResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupprotectionintent.BackupProtectionIntentClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupProtectionIntentClient) ListComplete(ctx context.Context, id VaultId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectionIntentResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupProtectionIntentClient) ListCompleteMatchingPredicate(ctx context.Context, id VaultId, options ListOperationOptions, predicate ProtectionIntentResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectionIntentResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go new file mode 100644 index 00000000000..b977432cd8e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azurerecoveryservicevaultprotectionintent.go @@ -0,0 +1,45 @@ +package backupprotectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureRecoveryServiceVaultProtectionIntent{} + +type AzureRecoveryServiceVaultProtectionIntent struct { + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureRecoveryServiceVaultProtectionIntent{} + +func (s AzureRecoveryServiceVaultProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureRecoveryServiceVaultProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "RecoveryServiceVaultItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureresourceprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureresourceprotectionintent.go new file mode 100644 index 00000000000..4583889073c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureresourceprotectionintent.go @@ -0,0 +1,46 @@ +package backupprotectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureResourceProtectionIntent{} + +type AzureResourceProtectionIntent struct { + FriendlyName *string `json:"friendlyName,omitempty"` + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureResourceProtectionIntent{} + +func (s AzureResourceProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureResourceProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureResourceProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureResourceProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureResourceItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureResourceProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go new file mode 100644 index 00000000000..267e3b491a5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadautoprotectionintent.go @@ -0,0 +1,45 @@ +package backupprotectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureWorkloadAutoProtectionIntent{} + +type AzureWorkloadAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadAutoProtectionIntent{} + +func (s AzureWorkloadAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureWorkloadAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go new file mode 100644 index 00000000000..a8769e454d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadcontainerautoprotectionintent.go @@ -0,0 +1,45 @@ +package backupprotectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureWorkloadContainerAutoProtectionIntent{} + +type AzureWorkloadContainerAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainerAutoProtectionIntent{} + +func (s AzureWorkloadContainerAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainerAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureWorkloadContainerAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go new file mode 100644 index 00000000000..f08a42d327c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_azureworkloadsqlautoprotectionintent.go @@ -0,0 +1,46 @@ +package backupprotectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureWorkloadSQLAutoProtectionIntent{} + +type AzureWorkloadSQLAutoProtectionIntent struct { + WorkloadItemType *WorkloadItemType `json:"workloadItemType,omitempty"` + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLAutoProtectionIntent{} + +func (s AzureWorkloadSQLAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureWorkloadSQLAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintent.go new file mode 100644 index 00000000000..37d03a79726 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintent.go @@ -0,0 +1,85 @@ +package backupprotectionintent + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionIntent interface { +} + +// RawProtectionIntentImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionIntentImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionIntentImplementation(input []byte) (ProtectionIntent, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionIntent into map[string]interface: %+v", err) + } + + value, ok := temp["protectionIntentItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "RecoveryServiceVaultItem") { + var out AzureRecoveryServiceVaultProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureResourceItem") { + var out AzureResourceProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureResourceProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadAutoProtectionIntent") { + var out AzureWorkloadAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainerAutoProtectionIntent") { + var out AzureWorkloadContainerAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLAutoProtectionIntent") { + var out AzureWorkloadSQLAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + return out, nil + } + + out := RawProtectionIntentImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintentresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintentresource.go new file mode 100644 index 00000000000..08b6ed4abda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/model_protectionintentresource.go @@ -0,0 +1,50 @@ +package backupprotectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionIntentResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionIntent `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionIntentResource{} + +func (s *ProtectionIntentResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionIntentResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionIntentResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionIntentResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionIntentImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionIntentResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/predicates.go new file mode 100644 index 00000000000..26161b72fe6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/predicates.go @@ -0,0 +1,37 @@ +package backupprotectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionIntentResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionIntentResourceOperationPredicate) Matches(input ProtectionIntentResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/version.go new file mode 100644 index 00000000000..2162fda8021 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent/version.go @@ -0,0 +1,12 @@ +package backupprotectionintent + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupprotectionintent/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/README.md new file mode 100644 index 00000000000..9b995cb3700 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/README.md @@ -0,0 +1,57 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs` Documentation + +The `backupresourceencryptionconfigs` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs" +``` + + +### Client Initialization + +```go +client := backupresourceencryptionconfigs.NewBackupResourceEncryptionConfigsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupResourceEncryptionConfigsClient.Get` + +```go +ctx := context.TODO() +id := backupresourceencryptionconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupResourceEncryptionConfigsClient.Update` + +```go +ctx := context.TODO() +id := backupresourceencryptionconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := backupresourceencryptionconfigs.BackupResourceEncryptionConfigResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/client.go new file mode 100644 index 00000000000..5b406d30285 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/client.go @@ -0,0 +1,18 @@ +package backupresourceencryptionconfigs + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfigsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupResourceEncryptionConfigsClientWithBaseURI(endpoint string) BackupResourceEncryptionConfigsClient { + return BackupResourceEncryptionConfigsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/constants.go new file mode 100644 index 00000000000..0c18f2887db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/constants.go @@ -0,0 +1,114 @@ +package backupresourceencryptionconfigs + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionAtRestType string + +const ( + EncryptionAtRestTypeCustomerManaged EncryptionAtRestType = "CustomerManaged" + EncryptionAtRestTypeInvalid EncryptionAtRestType = "Invalid" + EncryptionAtRestTypeMicrosoftManaged EncryptionAtRestType = "MicrosoftManaged" +) + +func PossibleValuesForEncryptionAtRestType() []string { + return []string{ + string(EncryptionAtRestTypeCustomerManaged), + string(EncryptionAtRestTypeInvalid), + string(EncryptionAtRestTypeMicrosoftManaged), + } +} + +func parseEncryptionAtRestType(input string) (*EncryptionAtRestType, error) { + vals := map[string]EncryptionAtRestType{ + "customermanaged": EncryptionAtRestTypeCustomerManaged, + "invalid": EncryptionAtRestTypeInvalid, + "microsoftmanaged": EncryptionAtRestTypeMicrosoftManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionAtRestType(input) + return &out, nil +} + +type InfrastructureEncryptionState string + +const ( + InfrastructureEncryptionStateDisabled InfrastructureEncryptionState = "Disabled" + InfrastructureEncryptionStateEnabled InfrastructureEncryptionState = "Enabled" + InfrastructureEncryptionStateInvalid InfrastructureEncryptionState = "Invalid" +) + +func PossibleValuesForInfrastructureEncryptionState() []string { + return []string{ + string(InfrastructureEncryptionStateDisabled), + string(InfrastructureEncryptionStateEnabled), + string(InfrastructureEncryptionStateInvalid), + } +} + +func parseInfrastructureEncryptionState(input string) (*InfrastructureEncryptionState, error) { + vals := map[string]InfrastructureEncryptionState{ + "disabled": InfrastructureEncryptionStateDisabled, + "enabled": InfrastructureEncryptionStateEnabled, + "invalid": InfrastructureEncryptionStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InfrastructureEncryptionState(input) + return &out, nil +} + +type LastUpdateStatus string + +const ( + LastUpdateStatusFailed LastUpdateStatus = "Failed" + LastUpdateStatusFirstInitialization LastUpdateStatus = "FirstInitialization" + LastUpdateStatusInitialized LastUpdateStatus = "Initialized" + LastUpdateStatusInvalid LastUpdateStatus = "Invalid" + LastUpdateStatusNotEnabled LastUpdateStatus = "NotEnabled" + LastUpdateStatusPartiallyFailed LastUpdateStatus = "PartiallyFailed" + LastUpdateStatusPartiallySucceeded LastUpdateStatus = "PartiallySucceeded" + LastUpdateStatusSucceeded LastUpdateStatus = "Succeeded" +) + +func PossibleValuesForLastUpdateStatus() []string { + return []string{ + string(LastUpdateStatusFailed), + string(LastUpdateStatusFirstInitialization), + string(LastUpdateStatusInitialized), + string(LastUpdateStatusInvalid), + string(LastUpdateStatusNotEnabled), + string(LastUpdateStatusPartiallyFailed), + string(LastUpdateStatusPartiallySucceeded), + string(LastUpdateStatusSucceeded), + } +} + +func parseLastUpdateStatus(input string) (*LastUpdateStatus, error) { + vals := map[string]LastUpdateStatus{ + "failed": LastUpdateStatusFailed, + "firstinitialization": LastUpdateStatusFirstInitialization, + "initialized": LastUpdateStatusInitialized, + "invalid": LastUpdateStatusInvalid, + "notenabled": LastUpdateStatusNotEnabled, + "partiallyfailed": LastUpdateStatusPartiallyFailed, + "partiallysucceeded": LastUpdateStatusPartiallySucceeded, + "succeeded": LastUpdateStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LastUpdateStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault.go new file mode 100644 index 00000000000..646a9d93961 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault.go @@ -0,0 +1,130 @@ +package backupresourceencryptionconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault_test.go new file mode 100644 index 00000000000..94221b356e4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/id_vault_test.go @@ -0,0 +1,282 @@ +package backupresourceencryptionconfigs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_get_autorest.go new file mode 100644 index 00000000000..8946fde875a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_get_autorest.go @@ -0,0 +1,69 @@ +package backupresourceencryptionconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceEncryptionConfigExtendedResource +} + +// Get ... +func (c BackupResourceEncryptionConfigsClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupResourceEncryptionConfigsClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupEncryptionConfigs/backupResourceEncryptionConfig", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c BackupResourceEncryptionConfigsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_update_autorest.go new file mode 100644 index 00000000000..8e72a546ee0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/method_update_autorest.go @@ -0,0 +1,68 @@ +package backupresourceencryptionconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response +} + +// Update ... +func (c BackupResourceEncryptionConfigsClient) Update(ctx context.Context, id VaultId, input BackupResourceEncryptionConfigResource) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c BackupResourceEncryptionConfigsClient) preparerForUpdate(ctx context.Context, id VaultId, input BackupResourceEncryptionConfigResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupEncryptionConfigs/backupResourceEncryptionConfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c BackupResourceEncryptionConfigsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go new file mode 100644 index 00000000000..04c2d9832cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfig.go @@ -0,0 +1,12 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfig struct { + EncryptionAtRestType *EncryptionAtRestType `json:"encryptionAtRestType,omitempty"` + InfrastructureEncryptionState *InfrastructureEncryptionState `json:"infrastructureEncryptionState,omitempty"` + KeyUri *string `json:"keyUri,omitempty"` + LastUpdateStatus *LastUpdateStatus `json:"lastUpdateStatus,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go new file mode 100644 index 00000000000..c58a1406581 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextended.go @@ -0,0 +1,14 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfigExtended struct { + EncryptionAtRestType *EncryptionAtRestType `json:"encryptionAtRestType,omitempty"` + InfrastructureEncryptionState *InfrastructureEncryptionState `json:"infrastructureEncryptionState,omitempty"` + KeyUri *string `json:"keyUri,omitempty"` + LastUpdateStatus *LastUpdateStatus `json:"lastUpdateStatus,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + UseSystemAssignedIdentity *bool `json:"useSystemAssignedIdentity,omitempty"` + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go new file mode 100644 index 00000000000..748ecae7a86 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigextendedresource.go @@ -0,0 +1,14 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfigExtendedResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceEncryptionConfigExtended `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go new file mode 100644 index 00000000000..2bdfb74ffb3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/model_backupresourceencryptionconfigresource.go @@ -0,0 +1,14 @@ +package backupresourceencryptionconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceEncryptionConfigResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceEncryptionConfig `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/version.go new file mode 100644 index 00000000000..2303e0f4f75 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs/version.go @@ -0,0 +1,12 @@ +package backupresourceencryptionconfigs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupresourceencryptionconfigs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/README.md new file mode 100644 index 00000000000..6c1e3390727 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr` Documentation + +The `backupresourcestorageconfigsnoncrr` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr" +``` + + +### Client Initialization + +```go +client := backupresourcestorageconfigsnoncrr.NewBackupResourceStorageConfigsNonCRRClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupResourceStorageConfigsNonCRRClient.Get` + +```go +ctx := context.TODO() +id := backupresourcestorageconfigsnoncrr.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupResourceStorageConfigsNonCRRClient.Patch` + +```go +ctx := context.TODO() +id := backupresourcestorageconfigsnoncrr.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := backupresourcestorageconfigsnoncrr.BackupResourceConfigResource{ + // ... +} + + +read, err := client.Patch(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupResourceStorageConfigsNonCRRClient.Update` + +```go +ctx := context.TODO() +id := backupresourcestorageconfigsnoncrr.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := backupresourcestorageconfigsnoncrr.BackupResourceConfigResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/client.go new file mode 100644 index 00000000000..88d28c49c49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/client.go @@ -0,0 +1,18 @@ +package backupresourcestorageconfigsnoncrr + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceStorageConfigsNonCRRClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupResourceStorageConfigsNonCRRClientWithBaseURI(endpoint string) BackupResourceStorageConfigsNonCRRClient { + return BackupResourceStorageConfigsNonCRRClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/constants.go new file mode 100644 index 00000000000..6ae51ba9c4a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/constants.go @@ -0,0 +1,136 @@ +package backupresourcestorageconfigsnoncrr + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedupState string + +const ( + DedupStateDisabled DedupState = "Disabled" + DedupStateEnabled DedupState = "Enabled" + DedupStateInvalid DedupState = "Invalid" +) + +func PossibleValuesForDedupState() []string { + return []string{ + string(DedupStateDisabled), + string(DedupStateEnabled), + string(DedupStateInvalid), + } +} + +func parseDedupState(input string) (*DedupState, error) { + vals := map[string]DedupState{ + "disabled": DedupStateDisabled, + "enabled": DedupStateEnabled, + "invalid": DedupStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DedupState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeGeoRedundant StorageType = "GeoRedundant" + StorageTypeInvalid StorageType = "Invalid" + StorageTypeLocallyRedundant StorageType = "LocallyRedundant" + StorageTypeReadAccessGeoZoneRedundant StorageType = "ReadAccessGeoZoneRedundant" + StorageTypeZoneRedundant StorageType = "ZoneRedundant" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeGeoRedundant), + string(StorageTypeInvalid), + string(StorageTypeLocallyRedundant), + string(StorageTypeReadAccessGeoZoneRedundant), + string(StorageTypeZoneRedundant), + } +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "georedundant": StorageTypeGeoRedundant, + "invalid": StorageTypeInvalid, + "locallyredundant": StorageTypeLocallyRedundant, + "readaccessgeozoneredundant": StorageTypeReadAccessGeoZoneRedundant, + "zoneredundant": StorageTypeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type StorageTypeState string + +const ( + StorageTypeStateInvalid StorageTypeState = "Invalid" + StorageTypeStateLocked StorageTypeState = "Locked" + StorageTypeStateUnlocked StorageTypeState = "Unlocked" +) + +func PossibleValuesForStorageTypeState() []string { + return []string{ + string(StorageTypeStateInvalid), + string(StorageTypeStateLocked), + string(StorageTypeStateUnlocked), + } +} + +func parseStorageTypeState(input string) (*StorageTypeState, error) { + vals := map[string]StorageTypeState{ + "invalid": StorageTypeStateInvalid, + "locked": StorageTypeStateLocked, + "unlocked": StorageTypeStateUnlocked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageTypeState(input) + return &out, nil +} + +type XcoolState string + +const ( + XcoolStateDisabled XcoolState = "Disabled" + XcoolStateEnabled XcoolState = "Enabled" + XcoolStateInvalid XcoolState = "Invalid" +) + +func PossibleValuesForXcoolState() []string { + return []string{ + string(XcoolStateDisabled), + string(XcoolStateEnabled), + string(XcoolStateInvalid), + } +} + +func parseXcoolState(input string) (*XcoolState, error) { + vals := map[string]XcoolState{ + "disabled": XcoolStateDisabled, + "enabled": XcoolStateEnabled, + "invalid": XcoolStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := XcoolState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault.go new file mode 100644 index 00000000000..a1355a4b4e3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault.go @@ -0,0 +1,130 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault_test.go new file mode 100644 index 00000000000..1be676b3d31 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/id_vault_test.go @@ -0,0 +1,282 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go new file mode 100644 index 00000000000..dfa7631d81e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_get_autorest.go @@ -0,0 +1,69 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceConfigResource +} + +// Get ... +func (c BackupResourceStorageConfigsNonCRRClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupResourceStorageConfigsNonCRRClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c BackupResourceStorageConfigsNonCRRClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go new file mode 100644 index 00000000000..06e35a3cb44 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_patch_autorest.go @@ -0,0 +1,68 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchOperationResponse struct { + HttpResponse *http.Response +} + +// Patch ... +func (c BackupResourceStorageConfigsNonCRRClient) Patch(ctx context.Context, id VaultId, input BackupResourceConfigResource) (result PatchOperationResponse, err error) { + req, err := c.preparerForPatch(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Patch", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Patch", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPatch(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Patch", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPatch prepares the Patch request. +func (c BackupResourceStorageConfigsNonCRRClient) preparerForPatch(ctx context.Context, id VaultId, input BackupResourceConfigResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPatch handles the response to the Patch request. The method always +// closes the http.Response Body. +func (c BackupResourceStorageConfigsNonCRRClient) responderForPatch(resp *http.Response) (result PatchOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go new file mode 100644 index 00000000000..13a010ee69d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/method_update_autorest.go @@ -0,0 +1,70 @@ +package backupresourcestorageconfigsnoncrr + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceConfigResource +} + +// Update ... +func (c BackupResourceStorageConfigsNonCRRClient) Update(ctx context.Context, id VaultId, input BackupResourceConfigResource) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c BackupResourceStorageConfigsNonCRRClient) preparerForUpdate(ctx context.Context, id VaultId, input BackupResourceConfigResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c BackupResourceStorageConfigsNonCRRClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go new file mode 100644 index 00000000000..69f226c0dcf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfig.go @@ -0,0 +1,13 @@ +package backupresourcestorageconfigsnoncrr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceConfig struct { + CrossRegionRestoreFlag *bool `json:"crossRegionRestoreFlag,omitempty"` + DedupState *DedupState `json:"dedupState,omitempty"` + StorageModelType *StorageType `json:"storageModelType,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` + StorageTypeState *StorageTypeState `json:"storageTypeState,omitempty"` + XcoolState *XcoolState `json:"xcoolState,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go new file mode 100644 index 00000000000..8fc2680cafb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/model_backupresourceconfigresource.go @@ -0,0 +1,14 @@ +package backupresourcestorageconfigsnoncrr + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceConfigResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceConfig `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/version.go new file mode 100644 index 00000000000..048b0ad4aa8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr/version.go @@ -0,0 +1,12 @@ +package backupresourcestorageconfigsnoncrr + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupresourcestorageconfigsnoncrr/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/README.md new file mode 100644 index 00000000000..49a9e89c211 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/README.md @@ -0,0 +1,78 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs` Documentation + +The `backupresourcevaultconfigs` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs" +``` + + +### Client Initialization + +```go +client := backupresourcevaultconfigs.NewBackupResourceVaultConfigsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupResourceVaultConfigsClient.Get` + +```go +ctx := context.TODO() +id := backupresourcevaultconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupResourceVaultConfigsClient.Put` + +```go +ctx := context.TODO() +id := backupresourcevaultconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := backupresourcevaultconfigs.BackupResourceVaultConfigResource{ + // ... +} + + +read, err := client.Put(ctx, id, payload, backupresourcevaultconfigs.DefaultPutOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BackupResourceVaultConfigsClient.Update` + +```go +ctx := context.TODO() +id := backupresourcevaultconfigs.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := backupresourcevaultconfigs.BackupResourceVaultConfigResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload, backupresourcevaultconfigs.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/client.go new file mode 100644 index 00000000000..b56d05bcc6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/client.go @@ -0,0 +1,18 @@ +package backupresourcevaultconfigs + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceVaultConfigsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupResourceVaultConfigsClientWithBaseURI(endpoint string) BackupResourceVaultConfigsClient { + return BackupResourceVaultConfigsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/constants.go new file mode 100644 index 00000000000..3be392d6155 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/constants.go @@ -0,0 +1,139 @@ +package backupresourcevaultconfigs + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnhancedSecurityState string + +const ( + EnhancedSecurityStateDisabled EnhancedSecurityState = "Disabled" + EnhancedSecurityStateEnabled EnhancedSecurityState = "Enabled" + EnhancedSecurityStateInvalid EnhancedSecurityState = "Invalid" +) + +func PossibleValuesForEnhancedSecurityState() []string { + return []string{ + string(EnhancedSecurityStateDisabled), + string(EnhancedSecurityStateEnabled), + string(EnhancedSecurityStateInvalid), + } +} + +func parseEnhancedSecurityState(input string) (*EnhancedSecurityState, error) { + vals := map[string]EnhancedSecurityState{ + "disabled": EnhancedSecurityStateDisabled, + "enabled": EnhancedSecurityStateEnabled, + "invalid": EnhancedSecurityStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnhancedSecurityState(input) + return &out, nil +} + +type SoftDeleteFeatureState string + +const ( + SoftDeleteFeatureStateAlwaysON SoftDeleteFeatureState = "AlwaysON" + SoftDeleteFeatureStateDisabled SoftDeleteFeatureState = "Disabled" + SoftDeleteFeatureStateEnabled SoftDeleteFeatureState = "Enabled" + SoftDeleteFeatureStateInvalid SoftDeleteFeatureState = "Invalid" +) + +func PossibleValuesForSoftDeleteFeatureState() []string { + return []string{ + string(SoftDeleteFeatureStateAlwaysON), + string(SoftDeleteFeatureStateDisabled), + string(SoftDeleteFeatureStateEnabled), + string(SoftDeleteFeatureStateInvalid), + } +} + +func parseSoftDeleteFeatureState(input string) (*SoftDeleteFeatureState, error) { + vals := map[string]SoftDeleteFeatureState{ + "alwayson": SoftDeleteFeatureStateAlwaysON, + "disabled": SoftDeleteFeatureStateDisabled, + "enabled": SoftDeleteFeatureStateEnabled, + "invalid": SoftDeleteFeatureStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SoftDeleteFeatureState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeGeoRedundant StorageType = "GeoRedundant" + StorageTypeInvalid StorageType = "Invalid" + StorageTypeLocallyRedundant StorageType = "LocallyRedundant" + StorageTypeReadAccessGeoZoneRedundant StorageType = "ReadAccessGeoZoneRedundant" + StorageTypeZoneRedundant StorageType = "ZoneRedundant" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeGeoRedundant), + string(StorageTypeInvalid), + string(StorageTypeLocallyRedundant), + string(StorageTypeReadAccessGeoZoneRedundant), + string(StorageTypeZoneRedundant), + } +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "georedundant": StorageTypeGeoRedundant, + "invalid": StorageTypeInvalid, + "locallyredundant": StorageTypeLocallyRedundant, + "readaccessgeozoneredundant": StorageTypeReadAccessGeoZoneRedundant, + "zoneredundant": StorageTypeZoneRedundant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type StorageTypeState string + +const ( + StorageTypeStateInvalid StorageTypeState = "Invalid" + StorageTypeStateLocked StorageTypeState = "Locked" + StorageTypeStateUnlocked StorageTypeState = "Unlocked" +) + +func PossibleValuesForStorageTypeState() []string { + return []string{ + string(StorageTypeStateInvalid), + string(StorageTypeStateLocked), + string(StorageTypeStateUnlocked), + } +} + +func parseStorageTypeState(input string) (*StorageTypeState, error) { + vals := map[string]StorageTypeState{ + "invalid": StorageTypeStateInvalid, + "locked": StorageTypeStateLocked, + "unlocked": StorageTypeStateUnlocked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageTypeState(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault.go new file mode 100644 index 00000000000..ba1ccdb6d5a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault.go @@ -0,0 +1,130 @@ +package backupresourcevaultconfigs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault_test.go new file mode 100644 index 00000000000..4fc8cf8e4f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/id_vault_test.go @@ -0,0 +1,282 @@ +package backupresourcevaultconfigs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_get_autorest.go new file mode 100644 index 00000000000..709a6190da7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_get_autorest.go @@ -0,0 +1,69 @@ +package backupresourcevaultconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceVaultConfigResource +} + +// Get ... +func (c BackupResourceVaultConfigsClient) Get(ctx context.Context, id VaultId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupResourceVaultConfigsClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupconfig/vaultconfig", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c BackupResourceVaultConfigsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_put_autorest.go new file mode 100644 index 00000000000..553319e53dc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_put_autorest.go @@ -0,0 +1,99 @@ +package backupresourcevaultconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceVaultConfigResource +} + +type PutOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultPutOperationOptions() PutOperationOptions { + return PutOperationOptions{} +} + +func (o PutOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o PutOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Put ... +func (c BackupResourceVaultConfigsClient) Put(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options PutOperationOptions) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Put", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Put", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPut(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Put", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPut prepares the Put request. +func (c BackupResourceVaultConfigsClient) preparerForPut(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options PutOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupconfig/vaultconfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPut handles the response to the Put request. The method always +// closes the http.Response Body. +func (c BackupResourceVaultConfigsClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_update_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_update_autorest.go new file mode 100644 index 00000000000..6bc2ec4acdf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/method_update_autorest.go @@ -0,0 +1,99 @@ +package backupresourcevaultconfigs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + Model *BackupResourceVaultConfigResource +} + +type UpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o UpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Update ... +func (c BackupResourceVaultConfigsClient) Update(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + req, err := c.preparerForUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Update", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Update", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupresourcevaultconfigs.BackupResourceVaultConfigsClient", "Update", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUpdate prepares the Update request. +func (c BackupResourceVaultConfigsClient) preparerForUpdate(ctx context.Context, id VaultId, input BackupResourceVaultConfigResource, options UpdateOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupconfig/vaultconfig", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUpdate handles the response to the Update request. The method always +// closes the http.Response Body. +func (c BackupResourceVaultConfigsClient) responderForUpdate(resp *http.Response) (result UpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go new file mode 100644 index 00000000000..43c59de4141 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfig.go @@ -0,0 +1,15 @@ +package backupresourcevaultconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceVaultConfig struct { + EnhancedSecurityState *EnhancedSecurityState `json:"enhancedSecurityState,omitempty"` + IsSoftDeleteFeatureStateEditable *bool `json:"isSoftDeleteFeatureStateEditable,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteFeatureState *SoftDeleteFeatureState `json:"softDeleteFeatureState,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + StorageModelType *StorageType `json:"storageModelType,omitempty"` + StorageType *StorageType `json:"storageType,omitempty"` + StorageTypeState *StorageTypeState `json:"storageTypeState,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go new file mode 100644 index 00000000000..9957131bbd6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/model_backupresourcevaultconfigresource.go @@ -0,0 +1,14 @@ +package backupresourcevaultconfigs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResourceVaultConfigResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupResourceVaultConfig `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/version.go new file mode 100644 index 00000000000..8b1edd7e860 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs/version.go @@ -0,0 +1,12 @@ +package backupresourcevaultconfigs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupresourcevaultconfigs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backups/README.md new file mode 100644 index 00000000000..2fcd36fbff1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backups` Documentation + +The `backups` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backups" +``` + + +### Client Initialization + +```go +client := backups.NewBackupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupsClient.Trigger` + +```go +ctx := context.TODO() +id := backups.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +payload := backups.BackupRequestResource{ + // ... +} + + +read, err := client.Trigger(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/client.go new file mode 100644 index 00000000000..8669bac74ee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/client.go @@ -0,0 +1,18 @@ +package backups + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupsClientWithBaseURI(endpoint string) BackupsClient { + return BackupsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/constants.go new file mode 100644 index 00000000000..28cae0d72b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/constants.go @@ -0,0 +1,52 @@ +package backups + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupType string + +const ( + BackupTypeCopyOnlyFull BackupType = "CopyOnlyFull" + BackupTypeDifferential BackupType = "Differential" + BackupTypeFull BackupType = "Full" + BackupTypeIncremental BackupType = "Incremental" + BackupTypeInvalid BackupType = "Invalid" + BackupTypeLog BackupType = "Log" + BackupTypeSnapshotCopyOnlyFull BackupType = "SnapshotCopyOnlyFull" + BackupTypeSnapshotFull BackupType = "SnapshotFull" +) + +func PossibleValuesForBackupType() []string { + return []string{ + string(BackupTypeCopyOnlyFull), + string(BackupTypeDifferential), + string(BackupTypeFull), + string(BackupTypeIncremental), + string(BackupTypeInvalid), + string(BackupTypeLog), + string(BackupTypeSnapshotCopyOnlyFull), + string(BackupTypeSnapshotFull), + } +} + +func parseBackupType(input string) (*BackupType, error) { + vals := map[string]BackupType{ + "copyonlyfull": BackupTypeCopyOnlyFull, + "differential": BackupTypeDifferential, + "full": BackupTypeFull, + "incremental": BackupTypeIncremental, + "invalid": BackupTypeInvalid, + "log": BackupTypeLog, + "snapshotcopyonlyfull": BackupTypeSnapshotCopyOnlyFull, + "snapshotfull": BackupTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem.go new file mode 100644 index 00000000000..384742b5287 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem.go @@ -0,0 +1,157 @@ +package backups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProtectedItemIDInsensitively parses 'input' case-insensitively into a ProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseProtectedItemIDInsensitively(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return nil +} + +// ValidateProtectedItemID checks that 'input' can be parsed as a Protected Item ID +func ValidateProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protected Item ID +func (id ProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protected Item ID +func (id ProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem_test.go new file mode 100644 index 00000000000..e724aa39827 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package backups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/method_trigger_autorest.go new file mode 100644 index 00000000000..bf23ac4685b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/method_trigger_autorest.go @@ -0,0 +1,68 @@ +package backups + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerOperationResponse struct { + HttpResponse *http.Response +} + +// Trigger ... +func (c BackupsClient) Trigger(ctx context.Context, id ProtectedItemId, input BackupRequestResource) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Trigger", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTrigger(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backups.BackupsClient", "Trigger", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTrigger prepares the Trigger request. +func (c BackupsClient) preparerForTrigger(ctx context.Context, id ProtectedItemId, input BackupRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backup", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTrigger handles the response to the Trigger request. The method always +// closes the http.Response Body. +func (c BackupsClient) responderForTrigger(resp *http.Response) (result TriggerOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azurefilesharebackuprequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azurefilesharebackuprequest.go new file mode 100644 index 00000000000..99ddceed9c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azurefilesharebackuprequest.go @@ -0,0 +1,41 @@ +package backups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupRequest = AzureFileShareBackupRequest{} + +type AzureFileShareBackupRequest struct { + RecoveryPointExpiryTimeInUTC *string `json:"recoveryPointExpiryTimeInUTC,omitempty"` + + // Fields inherited from BackupRequest +} + +var _ json.Marshaler = AzureFileShareBackupRequest{} + +func (s AzureFileShareBackupRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareBackupRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareBackupRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareBackupRequest: %+v", err) + } + decoded["objectType"] = "AzureFileShareBackupRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareBackupRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azureworkloadbackuprequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azureworkloadbackuprequest.go new file mode 100644 index 00000000000..dff561d8271 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_azureworkloadbackuprequest.go @@ -0,0 +1,43 @@ +package backups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupRequest = AzureWorkloadBackupRequest{} + +type AzureWorkloadBackupRequest struct { + BackupType *BackupType `json:"backupType,omitempty"` + EnableCompression *bool `json:"enableCompression,omitempty"` + RecoveryPointExpiryTimeInUTC *string `json:"recoveryPointExpiryTimeInUTC,omitempty"` + + // Fields inherited from BackupRequest +} + +var _ json.Marshaler = AzureWorkloadBackupRequest{} + +func (s AzureWorkloadBackupRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadBackupRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadBackupRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadBackupRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadBackupRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadBackupRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequest.go new file mode 100644 index 00000000000..2f905da3c3c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequest.go @@ -0,0 +1,69 @@ +package backups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequest interface { +} + +// RawBackupRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawBackupRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalBackupRequestImplementation(input []byte) (BackupRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling BackupRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareBackupRequest") { + var out AzureFileShareBackupRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareBackupRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadBackupRequest") { + var out AzureWorkloadBackupRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadBackupRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMBackupRequest") { + var out IaasVMBackupRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMBackupRequest: %+v", err) + } + return out, nil + } + + out := RawBackupRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequestresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequestresource.go new file mode 100644 index 00000000000..9f57a8a255b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_backuprequestresource.go @@ -0,0 +1,50 @@ +package backups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequestResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties BackupRequest `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &BackupRequestResource{} + +func (s *BackupRequestResource) UnmarshalJSON(bytes []byte) error { + type alias BackupRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into BackupRequestResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BackupRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalBackupRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'BackupRequestResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_iaasvmbackuprequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_iaasvmbackuprequest.go new file mode 100644 index 00000000000..d40c0c3ccf0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/model_iaasvmbackuprequest.go @@ -0,0 +1,41 @@ +package backups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BackupRequest = IaasVMBackupRequest{} + +type IaasVMBackupRequest struct { + RecoveryPointExpiryTimeInUTC *string `json:"recoveryPointExpiryTimeInUTC,omitempty"` + + // Fields inherited from BackupRequest +} + +var _ json.Marshaler = IaasVMBackupRequest{} + +func (s IaasVMBackupRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMBackupRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMBackupRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMBackupRequest: %+v", err) + } + decoded["objectType"] = "IaasVMBackupRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMBackupRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backups/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backups/version.go new file mode 100644 index 00000000000..8e400ee87e1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backups/version.go @@ -0,0 +1,12 @@ +package backups + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backups/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/README.md new file mode 100644 index 00000000000..70cb8532466 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus` Documentation + +The `backupstatus` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus" +``` + + +### Client Initialization + +```go +client := backupstatus.NewBackupStatusClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupStatusClient.Get` + +```go +ctx := context.TODO() +id := backupstatus.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := backupstatus.BackupStatusRequest{ + // ... +} + + +read, err := client.Get(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/client.go new file mode 100644 index 00000000000..d17f64f2d24 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/client.go @@ -0,0 +1,18 @@ +package backupstatus + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupStatusClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupStatusClientWithBaseURI(endpoint string) BackupStatusClient { + return BackupStatusClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/constants.go new file mode 100644 index 00000000000..aa16bf7cbcf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/constants.go @@ -0,0 +1,169 @@ +package backupstatus + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AcquireStorageAccountLock string + +const ( + AcquireStorageAccountLockAcquire AcquireStorageAccountLock = "Acquire" + AcquireStorageAccountLockNotAcquire AcquireStorageAccountLock = "NotAcquire" +) + +func PossibleValuesForAcquireStorageAccountLock() []string { + return []string{ + string(AcquireStorageAccountLockAcquire), + string(AcquireStorageAccountLockNotAcquire), + } +} + +func parseAcquireStorageAccountLock(input string) (*AcquireStorageAccountLock, error) { + vals := map[string]AcquireStorageAccountLock{ + "acquire": AcquireStorageAccountLockAcquire, + "notacquire": AcquireStorageAccountLockNotAcquire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AcquireStorageAccountLock(input) + return &out, nil +} + +type DataSourceType string + +const ( + DataSourceTypeAzureFileShare DataSourceType = "AzureFileShare" + DataSourceTypeAzureSqlDb DataSourceType = "AzureSqlDb" + DataSourceTypeClient DataSourceType = "Client" + DataSourceTypeExchange DataSourceType = "Exchange" + DataSourceTypeFileFolder DataSourceType = "FileFolder" + DataSourceTypeGenericDataSource DataSourceType = "GenericDataSource" + DataSourceTypeInvalid DataSourceType = "Invalid" + DataSourceTypeSAPAseDatabase DataSourceType = "SAPAseDatabase" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + DataSourceTypeSAPHanaDatabase DataSourceType = "SAPHanaDatabase" + DataSourceTypeSQLDB DataSourceType = "SQLDB" + DataSourceTypeSQLDataBase DataSourceType = "SQLDataBase" + DataSourceTypeSharepoint DataSourceType = "Sharepoint" + DataSourceTypeSystemState DataSourceType = "SystemState" + DataSourceTypeVM DataSourceType = "VM" + DataSourceTypeVMwareVM DataSourceType = "VMwareVM" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAzureFileShare), + string(DataSourceTypeAzureSqlDb), + string(DataSourceTypeClient), + string(DataSourceTypeExchange), + string(DataSourceTypeFileFolder), + string(DataSourceTypeGenericDataSource), + string(DataSourceTypeInvalid), + string(DataSourceTypeSAPAseDatabase), + string(DataSourceTypeSAPHanaDBInstance), + string(DataSourceTypeSAPHanaDatabase), + string(DataSourceTypeSQLDB), + string(DataSourceTypeSQLDataBase), + string(DataSourceTypeSharepoint), + string(DataSourceTypeSystemState), + string(DataSourceTypeVM), + string(DataSourceTypeVMwareVM), + } +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "azurefileshare": DataSourceTypeAzureFileShare, + "azuresqldb": DataSourceTypeAzureSqlDb, + "client": DataSourceTypeClient, + "exchange": DataSourceTypeExchange, + "filefolder": DataSourceTypeFileFolder, + "genericdatasource": DataSourceTypeGenericDataSource, + "invalid": DataSourceTypeInvalid, + "sapasedatabase": DataSourceTypeSAPAseDatabase, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "saphanadatabase": DataSourceTypeSAPHanaDatabase, + "sqldb": DataSourceTypeSQLDB, + "sqldatabase": DataSourceTypeSQLDataBase, + "sharepoint": DataSourceTypeSharepoint, + "systemstate": DataSourceTypeSystemState, + "vm": DataSourceTypeVM, + "vmwarevm": DataSourceTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} + +type FabricName string + +const ( + FabricNameAzure FabricName = "Azure" + FabricNameInvalid FabricName = "Invalid" +) + +func PossibleValuesForFabricName() []string { + return []string{ + string(FabricNameAzure), + string(FabricNameInvalid), + } +} + +func parseFabricName(input string) (*FabricName, error) { + vals := map[string]FabricName{ + "azure": FabricNameAzure, + "invalid": FabricNameInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FabricName(input) + return &out, nil +} + +type ProtectionStatus string + +const ( + ProtectionStatusInvalid ProtectionStatus = "Invalid" + ProtectionStatusNotProtected ProtectionStatus = "NotProtected" + ProtectionStatusProtected ProtectionStatus = "Protected" + ProtectionStatusProtecting ProtectionStatus = "Protecting" + ProtectionStatusProtectionFailed ProtectionStatus = "ProtectionFailed" +) + +func PossibleValuesForProtectionStatus() []string { + return []string{ + string(ProtectionStatusInvalid), + string(ProtectionStatusNotProtected), + string(ProtectionStatusProtected), + string(ProtectionStatusProtecting), + string(ProtectionStatusProtectionFailed), + } +} + +func parseProtectionStatus(input string) (*ProtectionStatus, error) { + vals := map[string]ProtectionStatus{ + "invalid": ProtectionStatusInvalid, + "notprotected": ProtectionStatusNotProtected, + "protected": ProtectionStatusProtected, + "protecting": ProtectionStatusProtecting, + "protectionfailed": ProtectionStatusProtectionFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location.go new file mode 100644 index 00000000000..aa1928c467e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location.go @@ -0,0 +1,121 @@ +package backupstatus + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location_test.go new file mode 100644 index 00000000000..83bf34ce9e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/id_location_test.go @@ -0,0 +1,237 @@ +package backupstatus + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/method_get_autorest.go new file mode 100644 index 00000000000..5bdbd049ea0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/method_get_autorest.go @@ -0,0 +1,70 @@ +package backupstatus + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *BackupStatusResponse +} + +// Get ... +func (c BackupStatusClient) Get(ctx context.Context, id LocationId, input BackupStatusRequest) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "backupstatus.BackupStatusClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupstatus.BackupStatusClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupstatus.BackupStatusClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c BackupStatusClient) preparerForGet(ctx context.Context, id LocationId, input BackupStatusRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStatus", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c BackupStatusClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusrequest.go new file mode 100644 index 00000000000..18355d1d1a4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusrequest.go @@ -0,0 +1,10 @@ +package backupstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupStatusRequest struct { + PoLogicalName *string `json:"poLogicalName,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceType *DataSourceType `json:"resourceType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusresponse.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusresponse.go new file mode 100644 index 00000000000..18836147a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/model_backupstatusresponse.go @@ -0,0 +1,18 @@ +package backupstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupStatusResponse struct { + AcquireStorageAccountLock *AcquireStorageAccountLock `json:"acquireStorageAccountLock,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + FabricName *FabricName `json:"fabricName,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ProtectionStatus *ProtectionStatus `json:"protectionStatus,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` + VaultId *string `json:"vaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/version.go new file mode 100644 index 00000000000..2e8d80d9370 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus/version.go @@ -0,0 +1,12 @@ +package backupstatus + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupstatus/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/README.md new file mode 100644 index 00000000000..4bcd0f644ff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries` Documentation + +The `backupusagesummaries` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries" +``` + + +### Client Initialization + +```go +client := backupusagesummaries.NewBackupUsageSummariesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupUsageSummariesClient.List` + +```go +ctx := context.TODO() +id := backupusagesummaries.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +read, err := client.List(ctx, id, backupusagesummaries.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/client.go new file mode 100644 index 00000000000..d6dbffa806e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/client.go @@ -0,0 +1,18 @@ +package backupusagesummaries + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupUsageSummariesClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupUsageSummariesClientWithBaseURI(endpoint string) BackupUsageSummariesClient { + return BackupUsageSummariesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/constants.go new file mode 100644 index 00000000000..397d5b32331 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/constants.go @@ -0,0 +1,46 @@ +package backupusagesummaries + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesUnit string + +const ( + UsagesUnitBytes UsagesUnit = "Bytes" + UsagesUnitBytesPerSecond UsagesUnit = "BytesPerSecond" + UsagesUnitCount UsagesUnit = "Count" + UsagesUnitCountPerSecond UsagesUnit = "CountPerSecond" + UsagesUnitPercent UsagesUnit = "Percent" + UsagesUnitSeconds UsagesUnit = "Seconds" +) + +func PossibleValuesForUsagesUnit() []string { + return []string{ + string(UsagesUnitBytes), + string(UsagesUnitBytesPerSecond), + string(UsagesUnitCount), + string(UsagesUnitCountPerSecond), + string(UsagesUnitPercent), + string(UsagesUnitSeconds), + } +} + +func parseUsagesUnit(input string) (*UsagesUnit, error) { + vals := map[string]UsagesUnit{ + "bytes": UsagesUnitBytes, + "bytespersecond": UsagesUnitBytesPerSecond, + "count": UsagesUnitCount, + "countpersecond": UsagesUnitCountPerSecond, + "percent": UsagesUnitPercent, + "seconds": UsagesUnitSeconds, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsagesUnit(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault.go new file mode 100644 index 00000000000..389ed893fc0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault.go @@ -0,0 +1,130 @@ +package backupusagesummaries + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault_test.go new file mode 100644 index 00000000000..d76a76435c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/id_vault_test.go @@ -0,0 +1,282 @@ +package backupusagesummaries + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/method_list_autorest.go new file mode 100644 index 00000000000..f3562412897 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/method_list_autorest.go @@ -0,0 +1,98 @@ +package backupusagesummaries + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *BackupManagementUsageList +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupUsageSummariesClient) List(ctx context.Context, id VaultId, options ListOperationOptions) (result ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupusagesummaries.BackupUsageSummariesClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupusagesummaries.BackupUsageSummariesClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupusagesummaries.BackupUsageSummariesClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForList prepares the List request. +func (c BackupUsageSummariesClient) preparerForList(ctx context.Context, id VaultId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupUsageSummaries", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupUsageSummariesClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusage.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusage.go new file mode 100644 index 00000000000..decb29b6951 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusage.go @@ -0,0 +1,31 @@ +package backupusagesummaries + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementUsage struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *NameInfo `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + QuotaPeriod *string `json:"quotaPeriod,omitempty"` + Unit *UsagesUnit `json:"unit,omitempty"` +} + +func (o *BackupManagementUsage) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupManagementUsage) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusagelist.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusagelist.go new file mode 100644 index 00000000000..e2014e84694 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_backupmanagementusagelist.go @@ -0,0 +1,8 @@ +package backupusagesummaries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementUsageList struct { + Value *[]BackupManagementUsage `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_nameinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_nameinfo.go new file mode 100644 index 00000000000..68fde56d864 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/model_nameinfo.go @@ -0,0 +1,9 @@ +package backupusagesummaries + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameInfo struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/version.go new file mode 100644 index 00000000000..a304372eaeb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries/version.go @@ -0,0 +1,12 @@ +package backupusagesummaries + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupusagesummaries/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/README.md new file mode 100644 index 00000000000..5e8cb69f3df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems` Documentation + +The `backupworkloaditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems" +``` + + +### Client Initialization + +```go +client := backupworkloaditems.NewBackupWorkloadItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BackupWorkloadItemsClient.List` + +```go +ctx := context.TODO() +id := backupworkloaditems.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +// alternatively `client.List(ctx, id, backupworkloaditems.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, backupworkloaditems.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/client.go new file mode 100644 index 00000000000..2493a9d3ce5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/client.go @@ -0,0 +1,18 @@ +package backupworkloaditems + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupWorkloadItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewBackupWorkloadItemsClientWithBaseURI(endpoint string) BackupWorkloadItemsClient { + return BackupWorkloadItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/constants.go new file mode 100644 index 00000000000..53f53e17687 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/constants.go @@ -0,0 +1,74 @@ +package backupworkloaditems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionStatus string + +const ( + ProtectionStatusInvalid ProtectionStatus = "Invalid" + ProtectionStatusNotProtected ProtectionStatus = "NotProtected" + ProtectionStatusProtected ProtectionStatus = "Protected" + ProtectionStatusProtecting ProtectionStatus = "Protecting" + ProtectionStatusProtectionFailed ProtectionStatus = "ProtectionFailed" +) + +func PossibleValuesForProtectionStatus() []string { + return []string{ + string(ProtectionStatusInvalid), + string(ProtectionStatusNotProtected), + string(ProtectionStatusProtected), + string(ProtectionStatusProtecting), + string(ProtectionStatusProtectionFailed), + } +} + +func parseProtectionStatus(input string) (*ProtectionStatus, error) { + vals := map[string]ProtectionStatus{ + "invalid": ProtectionStatusInvalid, + "notprotected": ProtectionStatusNotProtected, + "protected": ProtectionStatusProtected, + "protecting": ProtectionStatusProtecting, + "protectionfailed": ProtectionStatusProtectionFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionStatus(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer.go new file mode 100644 index 00000000000..d0642507a3e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer.go @@ -0,0 +1,148 @@ +package backupworkloaditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ProtectionContainerId{} + +// ProtectionContainerId is a struct representing the Resource ID for a Protection Container +type ProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string +} + +// NewProtectionContainerID returns a new ProtectionContainerId struct +func NewProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string) ProtectionContainerId { + return ProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + } +} + +// ParseProtectionContainerID parses 'input' into a ProtectionContainerId +func ParseProtectionContainerID(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProtectionContainerIDInsensitively parses 'input' case-insensitively into a ProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseProtectionContainerIDInsensitively(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + return nil +} + +// ValidateProtectionContainerID checks that 'input' can be parsed as a Protection Container ID +func ValidateProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protection Container ID +func (id ProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protection Container ID +func (id ProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + } +} + +// String returns a human-readable description of this Protection Container ID +func (id ProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + } + return fmt.Sprintf("Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer_test.go new file mode 100644 index 00000000000..eba02653ce8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/id_protectioncontainer_test.go @@ -0,0 +1,372 @@ +package backupworkloaditems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectionContainerId{} + +func TestNewProtectionContainerID(t *testing.T) { + id := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } +} + +func TestFormatProtectionContainerID(t *testing.T) { + actual := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestParseProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestSegmentsForProtectionContainerId(t *testing.T) { + segments := ProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/method_list_autorest.go new file mode 100644 index 00000000000..a730a74a266 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/method_list_autorest.go @@ -0,0 +1,215 @@ +package backupworkloaditems + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]WorkloadItemResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []WorkloadItemResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c BackupWorkloadItemsClient) List(ctx context.Context, id ProtectionContainerId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c BackupWorkloadItemsClient) preparerForList(ctx context.Context, id ProtectionContainerId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/items", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c BackupWorkloadItemsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c BackupWorkloadItemsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []WorkloadItemResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "backupworkloaditems.BackupWorkloadItemsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c BackupWorkloadItemsClient) ListComplete(ctx context.Context, id ProtectionContainerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkloadItemResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c BackupWorkloadItemsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProtectionContainerId, options ListOperationOptions, predicate WorkloadItemResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]WorkloadItemResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloaditem.go new file mode 100644 index 00000000000..69068df164a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloaditem.go @@ -0,0 +1,49 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadItem = AzureVMWorkloadItem{} + +type AzureVMWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadItem{} + +func (s AzureVMWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadItem: %+v", err) + } + decoded["workloadItemType"] = "AzureVmWorkloadItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go new file mode 100644 index 00000000000..d2b7b5b550a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasedatabaseworkloaditem.go @@ -0,0 +1,49 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadItem = AzureVMWorkloadSAPAseDatabaseWorkloadItem{} + +type AzureVMWorkloadSAPAseDatabaseWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseDatabaseWorkloadItem{} + +func (s AzureVMWorkloadSAPAseDatabaseWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseDatabaseWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + decoded["workloadItemType"] = "SAPAseDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go new file mode 100644 index 00000000000..1f00dd9c164 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsapasesystemworkloaditem.go @@ -0,0 +1,49 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadItem = AzureVMWorkloadSAPAseSystemWorkloadItem{} + +type AzureVMWorkloadSAPAseSystemWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseSystemWorkloadItem{} + +func (s AzureVMWorkloadSAPAseSystemWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseSystemWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + decoded["workloadItemType"] = "SAPAseSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go new file mode 100644 index 00000000000..49058e10e85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanadatabaseworkloaditem.go @@ -0,0 +1,49 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadItem = AzureVMWorkloadSAPHanaDatabaseWorkloadItem{} + +type AzureVMWorkloadSAPHanaDatabaseWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseWorkloadItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + decoded["workloadItemType"] = "SAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go new file mode 100644 index 00000000000..9b7e843c0bd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsaphanasystemworkloaditem.go @@ -0,0 +1,49 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadItem = AzureVMWorkloadSAPHanaSystemWorkloadItem{} + +type AzureVMWorkloadSAPHanaSystemWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaSystemWorkloadItem{} + +func (s AzureVMWorkloadSAPHanaSystemWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaSystemWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + decoded["workloadItemType"] = "SAPHanaSystem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go new file mode 100644 index 00000000000..d857da81c38 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqldatabaseworkloaditem.go @@ -0,0 +1,49 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadItem = AzureVMWorkloadSQLDatabaseWorkloadItem{} + +type AzureVMWorkloadSQLDatabaseWorkloadItem struct { + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseWorkloadItem{} + +func (s AzureVMWorkloadSQLDatabaseWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + decoded["workloadItemType"] = "SQLDataBase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go new file mode 100644 index 00000000000..1179d25dea3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_azurevmworkloadsqlinstanceworkloaditem.go @@ -0,0 +1,50 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ WorkloadItem = AzureVMWorkloadSQLInstanceWorkloadItem{} + +type AzureVMWorkloadSQLInstanceWorkloadItem struct { + DataDirectoryPaths *[]SQLDataDirectory `json:"dataDirectoryPaths,omitempty"` + IsAutoProtectable *bool `json:"isAutoProtectable,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ServerName *string `json:"serverName,omitempty"` + SubWorkloadItemCount *int64 `json:"subWorkloadItemCount,omitempty"` + Subinquireditemcount *int64 `json:"subinquireditemcount,omitempty"` + + // Fields inherited from WorkloadItem + BackupManagementType *string `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadSQLInstanceWorkloadItem{} + +func (s AzureVMWorkloadSQLInstanceWorkloadItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLInstanceWorkloadItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + decoded["workloadItemType"] = "SQLInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_sqldatadirectory.go new file mode 100644 index 00000000000..2bae2b886be --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_sqldatadirectory.go @@ -0,0 +1,10 @@ +package backupworkloaditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectory struct { + LogicalName *string `json:"logicalName,omitempty"` + Path *string `json:"path,omitempty"` + Type *SQLDataDirectoryType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditem.go new file mode 100644 index 00000000000..83019e354ef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditem.go @@ -0,0 +1,101 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadItem interface { +} + +// RawWorkloadItemImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawWorkloadItemImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalWorkloadItemImplementation(input []byte) (WorkloadItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling WorkloadItem into map[string]interface: %+v", err) + } + + value, ok := temp["workloadItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadItem") { + var out AzureVMWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPAseSystem") { + var out AzureVMWorkloadSAPAseSystemWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseSystemWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAPHanaSystem") { + var out AzureVMWorkloadSAPHanaSystemWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaSystemWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLDataBase") { + var out AzureVMWorkloadSQLDatabaseWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseWorkloadItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLInstance") { + var out AzureVMWorkloadSQLInstanceWorkloadItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLInstanceWorkloadItem: %+v", err) + } + return out, nil + } + + out := RawWorkloadItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditemresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditemresource.go new file mode 100644 index 00000000000..2c4a15f25c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/model_workloaditemresource.go @@ -0,0 +1,50 @@ +package backupworkloaditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkloadItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &WorkloadItemResource{} + +func (s *WorkloadItemResource) UnmarshalJSON(bytes []byte) error { + type alias WorkloadItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into WorkloadItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling WorkloadItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalWorkloadItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'WorkloadItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/predicates.go new file mode 100644 index 00000000000..98e6f2ee1de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/predicates.go @@ -0,0 +1,37 @@ +package backupworkloaditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadItemResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkloadItemResourceOperationPredicate) Matches(input WorkloadItemResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/version.go new file mode 100644 index 00000000000..713207f3fb6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems/version.go @@ -0,0 +1,12 @@ +package backupworkloaditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/backupworkloaditems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/client.go new file mode 100644 index 00000000000..27b7a8d7c09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/client.go @@ -0,0 +1,239 @@ +package v2024_04_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "github.com/Azure/go-autorest/autorest" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupengines" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupjobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backuppolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectableitems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupprotectionintent" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourceencryptionconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcestorageconfigsnoncrr" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupresourcevaultconfigs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backups" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupstatus" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupusagesummaries" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/backupworkloaditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/datamove" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/jobs" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/operation" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/restores" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/securitypins" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers" + "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation" +) + +type Client struct { + BackupEngines *backupengines.BackupEnginesClient + BackupJobs *backupjobs.BackupJobsClient + BackupPolicies *backuppolicies.BackupPoliciesClient + BackupProtectableItems *backupprotectableitems.BackupProtectableItemsClient + BackupProtectedItems *backupprotecteditems.BackupProtectedItemsClient + BackupProtectionContainers *backupprotectioncontainers.BackupProtectionContainersClient + BackupProtectionIntent *backupprotectionintent.BackupProtectionIntentClient + BackupResourceEncryptionConfigs *backupresourceencryptionconfigs.BackupResourceEncryptionConfigsClient + BackupResourceStorageConfigsNonCRR *backupresourcestorageconfigsnoncrr.BackupResourceStorageConfigsNonCRRClient + BackupResourceVaultConfigs *backupresourcevaultconfigs.BackupResourceVaultConfigsClient + BackupStatus *backupstatus.BackupStatusClient + BackupUsageSummaries *backupusagesummaries.BackupUsageSummariesClient + BackupWorkloadItems *backupworkloaditems.BackupWorkloadItemsClient + Backups *backups.BackupsClient + DataMove *datamove.DataMoveClient + FeatureSupport *featuresupport.FeatureSupportClient + FetchTieringCost *fetchtieringcost.FetchTieringCostClient + ItemLevelRecoveryConnections *itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient + JobCancellations *jobcancellations.JobCancellationsClient + JobDetails *jobdetails.JobDetailsClient + Jobs *jobs.JobsClient + Operation *operation.OperationClient + PrivateEndpointConnection *privateendpointconnection.PrivateEndpointConnectionClient + ProtectableContainers *protectablecontainers.ProtectableContainersClient + ProtectedItems *protecteditems.ProtectedItemsClient + ProtectionContainers *protectioncontainers.ProtectionContainersClient + ProtectionIntent *protectionintent.ProtectionIntentClient + ProtectionPolicies *protectionpolicies.ProtectionPoliciesClient + RecoveryPoint *recoverypoint.RecoveryPointClient + RecoveryPoints *recoverypoints.RecoveryPointsClient + RecoveryPointsRecommendedForMove *recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient + ResourceGuardProxies *resourceguardproxies.ResourceGuardProxiesClient + ResourceGuardProxy *resourceguardproxy.ResourceGuardProxyClient + Restores *restores.RestoresClient + SecurityPINs *securitypins.SecurityPINsClient + SoftDeletedContainers *softdeletedcontainers.SoftDeletedContainersClient + ValidateOperation *validateoperation.ValidateOperationClient +} + +func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client { + + backupEnginesClient := backupengines.NewBackupEnginesClientWithBaseURI(endpoint) + configureAuthFunc(&backupEnginesClient.Client) + + backupJobsClient := backupjobs.NewBackupJobsClientWithBaseURI(endpoint) + configureAuthFunc(&backupJobsClient.Client) + + backupPoliciesClient := backuppolicies.NewBackupPoliciesClientWithBaseURI(endpoint) + configureAuthFunc(&backupPoliciesClient.Client) + + backupProtectableItemsClient := backupprotectableitems.NewBackupProtectableItemsClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectableItemsClient.Client) + + backupProtectedItemsClient := backupprotecteditems.NewBackupProtectedItemsClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectedItemsClient.Client) + + backupProtectionContainersClient := backupprotectioncontainers.NewBackupProtectionContainersClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectionContainersClient.Client) + + backupProtectionIntentClient := backupprotectionintent.NewBackupProtectionIntentClientWithBaseURI(endpoint) + configureAuthFunc(&backupProtectionIntentClient.Client) + + backupResourceEncryptionConfigsClient := backupresourceencryptionconfigs.NewBackupResourceEncryptionConfigsClientWithBaseURI(endpoint) + configureAuthFunc(&backupResourceEncryptionConfigsClient.Client) + + backupResourceStorageConfigsNonCRRClient := backupresourcestorageconfigsnoncrr.NewBackupResourceStorageConfigsNonCRRClientWithBaseURI(endpoint) + configureAuthFunc(&backupResourceStorageConfigsNonCRRClient.Client) + + backupResourceVaultConfigsClient := backupresourcevaultconfigs.NewBackupResourceVaultConfigsClientWithBaseURI(endpoint) + configureAuthFunc(&backupResourceVaultConfigsClient.Client) + + backupStatusClient := backupstatus.NewBackupStatusClientWithBaseURI(endpoint) + configureAuthFunc(&backupStatusClient.Client) + + backupUsageSummariesClient := backupusagesummaries.NewBackupUsageSummariesClientWithBaseURI(endpoint) + configureAuthFunc(&backupUsageSummariesClient.Client) + + backupWorkloadItemsClient := backupworkloaditems.NewBackupWorkloadItemsClientWithBaseURI(endpoint) + configureAuthFunc(&backupWorkloadItemsClient.Client) + + backupsClient := backups.NewBackupsClientWithBaseURI(endpoint) + configureAuthFunc(&backupsClient.Client) + + dataMoveClient := datamove.NewDataMoveClientWithBaseURI(endpoint) + configureAuthFunc(&dataMoveClient.Client) + + featureSupportClient := featuresupport.NewFeatureSupportClientWithBaseURI(endpoint) + configureAuthFunc(&featureSupportClient.Client) + + fetchTieringCostClient := fetchtieringcost.NewFetchTieringCostClientWithBaseURI(endpoint) + configureAuthFunc(&fetchTieringCostClient.Client) + + itemLevelRecoveryConnectionsClient := itemlevelrecoveryconnections.NewItemLevelRecoveryConnectionsClientWithBaseURI(endpoint) + configureAuthFunc(&itemLevelRecoveryConnectionsClient.Client) + + jobCancellationsClient := jobcancellations.NewJobCancellationsClientWithBaseURI(endpoint) + configureAuthFunc(&jobCancellationsClient.Client) + + jobDetailsClient := jobdetails.NewJobDetailsClientWithBaseURI(endpoint) + configureAuthFunc(&jobDetailsClient.Client) + + jobsClient := jobs.NewJobsClientWithBaseURI(endpoint) + configureAuthFunc(&jobsClient.Client) + + operationClient := operation.NewOperationClientWithBaseURI(endpoint) + configureAuthFunc(&operationClient.Client) + + privateEndpointConnectionClient := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI(endpoint) + configureAuthFunc(&privateEndpointConnectionClient.Client) + + protectableContainersClient := protectablecontainers.NewProtectableContainersClientWithBaseURI(endpoint) + configureAuthFunc(&protectableContainersClient.Client) + + protectedItemsClient := protecteditems.NewProtectedItemsClientWithBaseURI(endpoint) + configureAuthFunc(&protectedItemsClient.Client) + + protectionContainersClient := protectioncontainers.NewProtectionContainersClientWithBaseURI(endpoint) + configureAuthFunc(&protectionContainersClient.Client) + + protectionIntentClient := protectionintent.NewProtectionIntentClientWithBaseURI(endpoint) + configureAuthFunc(&protectionIntentClient.Client) + + protectionPoliciesClient := protectionpolicies.NewProtectionPoliciesClientWithBaseURI(endpoint) + configureAuthFunc(&protectionPoliciesClient.Client) + + recoveryPointClient := recoverypoint.NewRecoveryPointClientWithBaseURI(endpoint) + configureAuthFunc(&recoveryPointClient.Client) + + recoveryPointsClient := recoverypoints.NewRecoveryPointsClientWithBaseURI(endpoint) + configureAuthFunc(&recoveryPointsClient.Client) + + recoveryPointsRecommendedForMoveClient := recoverypointsrecommendedformove.NewRecoveryPointsRecommendedForMoveClientWithBaseURI(endpoint) + configureAuthFunc(&recoveryPointsRecommendedForMoveClient.Client) + + resourceGuardProxiesClient := resourceguardproxies.NewResourceGuardProxiesClientWithBaseURI(endpoint) + configureAuthFunc(&resourceGuardProxiesClient.Client) + + resourceGuardProxyClient := resourceguardproxy.NewResourceGuardProxyClientWithBaseURI(endpoint) + configureAuthFunc(&resourceGuardProxyClient.Client) + + restoresClient := restores.NewRestoresClientWithBaseURI(endpoint) + configureAuthFunc(&restoresClient.Client) + + securityPINsClient := securitypins.NewSecurityPINsClientWithBaseURI(endpoint) + configureAuthFunc(&securityPINsClient.Client) + + softDeletedContainersClient := softdeletedcontainers.NewSoftDeletedContainersClientWithBaseURI(endpoint) + configureAuthFunc(&softDeletedContainersClient.Client) + + validateOperationClient := validateoperation.NewValidateOperationClientWithBaseURI(endpoint) + configureAuthFunc(&validateOperationClient.Client) + + return Client{ + BackupEngines: &backupEnginesClient, + BackupJobs: &backupJobsClient, + BackupPolicies: &backupPoliciesClient, + BackupProtectableItems: &backupProtectableItemsClient, + BackupProtectedItems: &backupProtectedItemsClient, + BackupProtectionContainers: &backupProtectionContainersClient, + BackupProtectionIntent: &backupProtectionIntentClient, + BackupResourceEncryptionConfigs: &backupResourceEncryptionConfigsClient, + BackupResourceStorageConfigsNonCRR: &backupResourceStorageConfigsNonCRRClient, + BackupResourceVaultConfigs: &backupResourceVaultConfigsClient, + BackupStatus: &backupStatusClient, + BackupUsageSummaries: &backupUsageSummariesClient, + BackupWorkloadItems: &backupWorkloadItemsClient, + Backups: &backupsClient, + DataMove: &dataMoveClient, + FeatureSupport: &featureSupportClient, + FetchTieringCost: &fetchTieringCostClient, + ItemLevelRecoveryConnections: &itemLevelRecoveryConnectionsClient, + JobCancellations: &jobCancellationsClient, + JobDetails: &jobDetailsClient, + Jobs: &jobsClient, + Operation: &operationClient, + PrivateEndpointConnection: &privateEndpointConnectionClient, + ProtectableContainers: &protectableContainersClient, + ProtectedItems: &protectedItemsClient, + ProtectionContainers: &protectionContainersClient, + ProtectionIntent: &protectionIntentClient, + ProtectionPolicies: &protectionPoliciesClient, + RecoveryPoint: &recoveryPointClient, + RecoveryPoints: &recoveryPointsClient, + RecoveryPointsRecommendedForMove: &recoveryPointsRecommendedForMoveClient, + ResourceGuardProxies: &resourceGuardProxiesClient, + ResourceGuardProxy: &resourceGuardProxyClient, + Restores: &restoresClient, + SecurityPINs: &securityPINsClient, + SoftDeletedContainers: &softDeletedContainersClient, + ValidateOperation: &validateOperationClient, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/README.md new file mode 100644 index 00000000000..7036890c92a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/datamove` Documentation + +The `datamove` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/datamove" +``` + + +### Client Initialization + +```go +client := datamove.NewDataMoveClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataMoveClient.BMSPrepareDataMove` + +```go +ctx := context.TODO() +id := datamove.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := datamove.PrepareDataMoveRequest{ + // ... +} + + +if err := client.BMSPrepareDataMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataMoveClient.BMSTriggerDataMove` + +```go +ctx := context.TODO() +id := datamove.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := datamove.TriggerDataMoveRequest{ + // ... +} + + +if err := client.BMSTriggerDataMoveThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/client.go new file mode 100644 index 00000000000..bca13a32cd6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/client.go @@ -0,0 +1,18 @@ +package datamove + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataMoveClient struct { + Client autorest.Client + baseUri string +} + +func NewDataMoveClientWithBaseURI(endpoint string) DataMoveClient { + return DataMoveClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/constants.go new file mode 100644 index 00000000000..86a3e471eea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/constants.go @@ -0,0 +1,37 @@ +package datamove + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataMoveLevel string + +const ( + DataMoveLevelContainer DataMoveLevel = "Container" + DataMoveLevelInvalid DataMoveLevel = "Invalid" + DataMoveLevelVault DataMoveLevel = "Vault" +) + +func PossibleValuesForDataMoveLevel() []string { + return []string{ + string(DataMoveLevelContainer), + string(DataMoveLevelInvalid), + string(DataMoveLevelVault), + } +} + +func parseDataMoveLevel(input string) (*DataMoveLevel, error) { + vals := map[string]DataMoveLevel{ + "container": DataMoveLevelContainer, + "invalid": DataMoveLevelInvalid, + "vault": DataMoveLevelVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataMoveLevel(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault.go new file mode 100644 index 00000000000..5908a75a95d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault.go @@ -0,0 +1,130 @@ +package datamove + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault_test.go new file mode 100644 index 00000000000..8f4c2dcb1ae --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/id_vault_test.go @@ -0,0 +1,282 @@ +package datamove + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmspreparedatamove_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmspreparedatamove_autorest.go new file mode 100644 index 00000000000..460642bf637 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmspreparedatamove_autorest.go @@ -0,0 +1,79 @@ +package datamove + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BMSPrepareDataMoveOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// BMSPrepareDataMove ... +func (c DataMoveClient) BMSPrepareDataMove(ctx context.Context, id VaultId, input PrepareDataMoveRequest) (result BMSPrepareDataMoveOperationResponse, err error) { + req, err := c.preparerForBMSPrepareDataMove(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSPrepareDataMove", nil, "Failure preparing request") + return + } + + result, err = c.senderForBMSPrepareDataMove(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSPrepareDataMove", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// BMSPrepareDataMoveThenPoll performs BMSPrepareDataMove then polls until it's completed +func (c DataMoveClient) BMSPrepareDataMoveThenPoll(ctx context.Context, id VaultId, input PrepareDataMoveRequest) error { + result, err := c.BMSPrepareDataMove(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BMSPrepareDataMove: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after BMSPrepareDataMove: %+v", err) + } + + return nil +} + +// preparerForBMSPrepareDataMove prepares the BMSPrepareDataMove request. +func (c DataMoveClient) preparerForBMSPrepareDataMove(ctx context.Context, id VaultId, input PrepareDataMoveRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig/prepareDataMove", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForBMSPrepareDataMove sends the BMSPrepareDataMove request. The method will close the +// http.Response Body if it receives an error. +func (c DataMoveClient) senderForBMSPrepareDataMove(ctx context.Context, req *http.Request) (future BMSPrepareDataMoveOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmstriggerdatamove_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmstriggerdatamove_autorest.go new file mode 100644 index 00000000000..5f89d916019 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/method_bmstriggerdatamove_autorest.go @@ -0,0 +1,79 @@ +package datamove + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BMSTriggerDataMoveOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// BMSTriggerDataMove ... +func (c DataMoveClient) BMSTriggerDataMove(ctx context.Context, id VaultId, input TriggerDataMoveRequest) (result BMSTriggerDataMoveOperationResponse, err error) { + req, err := c.preparerForBMSTriggerDataMove(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSTriggerDataMove", nil, "Failure preparing request") + return + } + + result, err = c.senderForBMSTriggerDataMove(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "datamove.DataMoveClient", "BMSTriggerDataMove", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// BMSTriggerDataMoveThenPoll performs BMSTriggerDataMove then polls until it's completed +func (c DataMoveClient) BMSTriggerDataMoveThenPoll(ctx context.Context, id VaultId, input TriggerDataMoveRequest) error { + result, err := c.BMSTriggerDataMove(ctx, id, input) + if err != nil { + return fmt.Errorf("performing BMSTriggerDataMove: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after BMSTriggerDataMove: %+v", err) + } + + return nil +} + +// preparerForBMSTriggerDataMove prepares the BMSTriggerDataMove request. +func (c DataMoveClient) preparerForBMSTriggerDataMove(ctx context.Context, id VaultId, input TriggerDataMoveRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupStorageConfig/vaultStorageConfig/triggerDataMove", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForBMSTriggerDataMove sends the BMSTriggerDataMove request. The method will close the +// http.Response Body if it receives an error. +func (c DataMoveClient) senderForBMSTriggerDataMove(ctx context.Context, req *http.Request) (future BMSTriggerDataMoveOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_preparedatamoverequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_preparedatamoverequest.go new file mode 100644 index 00000000000..f2e39d1cd8a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_preparedatamoverequest.go @@ -0,0 +1,12 @@ +package datamove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrepareDataMoveRequest struct { + DataMoveLevel DataMoveLevel `json:"dataMoveLevel"` + IgnoreMoved *bool `json:"ignoreMoved,omitempty"` + SourceContainerArmIds *[]string `json:"sourceContainerArmIds,omitempty"` + TargetRegion string `json:"targetRegion"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_triggerdatamoverequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_triggerdatamoverequest.go new file mode 100644 index 00000000000..eb35ce70218 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/model_triggerdatamoverequest.go @@ -0,0 +1,13 @@ +package datamove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerDataMoveRequest struct { + CorrelationId string `json:"correlationId"` + DataMoveLevel DataMoveLevel `json:"dataMoveLevel"` + PauseGC *bool `json:"pauseGC,omitempty"` + SourceContainerArmIds *[]string `json:"sourceContainerArmIds,omitempty"` + SourceRegion string `json:"sourceRegion"` + SourceResourceId string `json:"sourceResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/datamove/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/version.go new file mode 100644 index 00000000000..28351feda01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/datamove/version.go @@ -0,0 +1,12 @@ +package datamove + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/datamove/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/README.md new file mode 100644 index 00000000000..d417a3c4170 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport` Documentation + +The `featuresupport` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport" +``` + + +### Client Initialization + +```go +client := featuresupport.NewFeatureSupportClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FeatureSupportClient.Validate` + +```go +ctx := context.TODO() +id := featuresupport.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := featuresupport.FeatureSupportRequest{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/client.go new file mode 100644 index 00000000000..b4f22ceed18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/client.go @@ -0,0 +1,18 @@ +package featuresupport + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureSupportClient struct { + Client autorest.Client + baseUri string +} + +func NewFeatureSupportClientWithBaseURI(endpoint string) FeatureSupportClient { + return FeatureSupportClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/constants.go new file mode 100644 index 00000000000..e44ccfc6c48 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/constants.go @@ -0,0 +1,43 @@ +package featuresupport + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportStatus string + +const ( + SupportStatusDefaultOFF SupportStatus = "DefaultOFF" + SupportStatusDefaultON SupportStatus = "DefaultON" + SupportStatusInvalid SupportStatus = "Invalid" + SupportStatusNotSupported SupportStatus = "NotSupported" + SupportStatusSupported SupportStatus = "Supported" +) + +func PossibleValuesForSupportStatus() []string { + return []string{ + string(SupportStatusDefaultOFF), + string(SupportStatusDefaultON), + string(SupportStatusInvalid), + string(SupportStatusNotSupported), + string(SupportStatusSupported), + } +} + +func parseSupportStatus(input string) (*SupportStatus, error) { + vals := map[string]SupportStatus{ + "defaultoff": SupportStatusDefaultOFF, + "defaulton": SupportStatusDefaultON, + "invalid": SupportStatusInvalid, + "notsupported": SupportStatusNotSupported, + "supported": SupportStatusSupported, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location.go new file mode 100644 index 00000000000..e226fb08ca7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location.go @@ -0,0 +1,121 @@ +package featuresupport + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location_test.go new file mode 100644 index 00000000000..e08a74f19c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/id_location_test.go @@ -0,0 +1,237 @@ +package featuresupport + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/method_validate_autorest.go new file mode 100644 index 00000000000..71e04fc843f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/method_validate_autorest.go @@ -0,0 +1,70 @@ +package featuresupport + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + Model *AzureVMResourceFeatureSupportResponse +} + +// Validate ... +func (c FeatureSupportClient) Validate(ctx context.Context, id LocationId, input FeatureSupportRequest) (result ValidateOperationResponse, err error) { + req, err := c.preparerForValidate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "featuresupport.FeatureSupportClient", "Validate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "featuresupport.FeatureSupportClient", "Validate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForValidate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "featuresupport.FeatureSupportClient", "Validate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForValidate prepares the Validate request. +func (c FeatureSupportClient) preparerForValidate(ctx context.Context, id LocationId, input FeatureSupportRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupValidateFeatures", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForValidate handles the response to the Validate request. The method always +// closes the http.Response Body. +func (c FeatureSupportClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go new file mode 100644 index 00000000000..3d2bf051bd9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurebackupgoalfeaturesupportrequest.go @@ -0,0 +1,40 @@ +package featuresupport + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FeatureSupportRequest = AzureBackupGoalFeatureSupportRequest{} + +type AzureBackupGoalFeatureSupportRequest struct { + + // Fields inherited from FeatureSupportRequest +} + +var _ json.Marshaler = AzureBackupGoalFeatureSupportRequest{} + +func (s AzureBackupGoalFeatureSupportRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupGoalFeatureSupportRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupGoalFeatureSupportRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupGoalFeatureSupportRequest: %+v", err) + } + decoded["featureType"] = "AzureBackupGoals" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupGoalFeatureSupportRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go new file mode 100644 index 00000000000..b9e212a5b30 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportrequest.go @@ -0,0 +1,42 @@ +package featuresupport + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FeatureSupportRequest = AzureVMResourceFeatureSupportRequest{} + +type AzureVMResourceFeatureSupportRequest struct { + VMSize *string `json:"vmSize,omitempty"` + VMSku *string `json:"vmSku,omitempty"` + + // Fields inherited from FeatureSupportRequest +} + +var _ json.Marshaler = AzureVMResourceFeatureSupportRequest{} + +func (s AzureVMResourceFeatureSupportRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureVMResourceFeatureSupportRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMResourceFeatureSupportRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMResourceFeatureSupportRequest: %+v", err) + } + decoded["featureType"] = "AzureVMResourceBackup" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMResourceFeatureSupportRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go new file mode 100644 index 00000000000..b9d8a42e54a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_azurevmresourcefeaturesupportresponse.go @@ -0,0 +1,8 @@ +package featuresupport + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMResourceFeatureSupportResponse struct { + SupportStatus *SupportStatus `json:"supportStatus,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_featuresupportrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_featuresupportrequest.go new file mode 100644 index 00000000000..470e2a01527 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/model_featuresupportrequest.go @@ -0,0 +1,61 @@ +package featuresupport + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureSupportRequest interface { +} + +// RawFeatureSupportRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawFeatureSupportRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFeatureSupportRequestImplementation(input []byte) (FeatureSupportRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling FeatureSupportRequest into map[string]interface: %+v", err) + } + + value, ok := temp["featureType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupGoals") { + var out AzureBackupGoalFeatureSupportRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupGoalFeatureSupportRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVMResourceBackup") { + var out AzureVMResourceFeatureSupportRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMResourceFeatureSupportRequest: %+v", err) + } + return out, nil + } + + out := RawFeatureSupportRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/version.go new file mode 100644 index 00000000000..bbc1cbbc990 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/featuresupport/version.go @@ -0,0 +1,12 @@ +package featuresupport + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/featuresupport/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/README.md new file mode 100644 index 00000000000..05f1a58c275 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost` Documentation + +The `fetchtieringcost` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost" +``` + + +### Client Initialization + +```go +client := fetchtieringcost.NewFetchTieringCostClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FetchTieringCostClient.Post` + +```go +ctx := context.TODO() +id := fetchtieringcost.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := fetchtieringcost.FetchTieringCostInfoRequest{ + // ... +} + + +if err := client.PostThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/client.go new file mode 100644 index 00000000000..c3df44f183a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/client.go @@ -0,0 +1,18 @@ +package fetchtieringcost + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FetchTieringCostClient struct { + Client autorest.Client + baseUri string +} + +func NewFetchTieringCostClientWithBaseURI(endpoint string) FetchTieringCostClient { + return FetchTieringCostClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/constants.go new file mode 100644 index 00000000000..30e1f04df9f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/constants.go @@ -0,0 +1,68 @@ +package fetchtieringcost + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault.go new file mode 100644 index 00000000000..b828fbe3a6a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault.go @@ -0,0 +1,130 @@ +package fetchtieringcost + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault_test.go new file mode 100644 index 00000000000..8650d901df2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/id_vault_test.go @@ -0,0 +1,282 @@ +package fetchtieringcost + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/method_post_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/method_post_autorest.go new file mode 100644 index 00000000000..388a3bbc273 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/method_post_autorest.go @@ -0,0 +1,80 @@ +package fetchtieringcost + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PostOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response + Model *TieringCostInfo +} + +// Post ... +func (c FetchTieringCostClient) Post(ctx context.Context, id VaultId, input FetchTieringCostInfoRequest) (result PostOperationResponse, err error) { + req, err := c.preparerForPost(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "fetchtieringcost.FetchTieringCostClient", "Post", nil, "Failure preparing request") + return + } + + result, err = c.senderForPost(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "fetchtieringcost.FetchTieringCostClient", "Post", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PostThenPoll performs Post then polls until it's completed +func (c FetchTieringCostClient) PostThenPoll(ctx context.Context, id VaultId, input FetchTieringCostInfoRequest) error { + result, err := c.Post(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Post: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Post: %+v", err) + } + + return nil +} + +// preparerForPost prepares the Post request. +func (c FetchTieringCostClient) preparerForPost(ctx context.Context, id VaultId, input FetchTieringCostInfoRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupTieringCost/default/fetchTieringCost", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForPost sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (c FetchTieringCostClient) senderForPost(ctx context.Context, req *http.Request) (future PostOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go new file mode 100644 index 00000000000..4949da0922b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinfoforrehydrationrequest.go @@ -0,0 +1,46 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FetchTieringCostInfoRequest = FetchTieringCostInfoForRehydrationRequest{} + +type FetchTieringCostInfoForRehydrationRequest struct { + ContainerName string `json:"containerName"` + ProtectedItemName string `json:"protectedItemName"` + RecoveryPointId string `json:"recoveryPointId"` + RehydrationPriority RehydrationPriority `json:"rehydrationPriority"` + + // Fields inherited from FetchTieringCostInfoRequest + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +var _ json.Marshaler = FetchTieringCostInfoForRehydrationRequest{} + +func (s FetchTieringCostInfoForRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostInfoForRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + decoded["objectType"] = "FetchTieringCostInfoForRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinforequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinforequest.go new file mode 100644 index 00000000000..610799f0f84 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostinforequest.go @@ -0,0 +1,77 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FetchTieringCostInfoRequest interface { +} + +// RawFetchTieringCostInfoRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawFetchTieringCostInfoRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalFetchTieringCostInfoRequestImplementation(input []byte) (FetchTieringCostInfoRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostInfoRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "FetchTieringCostInfoForRehydrationRequest") { + var out FetchTieringCostInfoForRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostInfoForRehydrationRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FetchTieringCostSavingsInfoForPolicyRequest") { + var out FetchTieringCostSavingsInfoForPolicyRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FetchTieringCostSavingsInfoForProtectedItemRequest") { + var out FetchTieringCostSavingsInfoForProtectedItemRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FetchTieringCostSavingsInfoForVaultRequest") { + var out FetchTieringCostSavingsInfoForVaultRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + return out, nil + } + + out := RawFetchTieringCostInfoRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go new file mode 100644 index 00000000000..a3ef8489a2c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforpolicyrequest.go @@ -0,0 +1,43 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FetchTieringCostInfoRequest = FetchTieringCostSavingsInfoForPolicyRequest{} + +type FetchTieringCostSavingsInfoForPolicyRequest struct { + PolicyName string `json:"policyName"` + + // Fields inherited from FetchTieringCostInfoRequest + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +var _ json.Marshaler = FetchTieringCostSavingsInfoForPolicyRequest{} + +func (s FetchTieringCostSavingsInfoForPolicyRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostSavingsInfoForPolicyRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + decoded["objectType"] = "FetchTieringCostSavingsInfoForPolicyRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostSavingsInfoForPolicyRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go new file mode 100644 index 00000000000..6836ba25244 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforprotecteditemrequest.go @@ -0,0 +1,44 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FetchTieringCostInfoRequest = FetchTieringCostSavingsInfoForProtectedItemRequest{} + +type FetchTieringCostSavingsInfoForProtectedItemRequest struct { + ContainerName string `json:"containerName"` + ProtectedItemName string `json:"protectedItemName"` + + // Fields inherited from FetchTieringCostInfoRequest + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +var _ json.Marshaler = FetchTieringCostSavingsInfoForProtectedItemRequest{} + +func (s FetchTieringCostSavingsInfoForProtectedItemRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostSavingsInfoForProtectedItemRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + decoded["objectType"] = "FetchTieringCostSavingsInfoForProtectedItemRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostSavingsInfoForProtectedItemRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go new file mode 100644 index 00000000000..bfa92fffc4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_fetchtieringcostsavingsinfoforvaultrequest.go @@ -0,0 +1,42 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FetchTieringCostInfoRequest = FetchTieringCostSavingsInfoForVaultRequest{} + +type FetchTieringCostSavingsInfoForVaultRequest struct { + + // Fields inherited from FetchTieringCostInfoRequest + SourceTierType RecoveryPointTierType `json:"sourceTierType"` + TargetTierType RecoveryPointTierType `json:"targetTierType"` +} + +var _ json.Marshaler = FetchTieringCostSavingsInfoForVaultRequest{} + +func (s FetchTieringCostSavingsInfoForVaultRequest) MarshalJSON() ([]byte, error) { + type wrapper FetchTieringCostSavingsInfoForVaultRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + decoded["objectType"] = "FetchTieringCostSavingsInfoForVaultRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FetchTieringCostSavingsInfoForVaultRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostinfo.go new file mode 100644 index 00000000000..3278ffb8d57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostinfo.go @@ -0,0 +1,61 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TieringCostInfo interface { +} + +// RawTieringCostInfoImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawTieringCostInfoImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalTieringCostInfoImplementation(input []byte) (TieringCostInfo, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling TieringCostInfo into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "TieringCostRehydrationInfo") { + var out TieringCostRehydrationInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TieringCostRehydrationInfo: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TieringCostSavingInfo") { + var out TieringCostSavingInfo + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TieringCostSavingInfo: %+v", err) + } + return out, nil + } + + out := RawTieringCostInfoImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostrehydrationinfo.go new file mode 100644 index 00000000000..7d3e00aafee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostrehydrationinfo.go @@ -0,0 +1,42 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TieringCostInfo = TieringCostRehydrationInfo{} + +type TieringCostRehydrationInfo struct { + RehydrationSizeInBytes int64 `json:"rehydrationSizeInBytes"` + RetailRehydrationCostPerGBPerMonth float64 `json:"retailRehydrationCostPerGBPerMonth"` + + // Fields inherited from TieringCostInfo +} + +var _ json.Marshaler = TieringCostRehydrationInfo{} + +func (s TieringCostRehydrationInfo) MarshalJSON() ([]byte, error) { + type wrapper TieringCostRehydrationInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TieringCostRehydrationInfo: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TieringCostRehydrationInfo: %+v", err) + } + decoded["objectType"] = "TieringCostRehydrationInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TieringCostRehydrationInfo: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostsavinginfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostsavinginfo.go new file mode 100644 index 00000000000..45dd137725c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/model_tieringcostsavinginfo.go @@ -0,0 +1,44 @@ +package fetchtieringcost + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TieringCostInfo = TieringCostSavingInfo{} + +type TieringCostSavingInfo struct { + RetailSourceTierCostPerGBPerMonth float64 `json:"retailSourceTierCostPerGBPerMonth"` + RetailTargetTierCostPerGBPerMonth float64 `json:"retailTargetTierCostPerGBPerMonth"` + SourceTierSizeReductionInBytes int64 `json:"sourceTierSizeReductionInBytes"` + TargetTierSizeIncreaseInBytes int64 `json:"targetTierSizeIncreaseInBytes"` + + // Fields inherited from TieringCostInfo +} + +var _ json.Marshaler = TieringCostSavingInfo{} + +func (s TieringCostSavingInfo) MarshalJSON() ([]byte, error) { + type wrapper TieringCostSavingInfo + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TieringCostSavingInfo: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TieringCostSavingInfo: %+v", err) + } + decoded["objectType"] = "TieringCostSavingInfo" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TieringCostSavingInfo: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/version.go new file mode 100644 index 00000000000..61becd5297b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/fetchtieringcost/version.go @@ -0,0 +1,12 @@ +package fetchtieringcost + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/fetchtieringcost/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/README.md new file mode 100644 index 00000000000..d1d8a700469 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/README.md @@ -0,0 +1,57 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections` Documentation + +The `itemlevelrecoveryconnections` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections" +``` + + +### Client Initialization + +```go +client := itemlevelrecoveryconnections.NewItemLevelRecoveryConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ItemLevelRecoveryConnectionsClient.Provision` + +```go +ctx := context.TODO() +id := itemlevelrecoveryconnections.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +payload := itemlevelrecoveryconnections.ILRRequestResource{ + // ... +} + + +read, err := client.Provision(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ItemLevelRecoveryConnectionsClient.Revoke` + +```go +ctx := context.TODO() +id := itemlevelrecoveryconnections.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +read, err := client.Revoke(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/client.go new file mode 100644 index 00000000000..9dc4e42e08b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/client.go @@ -0,0 +1,18 @@ +package itemlevelrecoveryconnections + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ItemLevelRecoveryConnectionsClient struct { + Client autorest.Client + baseUri string +} + +func NewItemLevelRecoveryConnectionsClientWithBaseURI(endpoint string) ItemLevelRecoveryConnectionsClient { + return ItemLevelRecoveryConnectionsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint.go new file mode 100644 index 00000000000..0f971ef7db0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint.go @@ -0,0 +1,166 @@ +package itemlevelrecoveryconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint_test.go new file mode 100644 index 00000000000..0b3f033efd0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package itemlevelrecoveryconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_provision_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_provision_autorest.go new file mode 100644 index 00000000000..9d96e89f2fd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_provision_autorest.go @@ -0,0 +1,68 @@ +package itemlevelrecoveryconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisionOperationResponse struct { + HttpResponse *http.Response +} + +// Provision ... +func (c ItemLevelRecoveryConnectionsClient) Provision(ctx context.Context, id RecoveryPointId, input ILRRequestResource) (result ProvisionOperationResponse, err error) { + req, err := c.preparerForProvision(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Provision", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Provision", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForProvision(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Provision", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForProvision prepares the Provision request. +func (c ItemLevelRecoveryConnectionsClient) preparerForProvision(ctx context.Context, id RecoveryPointId, input ILRRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/provisionInstantItemRecovery", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForProvision handles the response to the Provision request. The method always +// closes the http.Response Body. +func (c ItemLevelRecoveryConnectionsClient) responderForProvision(resp *http.Response) (result ProvisionOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_revoke_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_revoke_autorest.go new file mode 100644 index 00000000000..9ea351e638d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/method_revoke_autorest.go @@ -0,0 +1,67 @@ +package itemlevelrecoveryconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevokeOperationResponse struct { + HttpResponse *http.Response +} + +// Revoke ... +func (c ItemLevelRecoveryConnectionsClient) Revoke(ctx context.Context, id RecoveryPointId) (result RevokeOperationResponse, err error) { + req, err := c.preparerForRevoke(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Revoke", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Revoke", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRevoke(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "itemlevelrecoveryconnections.ItemLevelRecoveryConnectionsClient", "Revoke", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRevoke prepares the Revoke request. +func (c ItemLevelRecoveryConnectionsClient) preparerForRevoke(ctx context.Context, id RecoveryPointId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/revokeInstantItemRecovery", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRevoke handles the response to the Revoke request. The method always +// closes the http.Response Body. +func (c ItemLevelRecoveryConnectionsClient) responderForRevoke(resp *http.Response) (result RevokeOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go new file mode 100644 index 00000000000..d93f105af7a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_azurefileshareprovisionilrrequest.go @@ -0,0 +1,42 @@ +package itemlevelrecoveryconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ILRRequest = AzureFileShareProvisionILRRequest{} + +type AzureFileShareProvisionILRRequest struct { + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + + // Fields inherited from ILRRequest +} + +var _ json.Marshaler = AzureFileShareProvisionILRRequest{} + +func (s AzureFileShareProvisionILRRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProvisionILRRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProvisionILRRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProvisionILRRequest: %+v", err) + } + decoded["objectType"] = "AzureFileShareProvisionILRRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProvisionILRRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go new file mode 100644 index 00000000000..87056a3101b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_iaasvmilrregistrationrequest.go @@ -0,0 +1,44 @@ +package itemlevelrecoveryconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ILRRequest = IaasVMILRRegistrationRequest{} + +type IaasVMILRRegistrationRequest struct { + InitiatorName *string `json:"initiatorName,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RenewExistingRegistration *bool `json:"renewExistingRegistration,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ILRRequest +} + +var _ json.Marshaler = IaasVMILRRegistrationRequest{} + +func (s IaasVMILRRegistrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMILRRegistrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMILRRegistrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMILRRegistrationRequest: %+v", err) + } + decoded["objectType"] = "IaasVMILRRegistrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMILRRegistrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequest.go new file mode 100644 index 00000000000..06d898b4cc2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequest.go @@ -0,0 +1,61 @@ +package itemlevelrecoveryconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ILRRequest interface { +} + +// RawILRRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawILRRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalILRRequestImplementation(input []byte) (ILRRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ILRRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareProvisionILRRequest") { + var out AzureFileShareProvisionILRRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProvisionILRRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMILRRegistrationRequest") { + var out IaasVMILRRegistrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMILRRegistrationRequest: %+v", err) + } + return out, nil + } + + out := RawILRRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequestresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequestresource.go new file mode 100644 index 00000000000..b9b0865a658 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/model_ilrrequestresource.go @@ -0,0 +1,50 @@ +package itemlevelrecoveryconnections + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ILRRequestResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ILRRequest `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ILRRequestResource{} + +func (s *ILRRequestResource) UnmarshalJSON(bytes []byte) error { + type alias ILRRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ILRRequestResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ILRRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalILRRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ILRRequestResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/version.go new file mode 100644 index 00000000000..03885c0695f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/itemlevelrecoveryconnections/version.go @@ -0,0 +1,12 @@ +package itemlevelrecoveryconnections + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/itemlevelrecoveryconnections/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/client.go new file mode 100644 index 00000000000..00a3fc2ea01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/client.go @@ -0,0 +1,18 @@ +package jobcancellations + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobCancellationsClient struct { + Client autorest.Client + baseUri string +} + +func NewJobCancellationsClientWithBaseURI(endpoint string) JobCancellationsClient { + return JobCancellationsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob.go new file mode 100644 index 00000000000..a1e5b25173c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob.go @@ -0,0 +1,139 @@ +package jobcancellations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupJobId{}) +} + +var _ resourceids.ResourceId = &BackupJobId{} + +// BackupJobId is a struct representing the Resource ID for a Backup Job +type BackupJobId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupJobName string +} + +// NewBackupJobID returns a new BackupJobId struct +func NewBackupJobID(subscriptionId string, resourceGroupName string, vaultName string, backupJobName string) BackupJobId { + return BackupJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupJobName: backupJobName, + } +} + +// ParseBackupJobID parses 'input' into a BackupJobId +func ParseBackupJobID(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupJobIDInsensitively parses 'input' case-insensitively into a BackupJobId +// note: this method should only be used for API response data and not user input +func ParseBackupJobIDInsensitively(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupJobName, ok = input.Parsed["backupJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupJobName", input) + } + + return nil +} + +// ValidateBackupJobID checks that 'input' can be parsed as a Backup Job ID +func ValidateBackupJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Job ID +func (id BackupJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Job ID +func (id BackupJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.UserSpecifiedSegment("backupJobName", "backupJobValue"), + } +} + +// String returns a human-readable description of this Backup Job ID +func (id BackupJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Job Name: %q", id.BackupJobName), + } + return fmt.Sprintf("Backup Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob_test.go new file mode 100644 index 00000000000..7c2473b8305 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/id_backupjob_test.go @@ -0,0 +1,327 @@ +package jobcancellations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupJobId{} + +func TestNewBackupJobID(t *testing.T) { + id := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupJobValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupJobName != "backupJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupJobName'", id.BackupJobName, "backupJobValue") + } +} + +func TestFormatBackupJobID(t *testing.T) { + actual := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestParseBackupJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupJobName: "bAcKuPjObVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestSegmentsForBackupJobId(t *testing.T) { + segments := BackupJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/method_trigger_autorest.go new file mode 100644 index 00000000000..9159d1476cb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/method_trigger_autorest.go @@ -0,0 +1,67 @@ +package jobcancellations + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerOperationResponse struct { + HttpResponse *http.Response +} + +// Trigger ... +func (c JobCancellationsClient) Trigger(ctx context.Context, id BackupJobId) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "jobcancellations.JobCancellationsClient", "Trigger", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "jobcancellations.JobCancellationsClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForTrigger(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "jobcancellations.JobCancellationsClient", "Trigger", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForTrigger prepares the Trigger request. +func (c JobCancellationsClient) preparerForTrigger(ctx context.Context, id BackupJobId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/cancel", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForTrigger handles the response to the Trigger request. The method always +// closes the http.Response Body. +func (c JobCancellationsClient) responderForTrigger(resp *http.Response) (result TriggerOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/version.go new file mode 100644 index 00000000000..7f966cc1f61 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobcancellations/version.go @@ -0,0 +1,12 @@ +package jobcancellations + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/jobcancellations/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/README.md new file mode 100644 index 00000000000..203d0f95c80 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails` Documentation + +The `jobdetails` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails" +``` + + +### Client Initialization + +```go +client := jobdetails.NewJobDetailsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `JobDetailsClient.Get` + +```go +ctx := context.TODO() +id := jobdetails.NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupJobValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/client.go new file mode 100644 index 00000000000..465d9e82eba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/client.go @@ -0,0 +1,18 @@ +package jobdetails + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobDetailsClient struct { + Client autorest.Client + baseUri string +} + +func NewJobDetailsClientWithBaseURI(endpoint string) JobDetailsClient { + return JobDetailsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/constants.go new file mode 100644 index 00000000000..a94046a0140 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/constants.go @@ -0,0 +1,223 @@ +package jobdetails + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type JobSupportedAction string + +const ( + JobSupportedActionCancellable JobSupportedAction = "Cancellable" + JobSupportedActionInvalid JobSupportedAction = "Invalid" + JobSupportedActionRetriable JobSupportedAction = "Retriable" +) + +func PossibleValuesForJobSupportedAction() []string { + return []string{ + string(JobSupportedActionCancellable), + string(JobSupportedActionInvalid), + string(JobSupportedActionRetriable), + } +} + +func parseJobSupportedAction(input string) (*JobSupportedAction, error) { + vals := map[string]JobSupportedAction{ + "cancellable": JobSupportedActionCancellable, + "invalid": JobSupportedActionInvalid, + "retriable": JobSupportedActionRetriable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobSupportedAction(input) + return &out, nil +} + +type MabServerType string + +const ( + MabServerTypeAzureBackupServerContainer MabServerType = "AzureBackupServerContainer" + MabServerTypeAzureSqlContainer MabServerType = "AzureSqlContainer" + MabServerTypeCluster MabServerType = "Cluster" + MabServerTypeDPMContainer MabServerType = "DPMContainer" + MabServerTypeGenericContainer MabServerType = "GenericContainer" + MabServerTypeIaasVMContainer MabServerType = "IaasVMContainer" + MabServerTypeIaasVMServiceContainer MabServerType = "IaasVMServiceContainer" + MabServerTypeInvalid MabServerType = "Invalid" + MabServerTypeMABContainer MabServerType = "MABContainer" + MabServerTypeSQLAGWorkLoadContainer MabServerType = "SQLAGWorkLoadContainer" + MabServerTypeStorageContainer MabServerType = "StorageContainer" + MabServerTypeUnknown MabServerType = "Unknown" + MabServerTypeVCenter MabServerType = "VCenter" + MabServerTypeVMAppContainer MabServerType = "VMAppContainer" + MabServerTypeWindows MabServerType = "Windows" +) + +func PossibleValuesForMabServerType() []string { + return []string{ + string(MabServerTypeAzureBackupServerContainer), + string(MabServerTypeAzureSqlContainer), + string(MabServerTypeCluster), + string(MabServerTypeDPMContainer), + string(MabServerTypeGenericContainer), + string(MabServerTypeIaasVMContainer), + string(MabServerTypeIaasVMServiceContainer), + string(MabServerTypeInvalid), + string(MabServerTypeMABContainer), + string(MabServerTypeSQLAGWorkLoadContainer), + string(MabServerTypeStorageContainer), + string(MabServerTypeUnknown), + string(MabServerTypeVCenter), + string(MabServerTypeVMAppContainer), + string(MabServerTypeWindows), + } +} + +func parseMabServerType(input string) (*MabServerType, error) { + vals := map[string]MabServerType{ + "azurebackupservercontainer": MabServerTypeAzureBackupServerContainer, + "azuresqlcontainer": MabServerTypeAzureSqlContainer, + "cluster": MabServerTypeCluster, + "dpmcontainer": MabServerTypeDPMContainer, + "genericcontainer": MabServerTypeGenericContainer, + "iaasvmcontainer": MabServerTypeIaasVMContainer, + "iaasvmservicecontainer": MabServerTypeIaasVMServiceContainer, + "invalid": MabServerTypeInvalid, + "mabcontainer": MabServerTypeMABContainer, + "sqlagworkloadcontainer": MabServerTypeSQLAGWorkLoadContainer, + "storagecontainer": MabServerTypeStorageContainer, + "unknown": MabServerTypeUnknown, + "vcenter": MabServerTypeVCenter, + "vmappcontainer": MabServerTypeVMAppContainer, + "windows": MabServerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MabServerType(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDBInstance), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob.go new file mode 100644 index 00000000000..e7740445ca3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob.go @@ -0,0 +1,139 @@ +package jobdetails + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupJobId{}) +} + +var _ resourceids.ResourceId = &BackupJobId{} + +// BackupJobId is a struct representing the Resource ID for a Backup Job +type BackupJobId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupJobName string +} + +// NewBackupJobID returns a new BackupJobId struct +func NewBackupJobID(subscriptionId string, resourceGroupName string, vaultName string, backupJobName string) BackupJobId { + return BackupJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupJobName: backupJobName, + } +} + +// ParseBackupJobID parses 'input' into a BackupJobId +func ParseBackupJobID(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupJobIDInsensitively parses 'input' case-insensitively into a BackupJobId +// note: this method should only be used for API response data and not user input +func ParseBackupJobIDInsensitively(input string) (*BackupJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupJobName, ok = input.Parsed["backupJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupJobName", input) + } + + return nil +} + +// ValidateBackupJobID checks that 'input' can be parsed as a Backup Job ID +func ValidateBackupJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Job ID +func (id BackupJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Job ID +func (id BackupJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupJobs", "backupJobs", "backupJobs"), + resourceids.UserSpecifiedSegment("backupJobName", "backupJobValue"), + } +} + +// String returns a human-readable description of this Backup Job ID +func (id BackupJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Job Name: %q", id.BackupJobName), + } + return fmt.Sprintf("Backup Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob_test.go new file mode 100644 index 00000000000..23a0fa12076 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/id_backupjob_test.go @@ -0,0 +1,327 @@ +package jobdetails + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupJobId{} + +func TestNewBackupJobID(t *testing.T) { + id := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupJobValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupJobName != "backupJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupJobName'", id.BackupJobName, "backupJobValue") + } +} + +func TestFormatBackupJobID(t *testing.T) { + actual := NewBackupJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestParseBackupJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupJobName: "backupJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupJobs/backupJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE", + Expected: &BackupJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupJobName: "bAcKuPjObVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPjObS/bAcKuPjObVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupJobName != v.Expected.BackupJobName { + t.Fatalf("Expected %q but got %q for BackupJobName", v.Expected.BackupJobName, actual.BackupJobName) + } + + } +} + +func TestSegmentsForBackupJobId(t *testing.T) { + segments := BackupJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/method_get_autorest.go new file mode 100644 index 00000000000..aa3589e2635 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/method_get_autorest.go @@ -0,0 +1,68 @@ +package jobdetails + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *JobResource +} + +// Get ... +func (c JobDetailsClient) Get(ctx context.Context, id BackupJobId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "jobdetails.JobDetailsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "jobdetails.JobDetailsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "jobdetails.JobDetailsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c JobDetailsClient) preparerForGet(ctx context.Context, id BackupJobId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c JobDetailsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmerrorinfo.go new file mode 100644 index 00000000000..47de469765b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmerrorinfo.go @@ -0,0 +1,11 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjob.go new file mode 100644 index 00000000000..fd829774cff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjob.go @@ -0,0 +1,81 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureIaaSVMJob{} + +type AzureIaaSVMJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureIaaSVMJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJob{} + +func (s AzureIaaSVMJob) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJob: %+v", err) + } + decoded["jobType"] = "AzureIaaSVMJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobextendedinfo.go new file mode 100644 index 00000000000..4dba88ce53a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobextendedinfo.go @@ -0,0 +1,13 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + EstimatedRemainingDuration *string `json:"estimatedRemainingDuration,omitempty"` + InternalPropertyBag *map[string]string `json:"internalPropertyBag,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureIaaSVMJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobtaskdetails.go new file mode 100644 index 00000000000..ae1cc624792 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobtaskdetails.go @@ -0,0 +1,45 @@ +package jobdetails + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + InstanceId *string `json:"instanceId,omitempty"` + ProgressPercentage *float64 `json:"progressPercentage,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskExecutionDetails *string `json:"taskExecutionDetails,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *AzureIaaSVMJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobv2.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobv2.go new file mode 100644 index 00000000000..e1c8f8a8d74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureiaasvmjobv2.go @@ -0,0 +1,80 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureIaaSVMJobV2{} + +type AzureIaaSVMJobV2 struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureIaaSVMErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureIaaSVMJobExtendedInfo `json:"extendedInfo,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureIaaSVMJobV2) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureIaaSVMJobV2) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMJobV2) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureIaaSVMJobV2{} + +func (s AzureIaaSVMJobV2) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMJobV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMJobV2: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMJobV2: %+v", err) + } + decoded["jobType"] = "AzureIaaSVMJobV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMJobV2: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestorageerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestorageerrorinfo.go new file mode 100644 index 00000000000..28cf64eae5f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestorageerrorinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejob.go new file mode 100644 index 00000000000..ae1214a2ed0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejob.go @@ -0,0 +1,81 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureStorageJob{} + +type AzureStorageJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureStorageErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureStorageJobExtendedInfo `json:"extendedInfo,omitempty"` + IsUserTriggered *bool `json:"isUserTriggered,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureStorageJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureStorageJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureStorageJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureStorageJob{} + +func (s AzureStorageJob) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageJob: %+v", err) + } + decoded["jobType"] = "AzureStorageJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobextendedinfo.go new file mode 100644 index 00000000000..b687b944e42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureStorageJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobtaskdetails.go new file mode 100644 index 00000000000..9cc5cb916c9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azurestoragejobtaskdetails.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloaderrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloaderrorinfo.go new file mode 100644 index 00000000000..d54f4b2217f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloaderrorinfo.go @@ -0,0 +1,12 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadErrorInfo struct { + AdditionalDetails *string `json:"additionalDetails,omitempty"` + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + ErrorTitle *string `json:"errorTitle,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjob.go new file mode 100644 index 00000000000..90c833a0b9e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjob.go @@ -0,0 +1,79 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = AzureWorkloadJob{} + +type AzureWorkloadJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]AzureWorkloadErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *AzureWorkloadJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *AzureWorkloadJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AzureWorkloadJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = AzureWorkloadJob{} + +func (s AzureWorkloadJob) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadJob: %+v", err) + } + decoded["jobType"] = "AzureWorkloadJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobextendedinfo.go new file mode 100644 index 00000000000..b086f0ffee5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]AzureWorkloadJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobtaskdetails.go new file mode 100644 index 00000000000..b6d9349f0c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_azureworkloadjobtaskdetails.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadJobTaskDetails struct { + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmerrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmerrorinfo.go new file mode 100644 index 00000000000..987eb3a7bcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmerrorinfo.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjob.go new file mode 100644 index 00000000000..7a18a1855d9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjob.go @@ -0,0 +1,82 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = DpmJob{} + +type DpmJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + ContainerType *string `json:"containerType,omitempty"` + DpmServerName *string `json:"dpmServerName,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]DpmErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *DpmJobExtendedInfo `json:"extendedInfo,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *DpmJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = DpmJob{} + +func (s DpmJob) MarshalJSON() ([]byte, error) { + type wrapper DpmJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmJob: %+v", err) + } + decoded["jobType"] = "DpmJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobextendedinfo.go new file mode 100644 index 00000000000..e06f6f2aa5e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]DpmJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobtaskdetails.go new file mode 100644 index 00000000000..9b8583d9233 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_dpmjobtaskdetails.go @@ -0,0 +1,42 @@ +package jobdetails + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DpmJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *DpmJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DpmJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DpmJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_job.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_job.go new file mode 100644 index 00000000000..eb88a4b64f5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_job.go @@ -0,0 +1,101 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Job interface { +} + +// RawJobImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawJobImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalJobImplementation(input []byte) (Job, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling Job into map[string]interface: %+v", err) + } + + value, ok := temp["jobType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureIaaSVMJob") { + var out AzureIaaSVMJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMJobV2") { + var out AzureIaaSVMJobV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMJobV2: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureStorageJob") { + var out AzureStorageJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadJob") { + var out AzureWorkloadJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DpmJob") { + var out DpmJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabJob") { + var out MabJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VaultJob") { + var out VaultJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VaultJob: %+v", err) + } + return out, nil + } + + out := RawJobImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_jobresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_jobresource.go new file mode 100644 index 00000000000..5a450efbfbd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_jobresource.go @@ -0,0 +1,50 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties Job `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &JobResource{} + +func (s *JobResource) UnmarshalJSON(bytes []byte) error { + type alias JobResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into JobResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalJobImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'JobResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_maberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_maberrorinfo.go new file mode 100644 index 00000000000..d12afd9a026 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_maberrorinfo.go @@ -0,0 +1,9 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabErrorInfo struct { + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjob.go new file mode 100644 index 00000000000..b39dc7f470f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjob.go @@ -0,0 +1,81 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = MabJob{} + +type MabJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]MabErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *MabJobExtendedInfo `json:"extendedInfo,omitempty"` + MabServerName *string `json:"mabServerName,omitempty"` + MabServerType *MabServerType `json:"mabServerType,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *MabJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = MabJob{} + +func (s MabJob) MarshalJSON() ([]byte, error) { + type wrapper MabJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabJob: %+v", err) + } + decoded["jobType"] = "MabJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobextendedinfo.go new file mode 100644 index 00000000000..b08829e160a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobextendedinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabJobExtendedInfo struct { + DynamicErrorMessage *string `json:"dynamicErrorMessage,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + TasksList *[]MabJobTaskDetails `json:"tasksList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobtaskdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobtaskdetails.go new file mode 100644 index 00000000000..c923d5d3282 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_mabjobtaskdetails.go @@ -0,0 +1,42 @@ +package jobdetails + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabJobTaskDetails struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` + TaskId *string `json:"taskId,omitempty"` +} + +func (o *MabJobTaskDetails) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MabJobTaskDetails) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabJobTaskDetails) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjob.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjob.go new file mode 100644 index 00000000000..e5aef51bd7b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjob.go @@ -0,0 +1,78 @@ +package jobdetails + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Job = VaultJob{} + +type VaultJob struct { + ActionsInfo *[]JobSupportedAction `json:"actionsInfo,omitempty"` + Duration *string `json:"duration,omitempty"` + ErrorDetails *[]VaultJobErrorInfo `json:"errorDetails,omitempty"` + ExtendedInfo *VaultJobExtendedInfo `json:"extendedInfo,omitempty"` + + // Fields inherited from Job + ActivityId *string `json:"activityId,omitempty"` + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + EndTime *string `json:"endTime,omitempty"` + EntityFriendlyName *string `json:"entityFriendlyName,omitempty"` + Operation *string `json:"operation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *string `json:"status,omitempty"` +} + +func (o *VaultJob) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *VaultJob) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *VaultJob) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +var _ json.Marshaler = VaultJob{} + +func (s VaultJob) MarshalJSON() ([]byte, error) { + type wrapper VaultJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VaultJob: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VaultJob: %+v", err) + } + decoded["jobType"] = "VaultJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VaultJob: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjoberrorinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjoberrorinfo.go new file mode 100644 index 00000000000..8369add63df --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjoberrorinfo.go @@ -0,0 +1,10 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobErrorInfo struct { + ErrorCode *int64 `json:"errorCode,omitempty"` + ErrorString *string `json:"errorString,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjobextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjobextendedinfo.go new file mode 100644 index 00000000000..78248901487 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/model_vaultjobextendedinfo.go @@ -0,0 +1,8 @@ +package jobdetails + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultJobExtendedInfo struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/version.go new file mode 100644 index 00000000000..74cb19fcd0d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobdetails/version.go @@ -0,0 +1,12 @@ +package jobdetails + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/jobdetails/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobs/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/client.go new file mode 100644 index 00000000000..fd4e7899bb5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/client.go @@ -0,0 +1,18 @@ +package jobs + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobsClient struct { + Client autorest.Client + baseUri string +} + +func NewJobsClientWithBaseURI(endpoint string) JobsClient { + return JobsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault.go new file mode 100644 index 00000000000..730fc6c8ab6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault.go @@ -0,0 +1,130 @@ +package jobs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault_test.go new file mode 100644 index 00000000000..d17765be948 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/id_vault_test.go @@ -0,0 +1,282 @@ +package jobs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobs/method_export_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/method_export_autorest.go new file mode 100644 index 00000000000..d6662857fa9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/method_export_autorest.go @@ -0,0 +1,96 @@ +package jobs + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExportOperationResponse struct { + HttpResponse *http.Response +} + +type ExportOperationOptions struct { + Filter *string +} + +func DefaultExportOperationOptions() ExportOperationOptions { + return ExportOperationOptions{} +} + +func (o ExportOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ExportOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Export ... +func (c JobsClient) Export(ctx context.Context, id VaultId, options ExportOperationOptions) (result ExportOperationResponse, err error) { + req, err := c.preparerForExport(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "jobs.JobsClient", "Export", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "jobs.JobsClient", "Export", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForExport(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "jobs.JobsClient", "Export", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForExport prepares the Export request. +func (c JobsClient) preparerForExport(ctx context.Context, id VaultId, options ExportOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupJobsExport", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForExport handles the response to the Export request. The method always +// closes the http.Response Body. +func (c JobsClient) responderForExport(resp *http.Response) (result ExportOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/jobs/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/version.go new file mode 100644 index 00000000000..e54d9be2b4d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/jobs/version.go @@ -0,0 +1,12 @@ +package jobs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/jobs/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/operation/README.md new file mode 100644 index 00000000000..ab23c3aae99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/operation` Documentation + +The `operation` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/operation" +``` + + +### Client Initialization + +```go +client := operation.NewOperationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OperationClient.Validate` + +```go +ctx := context.TODO() +id := operation.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := operation.ValidateOperationRequestResource{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/client.go new file mode 100644 index 00000000000..3a57d0e0d4c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/client.go @@ -0,0 +1,18 @@ +package operation + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OperationClient struct { + Client autorest.Client + baseUri string +} + +func NewOperationClientWithBaseURI(endpoint string) OperationClient { + return OperationClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/constants.go new file mode 100644 index 00000000000..6115c6303c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/constants.go @@ -0,0 +1,272 @@ +package operation + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CopyOptions string + +const ( + CopyOptionsCreateCopy CopyOptions = "CreateCopy" + CopyOptionsFailOnConflict CopyOptions = "FailOnConflict" + CopyOptionsInvalid CopyOptions = "Invalid" + CopyOptionsOverwrite CopyOptions = "Overwrite" + CopyOptionsSkip CopyOptions = "Skip" +) + +func PossibleValuesForCopyOptions() []string { + return []string{ + string(CopyOptionsCreateCopy), + string(CopyOptionsFailOnConflict), + string(CopyOptionsInvalid), + string(CopyOptionsOverwrite), + string(CopyOptionsSkip), + } +} + +func parseCopyOptions(input string) (*CopyOptions, error) { + vals := map[string]CopyOptions{ + "createcopy": CopyOptionsCreateCopy, + "failonconflict": CopyOptionsFailOnConflict, + "invalid": CopyOptionsInvalid, + "overwrite": CopyOptionsOverwrite, + "skip": CopyOptionsSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CopyOptions(input) + return &out, nil +} + +type OverwriteOptions string + +const ( + OverwriteOptionsFailOnConflict OverwriteOptions = "FailOnConflict" + OverwriteOptionsInvalid OverwriteOptions = "Invalid" + OverwriteOptionsOverwrite OverwriteOptions = "Overwrite" +) + +func PossibleValuesForOverwriteOptions() []string { + return []string{ + string(OverwriteOptionsFailOnConflict), + string(OverwriteOptionsInvalid), + string(OverwriteOptionsOverwrite), + } +} + +func parseOverwriteOptions(input string) (*OverwriteOptions, error) { + vals := map[string]OverwriteOptions{ + "failonconflict": OverwriteOptionsFailOnConflict, + "invalid": OverwriteOptionsInvalid, + "overwrite": OverwriteOptionsOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverwriteOptions(input) + return &out, nil +} + +type RecoveryMode string + +const ( + RecoveryModeFileRecovery RecoveryMode = "FileRecovery" + RecoveryModeInvalid RecoveryMode = "Invalid" + RecoveryModeRecoveryUsingSnapshot RecoveryMode = "RecoveryUsingSnapshot" + RecoveryModeSnapshotAttach RecoveryMode = "SnapshotAttach" + RecoveryModeSnapshotAttachAndRecover RecoveryMode = "SnapshotAttachAndRecover" + RecoveryModeWorkloadRecovery RecoveryMode = "WorkloadRecovery" +) + +func PossibleValuesForRecoveryMode() []string { + return []string{ + string(RecoveryModeFileRecovery), + string(RecoveryModeInvalid), + string(RecoveryModeRecoveryUsingSnapshot), + string(RecoveryModeSnapshotAttach), + string(RecoveryModeSnapshotAttachAndRecover), + string(RecoveryModeWorkloadRecovery), + } +} + +func parseRecoveryMode(input string) (*RecoveryMode, error) { + vals := map[string]RecoveryMode{ + "filerecovery": RecoveryModeFileRecovery, + "invalid": RecoveryModeInvalid, + "recoveryusingsnapshot": RecoveryModeRecoveryUsingSnapshot, + "snapshotattach": RecoveryModeSnapshotAttach, + "snapshotattachandrecover": RecoveryModeSnapshotAttachAndRecover, + "workloadrecovery": RecoveryModeWorkloadRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryMode(input) + return &out, nil +} + +type RecoveryType string + +const ( + RecoveryTypeAlternateLocation RecoveryType = "AlternateLocation" + RecoveryTypeInvalid RecoveryType = "Invalid" + RecoveryTypeOffline RecoveryType = "Offline" + RecoveryTypeOriginalLocation RecoveryType = "OriginalLocation" + RecoveryTypeRestoreDisks RecoveryType = "RestoreDisks" +) + +func PossibleValuesForRecoveryType() []string { + return []string{ + string(RecoveryTypeAlternateLocation), + string(RecoveryTypeInvalid), + string(RecoveryTypeOffline), + string(RecoveryTypeOriginalLocation), + string(RecoveryTypeRestoreDisks), + } +} + +func parseRecoveryType(input string) (*RecoveryType, error) { + vals := map[string]RecoveryType{ + "alternatelocation": RecoveryTypeAlternateLocation, + "invalid": RecoveryTypeInvalid, + "offline": RecoveryTypeOffline, + "originallocation": RecoveryTypeOriginalLocation, + "restoredisks": RecoveryTypeRestoreDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} + +type RestoreRequestType string + +const ( + RestoreRequestTypeFullShareRestore RestoreRequestType = "FullShareRestore" + RestoreRequestTypeInvalid RestoreRequestType = "Invalid" + RestoreRequestTypeItemLevelRestore RestoreRequestType = "ItemLevelRestore" +) + +func PossibleValuesForRestoreRequestType() []string { + return []string{ + string(RestoreRequestTypeFullShareRestore), + string(RestoreRequestTypeInvalid), + string(RestoreRequestTypeItemLevelRestore), + } +} + +func parseRestoreRequestType(input string) (*RestoreRequestType, error) { + vals := map[string]RestoreRequestType{ + "fullsharerestore": RestoreRequestTypeFullShareRestore, + "invalid": RestoreRequestTypeInvalid, + "itemlevelrestore": RestoreRequestTypeItemLevelRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreRequestType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} + +type TargetDiskNetworkAccessOption string + +const ( + TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePrivateAccessForAllDisks" + TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePublicAccessForAllDisks" + TargetDiskNetworkAccessOptionSameAsOnSourceDisks TargetDiskNetworkAccessOption = "SameAsOnSourceDisks" +) + +func PossibleValuesForTargetDiskNetworkAccessOption() []string { + return []string{ + string(TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks), + string(TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks), + string(TargetDiskNetworkAccessOptionSameAsOnSourceDisks), + } +} + +func parseTargetDiskNetworkAccessOption(input string) (*TargetDiskNetworkAccessOption, error) { + vals := map[string]TargetDiskNetworkAccessOption{ + "enableprivateaccessforalldisks": TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks, + "enablepublicaccessforalldisks": TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks, + "sameasonsourcedisks": TargetDiskNetworkAccessOptionSameAsOnSourceDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetDiskNetworkAccessOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault.go new file mode 100644 index 00000000000..4ae07d51d6d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault.go @@ -0,0 +1,130 @@ +package operation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault_test.go new file mode 100644 index 00000000000..dbfd98acc85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/id_vault_test.go @@ -0,0 +1,282 @@ +package operation + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/method_validate_autorest.go new file mode 100644 index 00000000000..05bac629ddd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/method_validate_autorest.go @@ -0,0 +1,70 @@ +package operation + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationApiResponse struct { + HttpResponse *http.Response + Model *ValidateOperationsResponse +} + +// Validate ... +func (c OperationClient) Validate(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (result ValidateOperationApiResponse, err error) { + req, err := c.preparerForValidate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "operation.OperationClient", "Validate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "operation.OperationClient", "Validate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForValidate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "operation.OperationClient", "Validate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForValidate prepares the Validate request. +func (c OperationClient) preparerForValidate(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupValidateOperation", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForValidate handles the response to the Validate request. The method always +// closes the http.Response Body. +func (c OperationClient) responderForValidate(resp *http.Response) (result ValidateOperationApiResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..5a514f78c69 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azurefilesharerestorerequest.go @@ -0,0 +1,47 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureFileShareRestoreRequest{} + +type AzureFileShareRestoreRequest struct { + CopyOptions *CopyOptions `json:"copyOptions,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + RestoreFileSpecs *[]RestoreFileSpecs `json:"restoreFileSpecs,omitempty"` + RestoreRequestType *RestoreRequestType `json:"restoreRequestType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetDetails *TargetAFSRestoreInfo `json:"targetDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareRestoreRequest{} + +func (s AzureFileShareRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureFileShareRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..5ee35cae11d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,51 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadPointInTimeRestoreRequest{} + +type AzureWorkloadPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRestoreRequest{} + +func (s AzureWorkloadPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..585e89976c7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadrestorerequest.go @@ -0,0 +1,50 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadRestoreRequest{} + +type AzureWorkloadRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadRestoreRequest{} + +func (s AzureWorkloadRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..f7e6a897e54 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,51 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..112bd3a5e26 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,52 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..602e01fc927 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,50 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaRestoreRequest{} + +type AzureWorkloadSAPHanaRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreRequest{} + +func (s AzureWorkloadSAPHanaRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..893d779276c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,51 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaRestoreWithRehydrateRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..5292a6a7515 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,54 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreRequest{} + +type AzureWorkloadSQLPointInTimeRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..a945ba6e041 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,55 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..061204b5db9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,53 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLRestoreRequest{} + +type AzureWorkloadSQLRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreRequest{} + +func (s AzureWorkloadSQLRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..9397507ba54 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,54 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_encryptiondetails.go new file mode 100644 index 00000000000..64f3372dbd2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_encryptiondetails.go @@ -0,0 +1,12 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionDetails struct { + EncryptionEnabled *bool `json:"encryptionEnabled,omitempty"` + KekUrl *string `json:"kekUrl,omitempty"` + KekVaultId *string `json:"kekVaultId,omitempty"` + SecretKeyUrl *string `json:"secretKeyUrl,omitempty"` + SecretKeyVaultId *string `json:"secretKeyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_errordetail.go new file mode 100644 index 00000000000..2c609c87024 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_errordetail.go @@ -0,0 +1,10 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_extendedlocation.go new file mode 100644 index 00000000000..42ab6a6a9d4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_extendedlocation.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..33fe3960a39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorerequest.go @@ -0,0 +1,66 @@ +package operation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreRequest{} + +type IaasVMRestoreRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = IaasVMRestoreRequest{} + +func (s IaasVMRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreRequest: %+v", err) + } + decoded["objectType"] = "IaasVMRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..c0f0ef8274c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,67 @@ +package operation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreWithRehydrationRequest{} + +type IaasVMRestoreWithRehydrationRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = IaasVMRestoreWithRehydrationRequest{} + +func (s IaasVMRestoreWithRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreWithRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + decoded["objectType"] = "IaasVMRestoreWithRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..dd5d66a7e1c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identitybasedrestoredetails.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityBasedRestoreDetails struct { + ObjectType *string `json:"objectType,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identityinfo.go new file mode 100644 index 00000000000..e6971151557 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_identityinfo.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityInfo struct { + IsSystemAssignedIdentity *bool `json:"isSystemAssignedIdentity,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..d5d028a3fe7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_recoverypointrehydrationinfo.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointRehydrationInfo struct { + RehydrationPriority *RehydrationPriority `json:"rehydrationPriority,omitempty"` + RehydrationRetentionDuration *string `json:"rehydrationRetentionDuration,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorefilespecs.go new file mode 100644 index 00000000000..74e8852a5f7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorefilespecs.go @@ -0,0 +1,10 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFileSpecs struct { + FileSpecType *string `json:"fileSpecType,omitempty"` + Path *string `json:"path,omitempty"` + TargetFolderPath *string `json:"targetFolderPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorerequest.go new file mode 100644 index 00000000000..80db41827d3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_restorerequest.go @@ -0,0 +1,149 @@ +package operation + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequest interface { +} + +// RawRestoreRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRestoreRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRestoreRequestImplementation(input []byte) (RestoreRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RestoreRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareRestoreRequest") { + var out AzureFileShareRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRestoreRequest") { + var out AzureWorkloadPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRestoreRequest") { + var out AzureWorkloadRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreRequest") { + var out AzureWorkloadSAPHanaRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreRequest") { + var out AzureWorkloadSQLPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreRequest") { + var out AzureWorkloadSQLRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreRequest") { + var out IaasVMRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreWithRehydrationRequest") { + var out IaasVMRestoreWithRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreWithRehydrationRequest: %+v", err) + } + return out, nil + } + + out := RawRestoreRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_securedvmdetails.go new file mode 100644 index 00000000000..3f5c4c4f17a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_securedvmdetails.go @@ -0,0 +1,8 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuredVMDetails struct { + SecuredVMOsDiskEncryptionSetId *string `json:"securedVMOsDiskEncryptionSetId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..100aca8fc56 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_snapshotrestoreparameters.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreParameters struct { + LogPointInTimeForDBRecovery *string `json:"logPointInTimeForDBRecovery,omitempty"` + SkipAttachAndMount *bool `json:"skipAttachAndMount,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..9de6dd3d184 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_sqldatadirectorymapping.go @@ -0,0 +1,11 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectoryMapping struct { + MappingType *SQLDataDirectoryType `json:"mappingType,omitempty"` + SourceLogicalName *string `json:"sourceLogicalName,omitempty"` + SourcePath *string `json:"sourcePath,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..56b7218e6de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetafsrestoreinfo.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetAFSRestoreInfo struct { + Name *string `json:"name,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..a900401068b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetdisknetworkaccesssettings.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetDiskNetworkAccessSettings struct { + TargetDiskAccessId *string `json:"targetDiskAccessId,omitempty"` + TargetDiskNetworkAccessOption *TargetDiskNetworkAccessOption `json:"targetDiskNetworkAccessOption,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetrestoreinfo.go new file mode 100644 index 00000000000..4d4171906ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_targetrestoreinfo.go @@ -0,0 +1,11 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetRestoreInfo struct { + ContainerId *string `json:"containerId,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + OverwriteOption *OverwriteOptions `json:"overwriteOption,omitempty"` + TargetDirectoryForFileRestore *string `json:"targetDirectoryForFileRestore,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..d0776af4b85 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..4000e7813ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateiaasvmrestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateiaasvmrestoreoperationrequest.go new file mode 100644 index 00000000000..1e08498a231 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateiaasvmrestoreoperationrequest.go @@ -0,0 +1,60 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ValidateOperationRequest = ValidateIaasVMRestoreOperationRequest{} + +type ValidateIaasVMRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +var _ json.Marshaler = ValidateIaasVMRestoreOperationRequest{} + +func (s ValidateIaasVMRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateIaasVMRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + decoded["objectType"] = "ValidateIaasVMRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateIaasVMRestoreOperationRequest{} + +func (s *ValidateIaasVMRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := unmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateIaasVMRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequest.go new file mode 100644 index 00000000000..7b2def35886 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequest.go @@ -0,0 +1,61 @@ +package operation + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationRequest interface { +} + +// RawValidateOperationRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawValidateOperationRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalValidateOperationRequestImplementation(input []byte) (ValidateOperationRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateOperationRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "ValidateIaasVMRestoreOperationRequest") { + var out ValidateIaasVMRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateIaasVMRestoreOperationRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ValidateRestoreOperationRequest") { + var out ValidateRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateRestoreOperationRequest: %+v", err) + } + return out, nil + } + + out := RawValidateOperationRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequestresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequestresource.go new file mode 100644 index 00000000000..2c0371a7699 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationrequestresource.go @@ -0,0 +1,40 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationRequestResource struct { + Id string `json:"id"` + Properties ValidateOperationRequest `json:"properties"` +} + +var _ json.Unmarshaler = &ValidateOperationRequestResource{} + +func (s *ValidateOperationRequestResource) UnmarshalJSON(bytes []byte) error { + type alias ValidateOperationRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ValidateOperationRequestResource: %+v", err) + } + + s.Id = decoded.Id + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateOperationRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalValidateOperationRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ValidateOperationRequestResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationresponse.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationresponse.go new file mode 100644 index 00000000000..0be2ef4af18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationresponse.go @@ -0,0 +1,8 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + ValidationResults *[]ErrorDetail `json:"validationResults,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationsresponse.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationsresponse.go new file mode 100644 index 00000000000..8b9f3991c07 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validateoperationsresponse.go @@ -0,0 +1,8 @@ +package operation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationsResponse struct { + ValidateOperationResponse *ValidateOperationResponse `json:"validateOperationResponse,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validaterestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validaterestoreoperationrequest.go new file mode 100644 index 00000000000..5fe10835e45 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/model_validaterestoreoperationrequest.go @@ -0,0 +1,60 @@ +package operation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ValidateOperationRequest = ValidateRestoreOperationRequest{} + +type ValidateRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +var _ json.Marshaler = ValidateRestoreOperationRequest{} + +func (s ValidateRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateRestoreOperationRequest: %+v", err) + } + decoded["objectType"] = "ValidateRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateRestoreOperationRequest{} + +func (s *ValidateRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := unmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/operation/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/operation/version.go new file mode 100644 index 00000000000..e5ca752ef35 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/operation/version.go @@ -0,0 +1,12 @@ +package operation + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/operation/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/README.md new file mode 100644 index 00000000000..906e0d4a046 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection` Documentation + +The `privateendpointconnection` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection" +``` + + +### Client Initialization + +```go +client := privateendpointconnection.NewPrivateEndpointConnectionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionClient.Put` + +```go +ctx := context.TODO() +id := privateendpointconnection.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") + +payload := privateendpointconnection.PrivateEndpointConnectionResource{ + // ... +} + + +if err := client.PutThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/client.go new file mode 100644 index 00000000000..6acd77b913c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/client.go @@ -0,0 +1,18 @@ +package privateendpointconnection + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionClient struct { + Client autorest.Client + baseUri string +} + +func NewPrivateEndpointConnectionClientWithBaseURI(endpoint string) PrivateEndpointConnectionClient { + return PrivateEndpointConnectionClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/constants.go new file mode 100644 index 00000000000..656d9100fa4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/constants.go @@ -0,0 +1,105 @@ +package privateendpointconnection + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionStatus string + +const ( + PrivateEndpointConnectionStatusApproved PrivateEndpointConnectionStatus = "Approved" + PrivateEndpointConnectionStatusDisconnected PrivateEndpointConnectionStatus = "Disconnected" + PrivateEndpointConnectionStatusPending PrivateEndpointConnectionStatus = "Pending" + PrivateEndpointConnectionStatusRejected PrivateEndpointConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointConnectionStatus() []string { + return []string{ + string(PrivateEndpointConnectionStatusApproved), + string(PrivateEndpointConnectionStatusDisconnected), + string(PrivateEndpointConnectionStatusPending), + string(PrivateEndpointConnectionStatusRejected), + } +} + +func parsePrivateEndpointConnectionStatus(input string) (*PrivateEndpointConnectionStatus, error) { + vals := map[string]PrivateEndpointConnectionStatus{ + "approved": PrivateEndpointConnectionStatusApproved, + "disconnected": PrivateEndpointConnectionStatusDisconnected, + "pending": PrivateEndpointConnectionStatusPending, + "rejected": PrivateEndpointConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStatePending ProvisioningState = "Pending" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStatePending), + string(ProvisioningStateSucceeded), + } +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "pending": ProvisioningStatePending, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VaultSubResourceType string + +const ( + VaultSubResourceTypeAzureBackup VaultSubResourceType = "AzureBackup" + VaultSubResourceTypeAzureBackupSecondary VaultSubResourceType = "AzureBackup_secondary" + VaultSubResourceTypeAzureSiteRecovery VaultSubResourceType = "AzureSiteRecovery" +) + +func PossibleValuesForVaultSubResourceType() []string { + return []string{ + string(VaultSubResourceTypeAzureBackup), + string(VaultSubResourceTypeAzureBackupSecondary), + string(VaultSubResourceTypeAzureSiteRecovery), + } +} + +func parseVaultSubResourceType(input string) (*VaultSubResourceType, error) { + vals := map[string]VaultSubResourceType{ + "azurebackup": VaultSubResourceTypeAzureBackup, + "azurebackup_secondary": VaultSubResourceTypeAzureBackupSecondary, + "azuresiterecovery": VaultSubResourceTypeAzureSiteRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VaultSubResourceType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection.go new file mode 100644 index 00000000000..17d1dcf18e4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnection + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, vaultName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..acb07fdeba7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnection + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_delete_autorest.go new file mode 100644 index 00000000000..7e8532d71b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_delete_autorest.go @@ -0,0 +1,78 @@ +package privateendpointconnection + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c PrivateEndpointConnectionClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c PrivateEndpointConnectionClient) preparerForDelete(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c PrivateEndpointConnectionClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_get_autorest.go new file mode 100644 index 00000000000..d5309175155 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_get_autorest.go @@ -0,0 +1,68 @@ +package privateendpointconnection + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *PrivateEndpointConnectionResource +} + +// Get ... +func (c PrivateEndpointConnectionClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c PrivateEndpointConnectionClient) preparerForGet(ctx context.Context, id PrivateEndpointConnectionId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c PrivateEndpointConnectionClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_put_autorest.go new file mode 100644 index 00000000000..072a1c747d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/method_put_autorest.go @@ -0,0 +1,80 @@ +package privateendpointconnection + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response + Model *PrivateEndpointConnectionResource +} + +// Put ... +func (c PrivateEndpointConnectionClient) Put(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionResource) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Put", nil, "Failure preparing request") + return + } + + result, err = c.senderForPut(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "privateendpointconnection.PrivateEndpointConnectionClient", "Put", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// PutThenPoll performs Put then polls until it's completed +func (c PrivateEndpointConnectionClient) PutThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionResource) error { + result, err := c.Put(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Put: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Put: %+v", err) + } + + return nil +} + +// preparerForPut prepares the Put request. +func (c PrivateEndpointConnectionClient) preparerForPut(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnectionResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForPut sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (c PrivateEndpointConnectionClient) senderForPut(ctx context.Context, req *http.Request) (future PutOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpoint.go new file mode 100644 index 00000000000..36d044c72d1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnection.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnection.go new file mode 100644 index 00000000000..0acbbb1f932 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + GroupIds *[]VaultSubResourceType `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnectionresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnectionresource.go new file mode 100644 index 00000000000..e3f0f4f5c74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privateendpointconnectionresource.go @@ -0,0 +1,14 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnection `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..81c55145a70 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnection + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/version.go new file mode 100644 index 00000000000..c706633cdb1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/privateendpointconnection/version.go @@ -0,0 +1,12 @@ +package privateendpointconnection + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privateendpointconnection/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/README.md new file mode 100644 index 00000000000..3a32e193ab3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers` Documentation + +The `protectablecontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers" +``` + + +### Client Initialization + +```go +client := protectablecontainers.NewProtectableContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectableContainersClient.List` + +```go +ctx := context.TODO() +id := protectablecontainers.NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue") + +// alternatively `client.List(ctx, id, protectablecontainers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, protectablecontainers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/client.go new file mode 100644 index 00000000000..3d5274d457a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/client.go @@ -0,0 +1,18 @@ +package protectablecontainers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectableContainersClientWithBaseURI(endpoint string) ProtectableContainersClient { + return ProtectableContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/constants.go new file mode 100644 index 00000000000..7d347c78755 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/constants.go @@ -0,0 +1,131 @@ +package protectablecontainers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric.go new file mode 100644 index 00000000000..34e69409306 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric.go @@ -0,0 +1,139 @@ +package protectablecontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupFabricId{}) +} + +var _ resourceids.ResourceId = &BackupFabricId{} + +// BackupFabricId is a struct representing the Resource ID for a Backup Fabric +type BackupFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string +} + +// NewBackupFabricID returns a new BackupFabricId struct +func NewBackupFabricID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string) BackupFabricId { + return BackupFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + } +} + +// ParseBackupFabricID parses 'input' into a BackupFabricId +func ParseBackupFabricID(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupFabricIDInsensitively parses 'input' case-insensitively into a BackupFabricId +// note: this method should only be used for API response data and not user input +func ParseBackupFabricIDInsensitively(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + return nil +} + +// ValidateBackupFabricID checks that 'input' can be parsed as a Backup Fabric ID +func ValidateBackupFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Fabric ID +func (id BackupFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Fabric ID +func (id BackupFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + } +} + +// String returns a human-readable description of this Backup Fabric ID +func (id BackupFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + } + return fmt.Sprintf("Backup Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric_test.go new file mode 100644 index 00000000000..9743a82705c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/id_backupfabric_test.go @@ -0,0 +1,327 @@ +package protectablecontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupFabricId{} + +func TestNewBackupFabricID(t *testing.T) { + id := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } +} + +func TestFormatBackupFabricID(t *testing.T) { + actual := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestParseBackupFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestSegmentsForBackupFabricId(t *testing.T) { + segments := BackupFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/method_list_autorest.go new file mode 100644 index 00000000000..bdea7c60f0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/method_list_autorest.go @@ -0,0 +1,215 @@ +package protectablecontainers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectableContainerResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []ProtectableContainerResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c ProtectableContainersClient) List(ctx context.Context, id BackupFabricId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c ProtectableContainersClient) preparerForList(ctx context.Context, id BackupFabricId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/protectableContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c ProtectableContainersClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c ProtectableContainersClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []ProtectableContainerResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectablecontainers.ProtectableContainersClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c ProtectableContainersClient) ListComplete(ctx context.Context, id BackupFabricId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ProtectableContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ProtectableContainersClient) ListCompleteMatchingPredicate(ctx context.Context, id BackupFabricId, options ListOperationOptions, predicate ProtectableContainerResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]ProtectableContainerResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurestorageprotectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurestorageprotectablecontainer.go new file mode 100644 index 00000000000..138e03f203a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurestorageprotectablecontainer.go @@ -0,0 +1,44 @@ +package protectablecontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectableContainer = AzureStorageProtectableContainer{} + +type AzureStorageProtectableContainer struct { + + // Fields inherited from ProtectableContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageProtectableContainer{} + +func (s AzureStorageProtectableContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageProtectableContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageProtectableContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageProtectableContainer: %+v", err) + } + decoded["protectableContainerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageProtectableContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go new file mode 100644 index 00000000000..ea902c91b28 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_azurevmappcontainerprotectablecontainer.go @@ -0,0 +1,44 @@ +package protectablecontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectableContainer = AzureVMAppContainerProtectableContainer{} + +type AzureVMAppContainerProtectableContainer struct { + + // Fields inherited from ProtectableContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectableContainer{} + +func (s AzureVMAppContainerProtectableContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectableContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectableContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectableContainer: %+v", err) + } + decoded["protectableContainerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectableContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainer.go new file mode 100644 index 00000000000..52366aa9b98 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainer.go @@ -0,0 +1,61 @@ +package protectablecontainers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableContainer interface { +} + +// RawProtectableContainerImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectableContainerImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectableContainerImplementation(input []byte) (ProtectableContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectableContainer into map[string]interface: %+v", err) + } + + value, ok := temp["protectableContainerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageProtectableContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageProtectableContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectableContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectableContainer: %+v", err) + } + return out, nil + } + + out := RawProtectableContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainerresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainerresource.go new file mode 100644 index 00000000000..c4d67d07b27 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/model_protectablecontainerresource.go @@ -0,0 +1,50 @@ +package protectablecontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableContainerResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectableContainer `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectableContainerResource{} + +func (s *ProtectableContainerResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectableContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectableContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectableContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectableContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectableContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/predicates.go new file mode 100644 index 00000000000..8ce6de2e8ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/predicates.go @@ -0,0 +1,37 @@ +package protectablecontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectableContainerResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectableContainerResourceOperationPredicate) Matches(input ProtectableContainerResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/version.go new file mode 100644 index 00000000000..3d299a2b44f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectablecontainers/version.go @@ -0,0 +1,12 @@ +package protectablecontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectablecontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/README.md new file mode 100644 index 00000000000..faacc8e4479 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/README.md @@ -0,0 +1,73 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems` Documentation + +The `protecteditems` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems" +``` + + +### Client Initialization + +```go +client := protecteditems.NewProtectedItemsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectedItemsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +payload := protecteditems.ProtectedItemResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, protecteditems.DefaultCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectedItemsClient.Delete` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectedItemsClient.Get` + +```go +ctx := context.TODO() +id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +read, err := client.Get(ctx, id, protecteditems.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/client.go new file mode 100644 index 00000000000..6843a00f823 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/client.go @@ -0,0 +1,18 @@ +package protecteditems + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemsClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectedItemsClientWithBaseURI(endpoint string) ProtectedItemsClient { + return ProtectedItemsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/constants.go new file mode 100644 index 00000000000..622b31da48b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/constants.go @@ -0,0 +1,387 @@ +package protecteditems + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type CreateMode string + +const ( + CreateModeDefault CreateMode = "Default" + CreateModeInvalid CreateMode = "Invalid" + CreateModeRecover CreateMode = "Recover" +) + +func PossibleValuesForCreateMode() []string { + return []string{ + string(CreateModeDefault), + string(CreateModeInvalid), + string(CreateModeRecover), + } +} + +func parseCreateMode(input string) (*CreateMode, error) { + vals := map[string]CreateMode{ + "default": CreateModeDefault, + "invalid": CreateModeInvalid, + "recover": CreateModeRecover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CreateMode(input) + return &out, nil +} + +type DataSourceType string + +const ( + DataSourceTypeAzureFileShare DataSourceType = "AzureFileShare" + DataSourceTypeAzureSqlDb DataSourceType = "AzureSqlDb" + DataSourceTypeClient DataSourceType = "Client" + DataSourceTypeExchange DataSourceType = "Exchange" + DataSourceTypeFileFolder DataSourceType = "FileFolder" + DataSourceTypeGenericDataSource DataSourceType = "GenericDataSource" + DataSourceTypeInvalid DataSourceType = "Invalid" + DataSourceTypeSAPAseDatabase DataSourceType = "SAPAseDatabase" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + DataSourceTypeSAPHanaDatabase DataSourceType = "SAPHanaDatabase" + DataSourceTypeSQLDB DataSourceType = "SQLDB" + DataSourceTypeSQLDataBase DataSourceType = "SQLDataBase" + DataSourceTypeSharepoint DataSourceType = "Sharepoint" + DataSourceTypeSystemState DataSourceType = "SystemState" + DataSourceTypeVM DataSourceType = "VM" + DataSourceTypeVMwareVM DataSourceType = "VMwareVM" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAzureFileShare), + string(DataSourceTypeAzureSqlDb), + string(DataSourceTypeClient), + string(DataSourceTypeExchange), + string(DataSourceTypeFileFolder), + string(DataSourceTypeGenericDataSource), + string(DataSourceTypeInvalid), + string(DataSourceTypeSAPAseDatabase), + string(DataSourceTypeSAPHanaDBInstance), + string(DataSourceTypeSAPHanaDatabase), + string(DataSourceTypeSQLDB), + string(DataSourceTypeSQLDataBase), + string(DataSourceTypeSharepoint), + string(DataSourceTypeSystemState), + string(DataSourceTypeVM), + string(DataSourceTypeVMwareVM), + } +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "azurefileshare": DataSourceTypeAzureFileShare, + "azuresqldb": DataSourceTypeAzureSqlDb, + "client": DataSourceTypeClient, + "exchange": DataSourceTypeExchange, + "filefolder": DataSourceTypeFileFolder, + "genericdatasource": DataSourceTypeGenericDataSource, + "invalid": DataSourceTypeInvalid, + "sapasedatabase": DataSourceTypeSAPAseDatabase, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "saphanadatabase": DataSourceTypeSAPHanaDatabase, + "sqldb": DataSourceTypeSQLDB, + "sqldatabase": DataSourceTypeSQLDataBase, + "sharepoint": DataSourceTypeSharepoint, + "systemstate": DataSourceTypeSystemState, + "vm": DataSourceTypeVM, + "vmwarevm": DataSourceTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} + +type HealthStatus string + +const ( + HealthStatusActionRequired HealthStatus = "ActionRequired" + HealthStatusActionSuggested HealthStatus = "ActionSuggested" + HealthStatusInvalid HealthStatus = "Invalid" + HealthStatusPassed HealthStatus = "Passed" +) + +func PossibleValuesForHealthStatus() []string { + return []string{ + string(HealthStatusActionRequired), + string(HealthStatusActionSuggested), + string(HealthStatusInvalid), + string(HealthStatusPassed), + } +} + +func parseHealthStatus(input string) (*HealthStatus, error) { + vals := map[string]HealthStatus{ + "actionrequired": HealthStatusActionRequired, + "actionsuggested": HealthStatusActionSuggested, + "invalid": HealthStatusInvalid, + "passed": HealthStatusPassed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HealthStatus(input) + return &out, nil +} + +type LastBackupStatus string + +const ( + LastBackupStatusHealthy LastBackupStatus = "Healthy" + LastBackupStatusIRPending LastBackupStatus = "IRPending" + LastBackupStatusInvalid LastBackupStatus = "Invalid" + LastBackupStatusUnhealthy LastBackupStatus = "Unhealthy" +) + +func PossibleValuesForLastBackupStatus() []string { + return []string{ + string(LastBackupStatusHealthy), + string(LastBackupStatusIRPending), + string(LastBackupStatusInvalid), + string(LastBackupStatusUnhealthy), + } +} + +func parseLastBackupStatus(input string) (*LastBackupStatus, error) { + vals := map[string]LastBackupStatus{ + "healthy": LastBackupStatusHealthy, + "irpending": LastBackupStatusIRPending, + "invalid": LastBackupStatusInvalid, + "unhealthy": LastBackupStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LastBackupStatus(input) + return &out, nil +} + +type ProtectedItemHealthStatus string + +const ( + ProtectedItemHealthStatusHealthy ProtectedItemHealthStatus = "Healthy" + ProtectedItemHealthStatusIRPending ProtectedItemHealthStatus = "IRPending" + ProtectedItemHealthStatusInvalid ProtectedItemHealthStatus = "Invalid" + ProtectedItemHealthStatusNotReachable ProtectedItemHealthStatus = "NotReachable" + ProtectedItemHealthStatusUnhealthy ProtectedItemHealthStatus = "Unhealthy" +) + +func PossibleValuesForProtectedItemHealthStatus() []string { + return []string{ + string(ProtectedItemHealthStatusHealthy), + string(ProtectedItemHealthStatusIRPending), + string(ProtectedItemHealthStatusInvalid), + string(ProtectedItemHealthStatusNotReachable), + string(ProtectedItemHealthStatusUnhealthy), + } +} + +func parseProtectedItemHealthStatus(input string) (*ProtectedItemHealthStatus, error) { + vals := map[string]ProtectedItemHealthStatus{ + "healthy": ProtectedItemHealthStatusHealthy, + "irpending": ProtectedItemHealthStatusIRPending, + "invalid": ProtectedItemHealthStatusInvalid, + "notreachable": ProtectedItemHealthStatusNotReachable, + "unhealthy": ProtectedItemHealthStatusUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemHealthStatus(input) + return &out, nil +} + +type ProtectedItemState string + +const ( + ProtectedItemStateBackupsSuspended ProtectedItemState = "BackupsSuspended" + ProtectedItemStateIRPending ProtectedItemState = "IRPending" + ProtectedItemStateInvalid ProtectedItemState = "Invalid" + ProtectedItemStateProtected ProtectedItemState = "Protected" + ProtectedItemStateProtectionError ProtectedItemState = "ProtectionError" + ProtectedItemStateProtectionPaused ProtectedItemState = "ProtectionPaused" + ProtectedItemStateProtectionStopped ProtectedItemState = "ProtectionStopped" +) + +func PossibleValuesForProtectedItemState() []string { + return []string{ + string(ProtectedItemStateBackupsSuspended), + string(ProtectedItemStateIRPending), + string(ProtectedItemStateInvalid), + string(ProtectedItemStateProtected), + string(ProtectedItemStateProtectionError), + string(ProtectedItemStateProtectionPaused), + string(ProtectedItemStateProtectionStopped), + } +} + +func parseProtectedItemState(input string) (*ProtectedItemState, error) { + vals := map[string]ProtectedItemState{ + "backupssuspended": ProtectedItemStateBackupsSuspended, + "irpending": ProtectedItemStateIRPending, + "invalid": ProtectedItemStateInvalid, + "protected": ProtectedItemStateProtected, + "protectionerror": ProtectedItemStateProtectionError, + "protectionpaused": ProtectedItemStateProtectionPaused, + "protectionstopped": ProtectedItemStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectedItemState(input) + return &out, nil +} + +type ProtectionState string + +const ( + ProtectionStateBackupsSuspended ProtectionState = "BackupsSuspended" + ProtectionStateIRPending ProtectionState = "IRPending" + ProtectionStateInvalid ProtectionState = "Invalid" + ProtectionStateProtected ProtectionState = "Protected" + ProtectionStateProtectionError ProtectionState = "ProtectionError" + ProtectionStateProtectionPaused ProtectionState = "ProtectionPaused" + ProtectionStateProtectionStopped ProtectionState = "ProtectionStopped" +) + +func PossibleValuesForProtectionState() []string { + return []string{ + string(ProtectionStateBackupsSuspended), + string(ProtectionStateIRPending), + string(ProtectionStateInvalid), + string(ProtectionStateProtected), + string(ProtectionStateProtectionError), + string(ProtectionStateProtectionPaused), + string(ProtectionStateProtectionStopped), + } +} + +func parseProtectionState(input string) (*ProtectionState, error) { + vals := map[string]ProtectionState{ + "backupssuspended": ProtectionStateBackupsSuspended, + "irpending": ProtectionStateIRPending, + "invalid": ProtectionStateInvalid, + "protected": ProtectionStateProtected, + "protectionerror": ProtectionStateProtectionError, + "protectionpaused": ProtectionStateProtectionPaused, + "protectionstopped": ProtectionStateProtectionStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionState(input) + return &out, nil +} + +type ResourceHealthStatus string + +const ( + ResourceHealthStatusHealthy ResourceHealthStatus = "Healthy" + ResourceHealthStatusInvalid ResourceHealthStatus = "Invalid" + ResourceHealthStatusPersistentDegraded ResourceHealthStatus = "PersistentDegraded" + ResourceHealthStatusPersistentUnhealthy ResourceHealthStatus = "PersistentUnhealthy" + ResourceHealthStatusTransientDegraded ResourceHealthStatus = "TransientDegraded" + ResourceHealthStatusTransientUnhealthy ResourceHealthStatus = "TransientUnhealthy" +) + +func PossibleValuesForResourceHealthStatus() []string { + return []string{ + string(ResourceHealthStatusHealthy), + string(ResourceHealthStatusInvalid), + string(ResourceHealthStatusPersistentDegraded), + string(ResourceHealthStatusPersistentUnhealthy), + string(ResourceHealthStatusTransientDegraded), + string(ResourceHealthStatusTransientUnhealthy), + } +} + +func parseResourceHealthStatus(input string) (*ResourceHealthStatus, error) { + vals := map[string]ResourceHealthStatus{ + "healthy": ResourceHealthStatusHealthy, + "invalid": ResourceHealthStatusInvalid, + "persistentdegraded": ResourceHealthStatusPersistentDegraded, + "persistentunhealthy": ResourceHealthStatusPersistentUnhealthy, + "transientdegraded": ResourceHealthStatusTransientDegraded, + "transientunhealthy": ResourceHealthStatusTransientUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceHealthStatus(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem.go new file mode 100644 index 00000000000..712e70d39b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem.go @@ -0,0 +1,157 @@ +package protecteditems + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProtectedItemIDInsensitively parses 'input' case-insensitively into a ProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseProtectedItemIDInsensitively(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return nil +} + +// ValidateProtectedItemID checks that 'input' can be parsed as a Protected Item ID +func ValidateProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protected Item ID +func (id ProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protected Item ID +func (id ProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem_test.go new file mode 100644 index 00000000000..3101e1c2911 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package protecteditems + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_createorupdate_autorest.go new file mode 100644 index 00000000000..f83f85fe3ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_createorupdate_autorest.go @@ -0,0 +1,98 @@ +package protecteditems + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ProtectedItemResource +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// CreateOrUpdate ... +func (c ProtectedItemsClient) CreateOrUpdate(ctx context.Context, id ProtectedItemId, input ProtectedItemResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectedItemsClient) preparerForCreateOrUpdate(ctx context.Context, id ProtectedItemId, input ProtectedItemResource, options CreateOrUpdateOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ProtectedItemsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_delete_autorest.go new file mode 100644 index 00000000000..ed0ba3ec7a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_delete_autorest.go @@ -0,0 +1,66 @@ +package protecteditems + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c ProtectedItemsClient) Delete(ctx context.Context, id ProtectedItemId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ProtectedItemsClient) preparerForDelete(ctx context.Context, id ProtectedItemId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c ProtectedItemsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_get_autorest.go new file mode 100644 index 00000000000..feb41aa7dcb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/method_get_autorest.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ProtectedItemResource +} + +type GetOperationOptions struct { + Filter *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o GetOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Get ... +func (c ProtectedItemsClient) Get(ctx context.Context, id ProtectedItemId, options GetOperationOptions) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectedItemsClient) preparerForGet(ctx context.Context, id ProtectedItemId, options GetOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ProtectedItemsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditem.go new file mode 100644 index 00000000000..4a8bcc205f7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditem.go @@ -0,0 +1,92 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureFileshareProtectedItem{} + +type AzureFileshareProtectedItem struct { + ExtendedInfo *AzureFileshareProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureFileshareProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureFileshareProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureFileshareProtectedItem{} + +func (s AzureFileshareProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureFileshareProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileshareProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileshareProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureFileShareProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileshareProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go new file mode 100644 index 00000000000..f3ee3ce37c0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurefileshareprotecteditemextendedinfo.go @@ -0,0 +1,42 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFileshareProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + ResourceState *string `json:"resourceState,omitempty"` + ResourceStateSyncTime *string `json:"resourceStateSyncTime,omitempty"` +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureFileshareProtectedItemExtendedInfo) GetResourceStateSyncTimeAsTime() (*time.Time, error) { + if o.ResourceStateSyncTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ResourceStateSyncTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureFileshareProtectedItemExtendedInfo) SetResourceStateSyncTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ResourceStateSyncTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go new file mode 100644 index 00000000000..b51e15f7de7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasclassiccomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSClassicComputeVMProtectedItem{} + +type AzureIaaSClassicComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSClassicComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMProtectedItem{} + +func (s AzureIaaSClassicComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaascomputevmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaascomputevmprotecteditem.go new file mode 100644 index 00000000000..154e875f0d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaascomputevmprotecteditem.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSComputeVMProtectedItem{} + +type AzureIaaSComputeVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSComputeVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSComputeVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSComputeVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSComputeVMProtectedItem{} + +func (s AzureIaaSComputeVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditem.go new file mode 100644 index 00000000000..a328c909a54 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditem.go @@ -0,0 +1,97 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureIaaSVMProtectedItem{} + +type AzureIaaSVMProtectedItem struct { + ExtendedInfo *AzureIaaSVMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ExtendedProperties *ExtendedProperties `json:"extendedProperties,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthDetails *[]ResourceHealthDetails `json:"healthDetails,omitempty"` + HealthStatus *HealthStatus `json:"healthStatus,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureIaaSVMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureIaaSVMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureIaaSVMProtectedItem{} + +func (s AzureIaaSVMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureIaaSVMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..36c092fb410 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azureiaasvmprotecteditemextendedinfo.go @@ -0,0 +1,67 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureIaaSVMProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyInconsistent *bool `json:"policyInconsistent,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureIaaSVMProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditem.go new file mode 100644 index 00000000000..1af6fd59264 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditem.go @@ -0,0 +1,88 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureSqlProtectedItem{} + +type AzureSqlProtectedItem struct { + ExtendedInfo *AzureSqlProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemDataId *string `json:"protectedItemDataId,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureSqlProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureSqlProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureSqlProtectedItem{} + +func (s AzureSqlProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "Microsoft.Sql/servers/databases" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go new file mode 100644 index 00000000000..3b6ba503042 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azuresqlprotecteditemextendedinfo.go @@ -0,0 +1,28 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureSqlProtectedItemExtendedInfo struct { + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureSqlProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureSqlProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditem.go new file mode 100644 index 00000000000..234b099a17b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditem.go @@ -0,0 +1,99 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadProtectedItem{} + +type AzureVMWorkloadProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadProtectedItem{} + +func (s AzureVMWorkloadProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go new file mode 100644 index 00000000000..e51960b91cf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadprotecteditemextendedinfo.go @@ -0,0 +1,68 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureVMWorkloadProtectedItemExtendedInfo struct { + NewestRecoveryPointInArchive *string `json:"newestRecoveryPointInArchive,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OldestRecoveryPointInArchive *string `json:"oldestRecoveryPointInArchive,omitempty"` + OldestRecoveryPointInVault *string `json:"oldestRecoveryPointInVault,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + RecoveryModel *string `json:"recoveryModel,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetNewestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.NewestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NewestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetNewestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NewestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInArchiveAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInArchive == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInArchive, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInArchiveAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInArchive = &formatted +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) GetOldestRecoveryPointInVaultAsTime() (*time.Time, error) { + if o.OldestRecoveryPointInVault == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPointInVault, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadProtectedItemExtendedInfo) SetOldestRecoveryPointInVaultAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPointInVault = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go new file mode 100644 index 00000000000..f2756534346 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsapasedatabaseprotecteditem.go @@ -0,0 +1,99 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +type AzureVMWorkloadSAPAseDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPAseDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPAseDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPAseDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPAseDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPAseDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go new file mode 100644 index 00000000000..deb8fd3e6e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadatabaseprotecteditem.go @@ -0,0 +1,99 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +type AzureVMWorkloadSAPHanaDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDatabaseProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go new file mode 100644 index 00000000000..b055967910f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsaphanadbinstanceprotecteditem.go @@ -0,0 +1,99 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +type AzureVMWorkloadSAPHanaDBInstanceProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSAPHanaDBInstanceProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSAPHanaDBInstanceProtectedItem{} + +func (s AzureVMWorkloadSAPHanaDBInstanceProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSAPHanaDBInstanceProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSAPHanaDBInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go new file mode 100644 index 00000000000..8a644318f7a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_azurevmworkloadsqldatabaseprotecteditem.go @@ -0,0 +1,99 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = AzureVMWorkloadSQLDatabaseProtectedItem{} + +type AzureVMWorkloadSQLDatabaseProtectedItem struct { + ExtendedInfo *AzureVMWorkloadProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + KpisHealths *map[string]KPIResourceHealthDetails `json:"kpisHealths,omitempty"` + LastBackupErrorDetail *ErrorDetail `json:"lastBackupErrorDetail,omitempty"` + LastBackupStatus *LastBackupStatus `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` + ParentName *string `json:"parentName,omitempty"` + ParentType *string `json:"parentType,omitempty"` + ProtectedItemDataSourceId *string `json:"protectedItemDataSourceId,omitempty"` + ProtectedItemHealthStatus *ProtectedItemHealthStatus `json:"protectedItemHealthStatus,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + ServerName *string `json:"serverName,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureVMWorkloadSQLDatabaseProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = AzureVMWorkloadSQLDatabaseProtectedItem{} + +func (s AzureVMWorkloadSQLDatabaseProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadSQLDatabaseProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "AzureVmWorkloadSQLDatabase" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_diskexclusionproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_diskexclusionproperties.go new file mode 100644 index 00000000000..17d722bc609 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_diskexclusionproperties.go @@ -0,0 +1,9 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskExclusionProperties struct { + DiskLunList *[]int64 `json:"diskLunList,omitempty"` + IsInclusionList *bool `json:"isInclusionList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_distributednodesinfo.go new file mode 100644 index 00000000000..a67db74854b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditem.go new file mode 100644 index 00000000000..eb37672a633 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditem.go @@ -0,0 +1,89 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = DPMProtectedItem{} + +type DPMProtectedItem struct { + BackupEngineName *string `json:"backupEngineName,omitempty"` + ExtendedInfo *DPMProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ProtectionState *ProtectedItemState `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *DPMProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *DPMProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = DPMProtectedItem{} + +func (s DPMProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper DPMProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DPMProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DPMProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "DPMProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DPMProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditemextendedinfo.go new file mode 100644 index 00000000000..fc6f9e8cd52 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_dpmprotecteditemextendedinfo.go @@ -0,0 +1,75 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMProtectedItemExtendedInfo struct { + DiskStorageUsedInBytes *string `json:"diskStorageUsedInBytes,omitempty"` + IsCollocated *bool `json:"isCollocated,omitempty"` + IsPresentOnCloud *bool `json:"isPresentOnCloud,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + OnPremiseLatestRecoveryPoint *string `json:"onPremiseLatestRecoveryPoint,omitempty"` + OnPremiseOldestRecoveryPoint *string `json:"onPremiseOldestRecoveryPoint,omitempty"` + OnPremiseRecoveryPointCount *int64 `json:"onPremiseRecoveryPointCount,omitempty"` + ProtectableObjectLoadPath *map[string]string `json:"protectableObjectLoadPath,omitempty"` + Protected *bool `json:"protected,omitempty"` + ProtectionGroupName *string `json:"protectionGroupName,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` + TotalDiskStorageSizeInBytes *string `json:"totalDiskStorageSizeInBytes,omitempty"` +} + +func (o *DPMProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseLatestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseLatestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseLatestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseLatestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseLatestRecoveryPoint = &formatted +} + +func (o *DPMProtectedItemExtendedInfo) GetOnPremiseOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OnPremiseOldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OnPremiseOldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMProtectedItemExtendedInfo) SetOnPremiseOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OnPremiseOldestRecoveryPoint = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_errordetail.go new file mode 100644 index 00000000000..e3fa04c50a3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_errordetail.go @@ -0,0 +1,10 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_extendedproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_extendedproperties.go new file mode 100644 index 00000000000..fe926ccaa09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_extendedproperties.go @@ -0,0 +1,9 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedProperties struct { + DiskExclusionProperties *DiskExclusionProperties `json:"diskExclusionProperties,omitempty"` + LinuxVMApplicationName *string `json:"linuxVmApplicationName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_genericprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_genericprotecteditem.go new file mode 100644 index 00000000000..b3bc228cfd9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_genericprotecteditem.go @@ -0,0 +1,91 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = GenericProtectedItem{} + +type GenericProtectedItem struct { + FabricName *string `json:"fabricName,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + PolicyState *string `json:"policyState,omitempty"` + ProtectedItemId *int64 `json:"protectedItemId,omitempty"` + ProtectionState *ProtectionState `json:"protectionState,omitempty"` + SourceAssociations *map[string]string `json:"sourceAssociations,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *GenericProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *GenericProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *GenericProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = GenericProtectedItem{} + +func (s GenericProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "GenericProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_kpiresourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_kpiresourcehealthdetails.go new file mode 100644 index 00000000000..6cef5da3613 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_kpiresourcehealthdetails.go @@ -0,0 +1,9 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KPIResourceHealthDetails struct { + ResourceHealthDetails *[]ResourceHealthDetails `json:"resourceHealthDetails,omitempty"` + ResourceHealthStatus *ResourceHealthStatus `json:"resourceHealthStatus,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditem.go new file mode 100644 index 00000000000..5e1cd167706 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditem.go @@ -0,0 +1,92 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectedItem = MabFileFolderProtectedItem{} + +type MabFileFolderProtectedItem struct { + ComputerName *string `json:"computerName,omitempty"` + DeferredDeleteSyncTimeInUTC *int64 `json:"deferredDeleteSyncTimeInUTC,omitempty"` + ExtendedInfo *MabFileFolderProtectedItemExtendedInfo `json:"extendedInfo,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastBackupTime *string `json:"lastBackupTime,omitempty"` + ProtectionState *string `json:"protectionState,omitempty"` + + // Fields inherited from ProtectedItem + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + BackupSetName *string `json:"backupSetName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + CreateMode *CreateMode `json:"createMode,omitempty"` + DeferredDeleteTimeInUTC *string `json:"deferredDeleteTimeInUTC,omitempty"` + DeferredDeleteTimeRemaining *string `json:"deferredDeleteTimeRemaining,omitempty"` + IsArchiveEnabled *bool `json:"isArchiveEnabled,omitempty"` + IsDeferredDeleteScheduleUpcoming *bool `json:"isDeferredDeleteScheduleUpcoming,omitempty"` + IsRehydrate *bool `json:"isRehydrate,omitempty"` + IsScheduledForDeferredDelete *bool `json:"isScheduledForDeferredDelete,omitempty"` + LastRecoveryPoint *string `json:"lastRecoveryPoint,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + PolicyName *string `json:"policyName,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + SoftDeleteRetentionPeriodInDays *int64 `json:"softDeleteRetentionPeriodInDays,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + VaultId *string `json:"vaultId,omitempty"` + WorkloadType *DataSourceType `json:"workloadType,omitempty"` +} + +func (o *MabFileFolderProtectedItem) GetDeferredDeleteTimeInUTCAsTime() (*time.Time, error) { + if o.DeferredDeleteTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DeferredDeleteTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetDeferredDeleteTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DeferredDeleteTimeInUTC = &formatted +} + +func (o *MabFileFolderProtectedItem) GetLastRecoveryPointAsTime() (*time.Time, error) { + if o.LastRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItem) SetLastRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRecoveryPoint = &formatted +} + +var _ json.Marshaler = MabFileFolderProtectedItem{} + +func (s MabFileFolderProtectedItem) MarshalJSON() ([]byte, error) { + type wrapper MabFileFolderProtectedItem + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabFileFolderProtectedItem: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabFileFolderProtectedItem: %+v", err) + } + decoded["protectedItemType"] = "MabFileFolderProtectedItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabFileFolderProtectedItem: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go new file mode 100644 index 00000000000..fbb9afca971 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_mabfilefolderprotecteditemextendedinfo.go @@ -0,0 +1,40 @@ +package protecteditems + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabFileFolderProtectedItemExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + OldestRecoveryPoint *string `json:"oldestRecoveryPoint,omitempty"` + RecoveryPointCount *int64 `json:"recoveryPointCount,omitempty"` +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} + +func (o *MabFileFolderProtectedItemExtendedInfo) GetOldestRecoveryPointAsTime() (*time.Time, error) { + if o.OldestRecoveryPoint == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OldestRecoveryPoint, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabFileFolderProtectedItemExtendedInfo) SetOldestRecoveryPointAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OldestRecoveryPoint = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditem.go new file mode 100644 index 00000000000..ffceef4149c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditem.go @@ -0,0 +1,149 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItem interface { +} + +// RawProtectedItemImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectedItemImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectedItemImplementation(input []byte) (ProtectedItem, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectedItem into map[string]interface: %+v", err) + } + + value, ok := temp["protectedItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareProtectedItem") { + var out AzureFileshareProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileshareProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaaSVMProtectedItem") { + var out AzureIaaSVMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Sql/servers/databases") { + var out AzureSqlProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadProtectedItem") { + var out AzureVMWorkloadProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPAseDatabase") { + var out AzureVMWorkloadSAPAseDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPAseDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPHanaDBInstance") { + var out AzureVMWorkloadSAPHanaDBInstanceProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDBInstanceProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSAPHanaDatabase") { + var out AzureVMWorkloadSAPHanaDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSAPHanaDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureVmWorkloadSQLDatabase") { + var out AzureVMWorkloadSQLDatabaseProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadSQLDatabaseProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMProtectedItem") { + var out DPMProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DPMProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectedItem") { + var out GenericProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectedItem: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MabFileFolderProtectedItem") { + var out MabFileFolderProtectedItem + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabFileFolderProtectedItem: %+v", err) + } + return out, nil + } + + out := RawProtectedItemImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditemresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditemresource.go new file mode 100644 index 00000000000..0541c1a67ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_protecteditemresource.go @@ -0,0 +1,50 @@ +package protecteditems + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectedItemResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectedItem `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectedItemResource{} + +func (s *ProtectedItemResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectedItemResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectedItemResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectedItemResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectedItemImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectedItemResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_resourcehealthdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_resourcehealthdetails.go new file mode 100644 index 00000000000..86710207857 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/model_resourcehealthdetails.go @@ -0,0 +1,11 @@ +package protecteditems + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/version.go new file mode 100644 index 00000000000..bd1522b6580 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protecteditems/version.go @@ -0,0 +1,12 @@ +package protecteditems + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protecteditems/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/README.md new file mode 100644 index 00000000000..53ba775f84d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/README.md @@ -0,0 +1,101 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers` Documentation + +The `protectioncontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers" +``` + + +### Client Initialization + +```go +client := protectioncontainers.NewProtectionContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionContainersClient.Get` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Inquire` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Inquire(ctx, id, protectioncontainers.DefaultInquireOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Refresh` + +```go +ctx := context.TODO() +id := protectioncontainers.NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue") + +read, err := client.Refresh(ctx, id, protectioncontainers.DefaultRefreshOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionContainersClient.Register` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +payload := protectioncontainers.ProtectionContainerResource{ + // ... +} + + +if err := client.RegisterThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProtectionContainersClient.Unregister` + +```go +ctx := context.TODO() +id := protectioncontainers.NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + +read, err := client.Unregister(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/client.go new file mode 100644 index 00000000000..a3766493d9d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/client.go @@ -0,0 +1,18 @@ +package protectioncontainers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectionContainersClientWithBaseURI(endpoint string) ProtectionContainersClient { + return ProtectionContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/constants.go new file mode 100644 index 00000000000..db706b5bd09 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/constants.go @@ -0,0 +1,330 @@ +package protectioncontainers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AcquireStorageAccountLock string + +const ( + AcquireStorageAccountLockAcquire AcquireStorageAccountLock = "Acquire" + AcquireStorageAccountLockNotAcquire AcquireStorageAccountLock = "NotAcquire" +) + +func PossibleValuesForAcquireStorageAccountLock() []string { + return []string{ + string(AcquireStorageAccountLockAcquire), + string(AcquireStorageAccountLockNotAcquire), + } +} + +func parseAcquireStorageAccountLock(input string) (*AcquireStorageAccountLock, error) { + vals := map[string]AcquireStorageAccountLock{ + "acquire": AcquireStorageAccountLockAcquire, + "notacquire": AcquireStorageAccountLockNotAcquire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AcquireStorageAccountLock(input) + return &out, nil +} + +type BackupItemType string + +const ( + BackupItemTypeAzureFileShare BackupItemType = "AzureFileShare" + BackupItemTypeAzureSqlDb BackupItemType = "AzureSqlDb" + BackupItemTypeClient BackupItemType = "Client" + BackupItemTypeExchange BackupItemType = "Exchange" + BackupItemTypeFileFolder BackupItemType = "FileFolder" + BackupItemTypeGenericDataSource BackupItemType = "GenericDataSource" + BackupItemTypeInvalid BackupItemType = "Invalid" + BackupItemTypeSAPAseDatabase BackupItemType = "SAPAseDatabase" + BackupItemTypeSAPHanaDBInstance BackupItemType = "SAPHanaDBInstance" + BackupItemTypeSAPHanaDatabase BackupItemType = "SAPHanaDatabase" + BackupItemTypeSQLDB BackupItemType = "SQLDB" + BackupItemTypeSQLDataBase BackupItemType = "SQLDataBase" + BackupItemTypeSharepoint BackupItemType = "Sharepoint" + BackupItemTypeSystemState BackupItemType = "SystemState" + BackupItemTypeVM BackupItemType = "VM" + BackupItemTypeVMwareVM BackupItemType = "VMwareVM" +) + +func PossibleValuesForBackupItemType() []string { + return []string{ + string(BackupItemTypeAzureFileShare), + string(BackupItemTypeAzureSqlDb), + string(BackupItemTypeClient), + string(BackupItemTypeExchange), + string(BackupItemTypeFileFolder), + string(BackupItemTypeGenericDataSource), + string(BackupItemTypeInvalid), + string(BackupItemTypeSAPAseDatabase), + string(BackupItemTypeSAPHanaDBInstance), + string(BackupItemTypeSAPHanaDatabase), + string(BackupItemTypeSQLDB), + string(BackupItemTypeSQLDataBase), + string(BackupItemTypeSharepoint), + string(BackupItemTypeSystemState), + string(BackupItemTypeVM), + string(BackupItemTypeVMwareVM), + } +} + +func parseBackupItemType(input string) (*BackupItemType, error) { + vals := map[string]BackupItemType{ + "azurefileshare": BackupItemTypeAzureFileShare, + "azuresqldb": BackupItemTypeAzureSqlDb, + "client": BackupItemTypeClient, + "exchange": BackupItemTypeExchange, + "filefolder": BackupItemTypeFileFolder, + "genericdatasource": BackupItemTypeGenericDataSource, + "invalid": BackupItemTypeInvalid, + "sapasedatabase": BackupItemTypeSAPAseDatabase, + "saphanadbinstance": BackupItemTypeSAPHanaDBInstance, + "saphanadatabase": BackupItemTypeSAPHanaDatabase, + "sqldb": BackupItemTypeSQLDB, + "sqldatabase": BackupItemTypeSQLDataBase, + "sharepoint": BackupItemTypeSharepoint, + "systemstate": BackupItemTypeSystemState, + "vm": BackupItemTypeVM, + "vmwarevm": BackupItemTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupItemType(input) + return &out, nil +} + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type OperationType string + +const ( + OperationTypeInvalid OperationType = "Invalid" + OperationTypeRegister OperationType = "Register" + OperationTypeReregister OperationType = "Reregister" +) + +func PossibleValuesForOperationType() []string { + return []string{ + string(OperationTypeInvalid), + string(OperationTypeRegister), + string(OperationTypeReregister), + } +} + +func parseOperationType(input string) (*OperationType, error) { + vals := map[string]OperationType{ + "invalid": OperationTypeInvalid, + "register": OperationTypeRegister, + "reregister": OperationTypeReregister, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationType(input) + return &out, nil +} + +type ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDBInstance), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric.go new file mode 100644 index 00000000000..8dc1cddbb0b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric.go @@ -0,0 +1,139 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupFabricId{}) +} + +var _ resourceids.ResourceId = &BackupFabricId{} + +// BackupFabricId is a struct representing the Resource ID for a Backup Fabric +type BackupFabricId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string +} + +// NewBackupFabricID returns a new BackupFabricId struct +func NewBackupFabricID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string) BackupFabricId { + return BackupFabricId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + } +} + +// ParseBackupFabricID parses 'input' into a BackupFabricId +func ParseBackupFabricID(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupFabricId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupFabricIDInsensitively parses 'input' case-insensitively into a BackupFabricId +// note: this method should only be used for API response data and not user input +func ParseBackupFabricIDInsensitively(input string) (*BackupFabricId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupFabricId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupFabricId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupFabricId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + return nil +} + +// ValidateBackupFabricID checks that 'input' can be parsed as a Backup Fabric ID +func ValidateBackupFabricID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupFabricID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Fabric ID +func (id BackupFabricId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Fabric ID +func (id BackupFabricId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + } +} + +// String returns a human-readable description of this Backup Fabric ID +func (id BackupFabricId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + } + return fmt.Sprintf("Backup Fabric (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric_test.go new file mode 100644 index 00000000000..37a949bab5f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_backupfabric_test.go @@ -0,0 +1,327 @@ +package protectioncontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupFabricId{} + +func TestNewBackupFabricID(t *testing.T) { + id := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } +} + +func TestFormatBackupFabricID(t *testing.T) { + actual := NewBackupFabricID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupFabricID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestParseBackupFabricIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupFabricId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Expected: &BackupFabricId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupFabricIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + } +} + +func TestSegmentsForBackupFabricId(t *testing.T) { + segments := BackupFabricId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupFabricId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer.go new file mode 100644 index 00000000000..b4f359ca4f1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer.go @@ -0,0 +1,148 @@ +package protectioncontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProtectionContainerId{}) +} + +var _ resourceids.ResourceId = &ProtectionContainerId{} + +// ProtectionContainerId is a struct representing the Resource ID for a Protection Container +type ProtectionContainerId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string +} + +// NewProtectionContainerID returns a new ProtectionContainerId struct +func NewProtectionContainerID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string) ProtectionContainerId { + return ProtectionContainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + } +} + +// ParseProtectionContainerID parses 'input' into a ProtectionContainerId +func ParseProtectionContainerID(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectionContainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProtectionContainerIDInsensitively parses 'input' case-insensitively into a ProtectionContainerId +// note: this method should only be used for API response data and not user input +func ParseProtectionContainerIDInsensitively(input string) (*ProtectionContainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectionContainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectionContainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectionContainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + return nil +} + +// ValidateProtectionContainerID checks that 'input' can be parsed as a Protection Container ID +func ValidateProtectionContainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectionContainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protection Container ID +func (id ProtectionContainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protection Container ID +func (id ProtectionContainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + } +} + +// String returns a human-readable description of this Protection Container ID +func (id ProtectionContainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + } + return fmt.Sprintf("Protection Container (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer_test.go new file mode 100644 index 00000000000..2e1ac683e43 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/id_protectioncontainer_test.go @@ -0,0 +1,372 @@ +package protectioncontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectionContainerId{} + +func TestNewProtectionContainerID(t *testing.T) { + id := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } +} + +func TestFormatProtectionContainerID(t *testing.T) { + actual := NewProtectionContainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectionContainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestParseProtectionContainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectionContainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Expected: &ProtectionContainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectionContainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + } +} + +func TestSegmentsForProtectionContainerId(t *testing.T) { + segments := ProtectionContainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectionContainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_get_autorest.go new file mode 100644 index 00000000000..07d4c710143 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_get_autorest.go @@ -0,0 +1,68 @@ +package protectioncontainers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionContainerResource +} + +// Get ... +func (c ProtectionContainersClient) Get(ctx context.Context, id ProtectionContainerId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectionContainersClient) preparerForGet(ctx context.Context, id ProtectionContainerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_inquire_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_inquire_autorest.go new file mode 100644 index 00000000000..fb85971bffd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_inquire_autorest.go @@ -0,0 +1,96 @@ +package protectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquireOperationResponse struct { + HttpResponse *http.Response +} + +type InquireOperationOptions struct { + Filter *string +} + +func DefaultInquireOperationOptions() InquireOperationOptions { + return InquireOperationOptions{} +} + +func (o InquireOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o InquireOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Inquire ... +func (c ProtectionContainersClient) Inquire(ctx context.Context, id ProtectionContainerId, options InquireOperationOptions) (result InquireOperationResponse, err error) { + req, err := c.preparerForInquire(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Inquire", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Inquire", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForInquire(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Inquire", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForInquire prepares the Inquire request. +func (c ProtectionContainersClient) preparerForInquire(ctx context.Context, id ProtectionContainerId, options InquireOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/inquire", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForInquire handles the response to the Inquire request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForInquire(resp *http.Response) (result InquireOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_refresh_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_refresh_autorest.go new file mode 100644 index 00000000000..2b4984af995 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_refresh_autorest.go @@ -0,0 +1,96 @@ +package protectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RefreshOperationResponse struct { + HttpResponse *http.Response +} + +type RefreshOperationOptions struct { + Filter *string +} + +func DefaultRefreshOperationOptions() RefreshOperationOptions { + return RefreshOperationOptions{} +} + +func (o RefreshOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o RefreshOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// Refresh ... +func (c ProtectionContainersClient) Refresh(ctx context.Context, id BackupFabricId, options RefreshOperationOptions) (result RefreshOperationResponse, err error) { + req, err := c.preparerForRefresh(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Refresh", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Refresh", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForRefresh(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Refresh", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForRefresh prepares the Refresh request. +func (c ProtectionContainersClient) preparerForRefresh(ctx context.Context, id BackupFabricId, options RefreshOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/refreshContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForRefresh handles the response to the Refresh request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForRefresh(resp *http.Response) (result RefreshOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_register_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_register_autorest.go new file mode 100644 index 00000000000..c1408bad011 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_register_autorest.go @@ -0,0 +1,80 @@ +package protectioncontainers + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisterOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response + Model *ProtectionContainerResource +} + +// Register ... +func (c ProtectionContainersClient) Register(ctx context.Context, id ProtectionContainerId, input ProtectionContainerResource) (result RegisterOperationResponse, err error) { + req, err := c.preparerForRegister(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Register", nil, "Failure preparing request") + return + } + + result, err = c.senderForRegister(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Register", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// RegisterThenPoll performs Register then polls until it's completed +func (c ProtectionContainersClient) RegisterThenPoll(ctx context.Context, id ProtectionContainerId, input ProtectionContainerResource) error { + result, err := c.Register(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Register: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Register: %+v", err) + } + + return nil +} + +// preparerForRegister prepares the Register request. +func (c ProtectionContainersClient) preparerForRegister(ctx context.Context, id ProtectionContainerId, input ProtectionContainerResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForRegister sends the Register request. The method will close the +// http.Response Body if it receives an error. +func (c ProtectionContainersClient) senderForRegister(ctx context.Context, req *http.Request) (future RegisterOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_unregister_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_unregister_autorest.go new file mode 100644 index 00000000000..cf4fbebe128 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/method_unregister_autorest.go @@ -0,0 +1,66 @@ +package protectioncontainers + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnregisterOperationResponse struct { + HttpResponse *http.Response +} + +// Unregister ... +func (c ProtectionContainersClient) Unregister(ctx context.Context, id ProtectionContainerId) (result UnregisterOperationResponse, err error) { + req, err := c.preparerForUnregister(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Unregister", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Unregister", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUnregister(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectioncontainers.ProtectionContainersClient", "Unregister", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUnregister prepares the Unregister request. +func (c ProtectionContainersClient) preparerForUnregister(ctx context.Context, id ProtectionContainerId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUnregister handles the response to the Unregister request. The method always +// closes the http.Response Body. +func (c ProtectionContainersClient) responderForUnregister(resp *http.Response) (result UnregisterOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..1c21d8906f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurebackupservercontainer.go @@ -0,0 +1,53 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureBackupServerContainer{} + +type AzureBackupServerContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerContainer{} + +func (s AzureBackupServerContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerContainer: %+v", err) + } + decoded["containerType"] = "AzureBackupServerContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..b8a8c17717e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSClassicComputeVMContainer{} + +type AzureIaaSClassicComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMContainer{} + +func (s AzureIaaSClassicComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..c66beff2ce0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSComputeVMContainer{} + +type AzureIaaSComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMContainer{} + +func (s AzureIaaSComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..7e0a1ed3e94 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSQLAGWorkloadContainerProtectionContainer{} + +type AzureSQLAGWorkloadContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSQLAGWorkloadContainerProtectionContainer{} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSQLAGWorkloadContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "SQLAGWorkLoadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..cd29b673055 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azuresqlcontainer.go @@ -0,0 +1,45 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSqlContainer{} + +type AzureSqlContainer struct { + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSqlContainer{} + +func (s AzureSqlContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlContainer: %+v", err) + } + decoded["containerType"] = "AzureSqlContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..fc4de5fe940 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurestoragecontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureStorageContainer{} + +type AzureStorageContainer struct { + AcquireStorageAccountLock *AcquireStorageAccountLock `json:"acquireStorageAccountLock,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageContainer{} + +func (s AzureStorageContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageContainer: %+v", err) + } + decoded["containerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..97d2dbf49f8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureVMAppContainerProtectionContainer{} + +type AzureVMAppContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectionContainer{} + +func (s AzureVMAppContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..79290339156 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainer.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureWorkloadContainer{} + +type AzureWorkloadContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainer{} + +func (s AzureWorkloadContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainer: %+v", err) + } + decoded["containerType"] = "AzureWorkloadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..3306d7014ef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_azureworkloadcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadContainerExtendedInfo struct { + HostServerName *string `json:"hostServerName,omitempty"` + InquiryInfo *InquiryInfo `json:"inquiryInfo,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..2a757b599d6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_containeridentityinfo.go @@ -0,0 +1,11 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerIdentityInfo struct { + AadTenantId *string `json:"aadTenantId,omitempty"` + Audience *string `json:"audience,omitempty"` + ServicePrincipalClientId *string `json:"servicePrincipalClientId,omitempty"` + UniqueName *string `json:"uniqueName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..a6ba705e4d5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..d35b9a9844d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainer.go @@ -0,0 +1,53 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = DpmContainer{} + +type DpmContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmContainer{} + +func (s DpmContainer) MarshalJSON() ([]byte, error) { + type wrapper DpmContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmContainer: %+v", err) + } + decoded["containerType"] = "DPMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..608a1ba48f9 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_dpmcontainerextendedinfo.go @@ -0,0 +1,26 @@ +package protectioncontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMContainerExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` +} + +func (o *DPMContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_errordetail.go new file mode 100644 index 00000000000..6eac856c404 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_errordetail.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainer.go new file mode 100644 index 00000000000..45b661347c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainer.go @@ -0,0 +1,47 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = GenericContainer{} + +type GenericContainer struct { + ExtendedInformation *GenericContainerExtendedInfo `json:"extendedInformation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = GenericContainer{} + +func (s GenericContainer) MarshalJSON() ([]byte, error) { + type wrapper GenericContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericContainer: %+v", err) + } + decoded["containerType"] = "GenericContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..6d1b2f49b6b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_genericcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenericContainerExtendedInfo struct { + ContainerIdentityInfo *ContainerIdentityInfo `json:"containerIdentityInfo,omitempty"` + RawCertData *string `json:"rawCertData,omitempty"` + ServiceEndpoints *map[string]string `json:"serviceEndpoints,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..e0a2bd35149 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_iaasvmcontainer.go @@ -0,0 +1,48 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = IaaSVMContainer{} + +type IaaSVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = IaaSVMContainer{} + +func (s IaaSVMContainer) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMContainer: %+v", err) + } + decoded["containerType"] = "IaasVMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..53bfc1db911 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryinfo.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + InquiryDetails *[]WorkloadInquiryDetails `json:"inquiryDetails,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..195ee612f4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_inquiryvalidation.go @@ -0,0 +1,11 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryValidation struct { + AdditionalDetail *string `json:"additionalDetail,omitempty"` + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + ProtectableItemCount *interface{} `json:"protectableItemCount,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainer.go new file mode 100644 index 00000000000..b2d5eb97307 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainer.go @@ -0,0 +1,52 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = MabContainer{} + +type MabContainer struct { + AgentVersion *string `json:"agentVersion,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerHealthState *string `json:"containerHealthState,omitempty"` + ContainerId *int64 `json:"containerId,omitempty"` + ExtendedInfo *MabContainerExtendedInfo `json:"extendedInfo,omitempty"` + MabContainerHealthDetails *[]MABContainerHealthDetails `json:"mabContainerHealthDetails,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = MabContainer{} + +func (s MabContainer) MarshalJSON() ([]byte, error) { + type wrapper MabContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabContainer: %+v", err) + } + decoded["containerType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..82aeca609c6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerextendedinfo.go @@ -0,0 +1,30 @@ +package protectioncontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabContainerExtendedInfo struct { + BackupItemType *BackupItemType `json:"backupItemType,omitempty"` + BackupItems *[]string `json:"backupItems,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + PolicyName *string `json:"policyName,omitempty"` +} + +func (o *MabContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..1bc3a807285 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_mabcontainerhealthdetails.go @@ -0,0 +1,11 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MABContainerHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..1ba03b16172 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainer.go @@ -0,0 +1,141 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainer interface { +} + +// RawProtectionContainerImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionContainerImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionContainerImplementation(input []byte) (ProtectionContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionContainer into map[string]interface: %+v", err) + } + + value, ok := temp["containerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerContainer") { + var out AzureBackupServerContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAGWorkLoadContainer") { + var out AzureSQLAGWorkloadContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSqlContainer") { + var out AzureSqlContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainer") { + var out AzureWorkloadContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMContainer") { + var out DpmContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericContainer") { + var out GenericContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMContainer") { + var out IaaSVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out MabContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabContainer: %+v", err) + } + return out, nil + } + + out := RawProtectionContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..4de75e08602 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_protectioncontainerresource.go @@ -0,0 +1,50 @@ +package protectioncontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionContainer `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerResource{} + +func (s *ProtectionContainerResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..1e9d1413743 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/model_workloadinquirydetails.go @@ -0,0 +1,10 @@ +package protectioncontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadInquiryDetails struct { + InquiryValidation *InquiryValidation `json:"inquiryValidation,omitempty"` + ItemCount *int64 `json:"itemCount,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/version.go new file mode 100644 index 00000000000..c114ff799f3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectioncontainers/version.go @@ -0,0 +1,12 @@ +package protectioncontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectioncontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/README.md new file mode 100644 index 00000000000..5e407187a06 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent` Documentation + +The `protectionintent` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent" +``` + + +### Client Initialization + +```go +client := protectionintent.NewProtectionIntentClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionIntentClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protectionintent.NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + +payload := protectionintent.ProtectionIntentResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionIntentClient.Delete` + +```go +ctx := context.TODO() +id := protectionintent.NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionIntentClient.Get` + +```go +ctx := context.TODO() +id := protectionintent.NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionIntentClient.Validate` + +```go +ctx := context.TODO() +id := protectionintent.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := protectionintent.PreValidateEnableBackupRequest{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/client.go new file mode 100644 index 00000000000..0ffe385d61d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/client.go @@ -0,0 +1,18 @@ +package protectionintent + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionIntentClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectionIntentClientWithBaseURI(endpoint string) ProtectionIntentClient { + return ProtectionIntentClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/constants.go new file mode 100644 index 00000000000..2d2e274187f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/constants.go @@ -0,0 +1,279 @@ +package protectionintent + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type DataSourceType string + +const ( + DataSourceTypeAzureFileShare DataSourceType = "AzureFileShare" + DataSourceTypeAzureSqlDb DataSourceType = "AzureSqlDb" + DataSourceTypeClient DataSourceType = "Client" + DataSourceTypeExchange DataSourceType = "Exchange" + DataSourceTypeFileFolder DataSourceType = "FileFolder" + DataSourceTypeGenericDataSource DataSourceType = "GenericDataSource" + DataSourceTypeInvalid DataSourceType = "Invalid" + DataSourceTypeSAPAseDatabase DataSourceType = "SAPAseDatabase" + DataSourceTypeSAPHanaDBInstance DataSourceType = "SAPHanaDBInstance" + DataSourceTypeSAPHanaDatabase DataSourceType = "SAPHanaDatabase" + DataSourceTypeSQLDB DataSourceType = "SQLDB" + DataSourceTypeSQLDataBase DataSourceType = "SQLDataBase" + DataSourceTypeSharepoint DataSourceType = "Sharepoint" + DataSourceTypeSystemState DataSourceType = "SystemState" + DataSourceTypeVM DataSourceType = "VM" + DataSourceTypeVMwareVM DataSourceType = "VMwareVM" +) + +func PossibleValuesForDataSourceType() []string { + return []string{ + string(DataSourceTypeAzureFileShare), + string(DataSourceTypeAzureSqlDb), + string(DataSourceTypeClient), + string(DataSourceTypeExchange), + string(DataSourceTypeFileFolder), + string(DataSourceTypeGenericDataSource), + string(DataSourceTypeInvalid), + string(DataSourceTypeSAPAseDatabase), + string(DataSourceTypeSAPHanaDBInstance), + string(DataSourceTypeSAPHanaDatabase), + string(DataSourceTypeSQLDB), + string(DataSourceTypeSQLDataBase), + string(DataSourceTypeSharepoint), + string(DataSourceTypeSystemState), + string(DataSourceTypeVM), + string(DataSourceTypeVMwareVM), + } +} + +func parseDataSourceType(input string) (*DataSourceType, error) { + vals := map[string]DataSourceType{ + "azurefileshare": DataSourceTypeAzureFileShare, + "azuresqldb": DataSourceTypeAzureSqlDb, + "client": DataSourceTypeClient, + "exchange": DataSourceTypeExchange, + "filefolder": DataSourceTypeFileFolder, + "genericdatasource": DataSourceTypeGenericDataSource, + "invalid": DataSourceTypeInvalid, + "sapasedatabase": DataSourceTypeSAPAseDatabase, + "saphanadbinstance": DataSourceTypeSAPHanaDBInstance, + "saphanadatabase": DataSourceTypeSAPHanaDatabase, + "sqldb": DataSourceTypeSQLDB, + "sqldatabase": DataSourceTypeSQLDataBase, + "sharepoint": DataSourceTypeSharepoint, + "systemstate": DataSourceTypeSystemState, + "vm": DataSourceTypeVM, + "vmwarevm": DataSourceTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataSourceType(input) + return &out, nil +} + +type ProtectionIntentItemType string + +const ( + ProtectionIntentItemTypeAzureResourceItem ProtectionIntentItemType = "AzureResourceItem" + ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadContainerAutoProtectionIntent" + ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent ProtectionIntentItemType = "AzureWorkloadSQLAutoProtectionIntent" + ProtectionIntentItemTypeInvalid ProtectionIntentItemType = "Invalid" + ProtectionIntentItemTypeRecoveryServiceVaultItem ProtectionIntentItemType = "RecoveryServiceVaultItem" +) + +func PossibleValuesForProtectionIntentItemType() []string { + return []string{ + string(ProtectionIntentItemTypeAzureResourceItem), + string(ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent), + string(ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent), + string(ProtectionIntentItemTypeInvalid), + string(ProtectionIntentItemTypeRecoveryServiceVaultItem), + } +} + +func parseProtectionIntentItemType(input string) (*ProtectionIntentItemType, error) { + vals := map[string]ProtectionIntentItemType{ + "azureresourceitem": ProtectionIntentItemTypeAzureResourceItem, + "azureworkloadautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadAutoProtectionIntent, + "azureworkloadcontainerautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadContainerAutoProtectionIntent, + "azureworkloadsqlautoprotectionintent": ProtectionIntentItemTypeAzureWorkloadSQLAutoProtectionIntent, + "invalid": ProtectionIntentItemTypeInvalid, + "recoveryservicevaultitem": ProtectionIntentItemTypeRecoveryServiceVaultItem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionIntentItemType(input) + return &out, nil +} + +type ProtectionStatus string + +const ( + ProtectionStatusInvalid ProtectionStatus = "Invalid" + ProtectionStatusNotProtected ProtectionStatus = "NotProtected" + ProtectionStatusProtected ProtectionStatus = "Protected" + ProtectionStatusProtecting ProtectionStatus = "Protecting" + ProtectionStatusProtectionFailed ProtectionStatus = "ProtectionFailed" +) + +func PossibleValuesForProtectionStatus() []string { + return []string{ + string(ProtectionStatusInvalid), + string(ProtectionStatusNotProtected), + string(ProtectionStatusProtected), + string(ProtectionStatusProtecting), + string(ProtectionStatusProtectionFailed), + } +} + +func parseProtectionStatus(input string) (*ProtectionStatus, error) { + vals := map[string]ProtectionStatus{ + "invalid": ProtectionStatusInvalid, + "notprotected": ProtectionStatusNotProtected, + "protected": ProtectionStatusProtected, + "protecting": ProtectionStatusProtecting, + "protectionfailed": ProtectionStatusProtectionFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectionStatus(input) + return &out, nil +} + +type ValidationStatus string + +const ( + ValidationStatusFailed ValidationStatus = "Failed" + ValidationStatusInvalid ValidationStatus = "Invalid" + ValidationStatusSucceeded ValidationStatus = "Succeeded" +) + +func PossibleValuesForValidationStatus() []string { + return []string{ + string(ValidationStatusFailed), + string(ValidationStatusInvalid), + string(ValidationStatusSucceeded), + } +} + +func parseValidationStatus(input string) (*ValidationStatus, error) { + vals := map[string]ValidationStatus{ + "failed": ValidationStatusFailed, + "invalid": ValidationStatusInvalid, + "succeeded": ValidationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationStatus(input) + return &out, nil +} + +type WorkloadItemType string + +const ( + WorkloadItemTypeInvalid WorkloadItemType = "Invalid" + WorkloadItemTypeSAPAseDatabase WorkloadItemType = "SAPAseDatabase" + WorkloadItemTypeSAPAseSystem WorkloadItemType = "SAPAseSystem" + WorkloadItemTypeSAPHanaDBInstance WorkloadItemType = "SAPHanaDBInstance" + WorkloadItemTypeSAPHanaDatabase WorkloadItemType = "SAPHanaDatabase" + WorkloadItemTypeSAPHanaSystem WorkloadItemType = "SAPHanaSystem" + WorkloadItemTypeSQLDataBase WorkloadItemType = "SQLDataBase" + WorkloadItemTypeSQLInstance WorkloadItemType = "SQLInstance" +) + +func PossibleValuesForWorkloadItemType() []string { + return []string{ + string(WorkloadItemTypeInvalid), + string(WorkloadItemTypeSAPAseDatabase), + string(WorkloadItemTypeSAPAseSystem), + string(WorkloadItemTypeSAPHanaDBInstance), + string(WorkloadItemTypeSAPHanaDatabase), + string(WorkloadItemTypeSAPHanaSystem), + string(WorkloadItemTypeSQLDataBase), + string(WorkloadItemTypeSQLInstance), + } +} + +func parseWorkloadItemType(input string) (*WorkloadItemType, error) { + vals := map[string]WorkloadItemType{ + "invalid": WorkloadItemTypeInvalid, + "sapasedatabase": WorkloadItemTypeSAPAseDatabase, + "sapasesystem": WorkloadItemTypeSAPAseSystem, + "saphanadbinstance": WorkloadItemTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadItemTypeSAPHanaDatabase, + "saphanasystem": WorkloadItemTypeSAPHanaSystem, + "sqldatabase": WorkloadItemTypeSQLDataBase, + "sqlinstance": WorkloadItemTypeSQLInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadItemType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent.go new file mode 100644 index 00000000000..d7831d6c089 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent.go @@ -0,0 +1,148 @@ +package protectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupProtectionIntentId{}) +} + +var _ resourceids.ResourceId = &BackupProtectionIntentId{} + +// BackupProtectionIntentId is a struct representing the Resource ID for a Backup Protection Intent +type BackupProtectionIntentId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + BackupProtectionIntentName string +} + +// NewBackupProtectionIntentID returns a new BackupProtectionIntentId struct +func NewBackupProtectionIntentID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, backupProtectionIntentName string) BackupProtectionIntentId { + return BackupProtectionIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + BackupProtectionIntentName: backupProtectionIntentName, + } +} + +// ParseBackupProtectionIntentID parses 'input' into a BackupProtectionIntentId +func ParseBackupProtectionIntentID(input string) (*BackupProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupProtectionIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupProtectionIntentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupProtectionIntentIDInsensitively parses 'input' case-insensitively into a BackupProtectionIntentId +// note: this method should only be used for API response data and not user input +func ParseBackupProtectionIntentIDInsensitively(input string) (*BackupProtectionIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupProtectionIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupProtectionIntentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupProtectionIntentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.BackupProtectionIntentName, ok = input.Parsed["backupProtectionIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupProtectionIntentName", input) + } + + return nil +} + +// ValidateBackupProtectionIntentID checks that 'input' can be parsed as a Backup Protection Intent ID +func ValidateBackupProtectionIntentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupProtectionIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Protection Intent ID +func (id BackupProtectionIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/backupProtectionIntent/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.BackupProtectionIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Protection Intent ID +func (id BackupProtectionIntentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticBackupProtectionIntent", "backupProtectionIntent", "backupProtectionIntent"), + resourceids.UserSpecifiedSegment("backupProtectionIntentName", "backupProtectionIntentValue"), + } +} + +// String returns a human-readable description of this Backup Protection Intent ID +func (id BackupProtectionIntentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Backup Protection Intent Name: %q", id.BackupProtectionIntentName), + } + return fmt.Sprintf("Backup Protection Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent_test.go new file mode 100644 index 00000000000..acc775f1aef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_backupprotectionintent_test.go @@ -0,0 +1,372 @@ +package protectionintent + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupProtectionIntentId{} + +func TestNewBackupProtectionIntentID(t *testing.T) { + id := NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "backupProtectionIntentValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.BackupProtectionIntentName != "backupProtectionIntentValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupProtectionIntentName'", id.BackupProtectionIntentName, "backupProtectionIntentValue") + } +} + +func TestFormatBackupProtectionIntentID(t *testing.T) { + actual := NewBackupProtectionIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "backupProtectionIntentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupProtectionIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + BackupProtectionIntentName: "backupProtectionIntentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupProtectionIntentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.BackupProtectionIntentName != v.Expected.BackupProtectionIntentName { + t.Fatalf("Expected %q but got %q for BackupProtectionIntentName", v.Expected.BackupProtectionIntentName, actual.BackupProtectionIntentName) + } + + } +} + +func TestParseBackupProtectionIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupProtectionIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/bAcKuPpRoTeCtIoNiNtEnT", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + BackupProtectionIntentName: "backupProtectionIntentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/backupProtectionIntent/backupProtectionIntentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/bAcKuPpRoTeCtIoNiNtEnT/bAcKuPpRoTeCtIoNiNtEnTvAlUe", + Expected: &BackupProtectionIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + BackupProtectionIntentName: "bAcKuPpRoTeCtIoNiNtEnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/bAcKuPpRoTeCtIoNiNtEnT/bAcKuPpRoTeCtIoNiNtEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupProtectionIntentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.BackupProtectionIntentName != v.Expected.BackupProtectionIntentName { + t.Fatalf("Expected %q but got %q for BackupProtectionIntentName", v.Expected.BackupProtectionIntentName, actual.BackupProtectionIntentName) + } + + } +} + +func TestSegmentsForBackupProtectionIntentId(t *testing.T) { + segments := BackupProtectionIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupProtectionIntentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location.go new file mode 100644 index 00000000000..2b562193f43 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location.go @@ -0,0 +1,121 @@ +package protectionintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.RecoveryServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location_test.go new file mode 100644 index 00000000000..76b7dbb1a81 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/id_location_test.go @@ -0,0 +1,237 @@ +package protectionintent + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.RecoveryServices/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_createorupdate_autorest.go new file mode 100644 index 00000000000..119b9b9a38a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_createorupdate_autorest.go @@ -0,0 +1,69 @@ +package protectionintent + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionIntentResource +} + +// CreateOrUpdate ... +func (c ProtectionIntentClient) CreateOrUpdate(ctx context.Context, id BackupProtectionIntentId, input ProtectionIntentResource) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectionIntentClient) preparerForCreateOrUpdate(ctx context.Context, id BackupProtectionIntentId, input ProtectionIntentResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ProtectionIntentClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_delete_autorest.go new file mode 100644 index 00000000000..2ed03771624 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_delete_autorest.go @@ -0,0 +1,66 @@ +package protectionintent + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c ProtectionIntentClient) Delete(ctx context.Context, id BackupProtectionIntentId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ProtectionIntentClient) preparerForDelete(ctx context.Context, id BackupProtectionIntentId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c ProtectionIntentClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_get_autorest.go new file mode 100644 index 00000000000..0875ecb9ece --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_get_autorest.go @@ -0,0 +1,68 @@ +package protectionintent + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionIntentResource +} + +// Get ... +func (c ProtectionIntentClient) Get(ctx context.Context, id BackupProtectionIntentId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectionIntentClient) preparerForGet(ctx context.Context, id BackupProtectionIntentId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ProtectionIntentClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_validate_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_validate_autorest.go new file mode 100644 index 00000000000..677f74de02b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/method_validate_autorest.go @@ -0,0 +1,70 @@ +package protectionintent + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + Model *PreValidateEnableBackupResponse +} + +// Validate ... +func (c ProtectionIntentClient) Validate(ctx context.Context, id LocationId, input PreValidateEnableBackupRequest) (result ValidateOperationResponse, err error) { + req, err := c.preparerForValidate(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Validate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Validate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForValidate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionintent.ProtectionIntentClient", "Validate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForValidate prepares the Validate request. +func (c ProtectionIntentClient) preparerForValidate(ctx context.Context, id LocationId, input PreValidateEnableBackupRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupPreValidateProtection", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForValidate handles the response to the Validate request. The method always +// closes the http.Response Body. +func (c ProtectionIntentClient) responderForValidate(resp *http.Response) (result ValidateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go new file mode 100644 index 00000000000..06a58c50499 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azurerecoveryservicevaultprotectionintent.go @@ -0,0 +1,45 @@ +package protectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureRecoveryServiceVaultProtectionIntent{} + +type AzureRecoveryServiceVaultProtectionIntent struct { + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureRecoveryServiceVaultProtectionIntent{} + +func (s AzureRecoveryServiceVaultProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureRecoveryServiceVaultProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "RecoveryServiceVaultItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureresourceprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureresourceprotectionintent.go new file mode 100644 index 00000000000..6a274d6f965 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureresourceprotectionintent.go @@ -0,0 +1,46 @@ +package protectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureResourceProtectionIntent{} + +type AzureResourceProtectionIntent struct { + FriendlyName *string `json:"friendlyName,omitempty"` + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureResourceProtectionIntent{} + +func (s AzureResourceProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureResourceProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureResourceProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureResourceProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureResourceItem" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureResourceProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadautoprotectionintent.go new file mode 100644 index 00000000000..c3bd647eb31 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadautoprotectionintent.go @@ -0,0 +1,45 @@ +package protectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureWorkloadAutoProtectionIntent{} + +type AzureWorkloadAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadAutoProtectionIntent{} + +func (s AzureWorkloadAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureWorkloadAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go new file mode 100644 index 00000000000..392bf620c14 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadcontainerautoprotectionintent.go @@ -0,0 +1,45 @@ +package protectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureWorkloadContainerAutoProtectionIntent{} + +type AzureWorkloadContainerAutoProtectionIntent struct { + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainerAutoProtectionIntent{} + +func (s AzureWorkloadContainerAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainerAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureWorkloadContainerAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go new file mode 100644 index 00000000000..c794a5ef4db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_azureworkloadsqlautoprotectionintent.go @@ -0,0 +1,46 @@ +package protectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionIntent = AzureWorkloadSQLAutoProtectionIntent{} + +type AzureWorkloadSQLAutoProtectionIntent struct { + WorkloadItemType *WorkloadItemType `json:"workloadItemType,omitempty"` + + // Fields inherited from ProtectionIntent + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + ItemId *string `json:"itemId,omitempty"` + PolicyId *string `json:"policyId,omitempty"` + ProtectionState *ProtectionStatus `json:"protectionState,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLAutoProtectionIntent{} + +func (s AzureWorkloadSQLAutoProtectionIntent) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLAutoProtectionIntent + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + decoded["protectionIntentItemType"] = "AzureWorkloadSQLAutoProtectionIntent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackuprequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackuprequest.go new file mode 100644 index 00000000000..58ac0096b74 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackuprequest.go @@ -0,0 +1,11 @@ +package protectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreValidateEnableBackupRequest struct { + Properties *string `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceType *DataSourceType `json:"resourceType,omitempty"` + VaultId *string `json:"vaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackupresponse.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackupresponse.go new file mode 100644 index 00000000000..456761b757d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_prevalidateenablebackupresponse.go @@ -0,0 +1,13 @@ +package protectionintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreValidateEnableBackupResponse struct { + ContainerName *string `json:"containerName,omitempty"` + ErrorCode *string `json:"errorCode,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + ProtectedItemName *string `json:"protectedItemName,omitempty"` + Recommendation *string `json:"recommendation,omitempty"` + Status *ValidationStatus `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintent.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintent.go new file mode 100644 index 00000000000..a7fa1d6491f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintent.go @@ -0,0 +1,85 @@ +package protectionintent + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionIntent interface { +} + +// RawProtectionIntentImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionIntentImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionIntentImplementation(input []byte) (ProtectionIntent, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionIntent into map[string]interface: %+v", err) + } + + value, ok := temp["protectionIntentItemType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "RecoveryServiceVaultItem") { + var out AzureRecoveryServiceVaultProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureRecoveryServiceVaultProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureResourceItem") { + var out AzureResourceProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureResourceProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadAutoProtectionIntent") { + var out AzureWorkloadAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainerAutoProtectionIntent") { + var out AzureWorkloadContainerAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainerAutoProtectionIntent: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLAutoProtectionIntent") { + var out AzureWorkloadSQLAutoProtectionIntent + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLAutoProtectionIntent: %+v", err) + } + return out, nil + } + + out := RawProtectionIntentImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintentresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintentresource.go new file mode 100644 index 00000000000..bff822af9f5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/model_protectionintentresource.go @@ -0,0 +1,50 @@ +package protectionintent + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionIntentResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionIntent `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionIntentResource{} + +func (s *ProtectionIntentResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionIntentResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionIntentResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionIntentResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionIntentImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionIntentResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/version.go new file mode 100644 index 00000000000..548d8c97f0a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionintent/version.go @@ -0,0 +1,12 @@ +package protectionintent + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectionintent/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/README.md new file mode 100644 index 00000000000..6602d267f38 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies` Documentation + +The `protectionpolicies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies" +``` + + +### Client Initialization + +```go +client := protectionpolicies.NewProtectionPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProtectionPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +payload := protectionpolicies.ProtectionPolicyResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, protectionpolicies.DefaultCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProtectionPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ProtectionPoliciesClient.Get` + +```go +ctx := context.TODO() +id := protectionpolicies.NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/client.go new file mode 100644 index 00000000000..af96d5ee4b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/client.go @@ -0,0 +1,18 @@ +package protectionpolicies + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPoliciesClient struct { + Client autorest.Client + baseUri string +} + +func NewProtectionPoliciesClientWithBaseURI(endpoint string) ProtectionPoliciesClient { + return ProtectionPoliciesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/constants.go new file mode 100644 index 00000000000..0b1721c13dc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/constants.go @@ -0,0 +1,458 @@ +package protectionpolicies + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type IAASVMPolicyType string + +const ( + IAASVMPolicyTypeInvalid IAASVMPolicyType = "Invalid" + IAASVMPolicyTypeVOne IAASVMPolicyType = "V1" + IAASVMPolicyTypeVTwo IAASVMPolicyType = "V2" +) + +func PossibleValuesForIAASVMPolicyType() []string { + return []string{ + string(IAASVMPolicyTypeInvalid), + string(IAASVMPolicyTypeVOne), + string(IAASVMPolicyTypeVTwo), + } +} + +func parseIAASVMPolicyType(input string) (*IAASVMPolicyType, error) { + vals := map[string]IAASVMPolicyType{ + "invalid": IAASVMPolicyTypeInvalid, + "v1": IAASVMPolicyTypeVOne, + "v2": IAASVMPolicyTypeVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IAASVMPolicyType(input) + return &out, nil +} + +type IaasVMSnapshotConsistencyType string + +const ( + IaasVMSnapshotConsistencyTypeOnlyCrashConsistent IaasVMSnapshotConsistencyType = "OnlyCrashConsistent" +) + +func PossibleValuesForIaasVMSnapshotConsistencyType() []string { + return []string{ + string(IaasVMSnapshotConsistencyTypeOnlyCrashConsistent), + } +} + +func parseIaasVMSnapshotConsistencyType(input string) (*IaasVMSnapshotConsistencyType, error) { + vals := map[string]IaasVMSnapshotConsistencyType{ + "onlycrashconsistent": IaasVMSnapshotConsistencyTypeOnlyCrashConsistent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IaasVMSnapshotConsistencyType(input) + return &out, nil +} + +type MonthOfYear string + +const ( + MonthOfYearApril MonthOfYear = "April" + MonthOfYearAugust MonthOfYear = "August" + MonthOfYearDecember MonthOfYear = "December" + MonthOfYearFebruary MonthOfYear = "February" + MonthOfYearInvalid MonthOfYear = "Invalid" + MonthOfYearJanuary MonthOfYear = "January" + MonthOfYearJuly MonthOfYear = "July" + MonthOfYearJune MonthOfYear = "June" + MonthOfYearMarch MonthOfYear = "March" + MonthOfYearMay MonthOfYear = "May" + MonthOfYearNovember MonthOfYear = "November" + MonthOfYearOctober MonthOfYear = "October" + MonthOfYearSeptember MonthOfYear = "September" +) + +func PossibleValuesForMonthOfYear() []string { + return []string{ + string(MonthOfYearApril), + string(MonthOfYearAugust), + string(MonthOfYearDecember), + string(MonthOfYearFebruary), + string(MonthOfYearInvalid), + string(MonthOfYearJanuary), + string(MonthOfYearJuly), + string(MonthOfYearJune), + string(MonthOfYearMarch), + string(MonthOfYearMay), + string(MonthOfYearNovember), + string(MonthOfYearOctober), + string(MonthOfYearSeptember), + } +} + +func parseMonthOfYear(input string) (*MonthOfYear, error) { + vals := map[string]MonthOfYear{ + "april": MonthOfYearApril, + "august": MonthOfYearAugust, + "december": MonthOfYearDecember, + "february": MonthOfYearFebruary, + "invalid": MonthOfYearInvalid, + "january": MonthOfYearJanuary, + "july": MonthOfYearJuly, + "june": MonthOfYearJune, + "march": MonthOfYearMarch, + "may": MonthOfYearMay, + "november": MonthOfYearNovember, + "october": MonthOfYearOctober, + "september": MonthOfYearSeptember, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonthOfYear(input) + return &out, nil +} + +type PolicyType string + +const ( + PolicyTypeCopyOnlyFull PolicyType = "CopyOnlyFull" + PolicyTypeDifferential PolicyType = "Differential" + PolicyTypeFull PolicyType = "Full" + PolicyTypeIncremental PolicyType = "Incremental" + PolicyTypeInvalid PolicyType = "Invalid" + PolicyTypeLog PolicyType = "Log" + PolicyTypeSnapshotCopyOnlyFull PolicyType = "SnapshotCopyOnlyFull" + PolicyTypeSnapshotFull PolicyType = "SnapshotFull" +) + +func PossibleValuesForPolicyType() []string { + return []string{ + string(PolicyTypeCopyOnlyFull), + string(PolicyTypeDifferential), + string(PolicyTypeFull), + string(PolicyTypeIncremental), + string(PolicyTypeInvalid), + string(PolicyTypeLog), + string(PolicyTypeSnapshotCopyOnlyFull), + string(PolicyTypeSnapshotFull), + } +} + +func parsePolicyType(input string) (*PolicyType, error) { + vals := map[string]PolicyType{ + "copyonlyfull": PolicyTypeCopyOnlyFull, + "differential": PolicyTypeDifferential, + "full": PolicyTypeFull, + "incremental": PolicyTypeIncremental, + "invalid": PolicyTypeInvalid, + "log": PolicyTypeLog, + "snapshotcopyonlyfull": PolicyTypeSnapshotCopyOnlyFull, + "snapshotfull": PolicyTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PolicyType(input) + return &out, nil +} + +type RetentionDurationType string + +const ( + RetentionDurationTypeDays RetentionDurationType = "Days" + RetentionDurationTypeInvalid RetentionDurationType = "Invalid" + RetentionDurationTypeMonths RetentionDurationType = "Months" + RetentionDurationTypeWeeks RetentionDurationType = "Weeks" + RetentionDurationTypeYears RetentionDurationType = "Years" +) + +func PossibleValuesForRetentionDurationType() []string { + return []string{ + string(RetentionDurationTypeDays), + string(RetentionDurationTypeInvalid), + string(RetentionDurationTypeMonths), + string(RetentionDurationTypeWeeks), + string(RetentionDurationTypeYears), + } +} + +func parseRetentionDurationType(input string) (*RetentionDurationType, error) { + vals := map[string]RetentionDurationType{ + "days": RetentionDurationTypeDays, + "invalid": RetentionDurationTypeInvalid, + "months": RetentionDurationTypeMonths, + "weeks": RetentionDurationTypeWeeks, + "years": RetentionDurationTypeYears, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RetentionDurationType(input) + return &out, nil +} + +type RetentionScheduleFormat string + +const ( + RetentionScheduleFormatDaily RetentionScheduleFormat = "Daily" + RetentionScheduleFormatInvalid RetentionScheduleFormat = "Invalid" + RetentionScheduleFormatWeekly RetentionScheduleFormat = "Weekly" +) + +func PossibleValuesForRetentionScheduleFormat() []string { + return []string{ + string(RetentionScheduleFormatDaily), + string(RetentionScheduleFormatInvalid), + string(RetentionScheduleFormatWeekly), + } +} + +func parseRetentionScheduleFormat(input string) (*RetentionScheduleFormat, error) { + vals := map[string]RetentionScheduleFormat{ + "daily": RetentionScheduleFormatDaily, + "invalid": RetentionScheduleFormatInvalid, + "weekly": RetentionScheduleFormatWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RetentionScheduleFormat(input) + return &out, nil +} + +type ScheduleRunType string + +const ( + ScheduleRunTypeDaily ScheduleRunType = "Daily" + ScheduleRunTypeHourly ScheduleRunType = "Hourly" + ScheduleRunTypeInvalid ScheduleRunType = "Invalid" + ScheduleRunTypeWeekly ScheduleRunType = "Weekly" +) + +func PossibleValuesForScheduleRunType() []string { + return []string{ + string(ScheduleRunTypeDaily), + string(ScheduleRunTypeHourly), + string(ScheduleRunTypeInvalid), + string(ScheduleRunTypeWeekly), + } +} + +func parseScheduleRunType(input string) (*ScheduleRunType, error) { + vals := map[string]ScheduleRunType{ + "daily": ScheduleRunTypeDaily, + "hourly": ScheduleRunTypeHourly, + "invalid": ScheduleRunTypeInvalid, + "weekly": ScheduleRunTypeWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleRunType(input) + return &out, nil +} + +type TieringMode string + +const ( + TieringModeDoNotTier TieringMode = "DoNotTier" + TieringModeInvalid TieringMode = "Invalid" + TieringModeTierAfter TieringMode = "TierAfter" + TieringModeTierRecommended TieringMode = "TierRecommended" +) + +func PossibleValuesForTieringMode() []string { + return []string{ + string(TieringModeDoNotTier), + string(TieringModeInvalid), + string(TieringModeTierAfter), + string(TieringModeTierRecommended), + } +} + +func parseTieringMode(input string) (*TieringMode, error) { + vals := map[string]TieringMode{ + "donottier": TieringModeDoNotTier, + "invalid": TieringModeInvalid, + "tierafter": TieringModeTierAfter, + "tierrecommended": TieringModeTierRecommended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TieringMode(input) + return &out, nil +} + +type WeekOfMonth string + +const ( + WeekOfMonthFirst WeekOfMonth = "First" + WeekOfMonthFourth WeekOfMonth = "Fourth" + WeekOfMonthInvalid WeekOfMonth = "Invalid" + WeekOfMonthLast WeekOfMonth = "Last" + WeekOfMonthSecond WeekOfMonth = "Second" + WeekOfMonthThird WeekOfMonth = "Third" +) + +func PossibleValuesForWeekOfMonth() []string { + return []string{ + string(WeekOfMonthFirst), + string(WeekOfMonthFourth), + string(WeekOfMonthInvalid), + string(WeekOfMonthLast), + string(WeekOfMonthSecond), + string(WeekOfMonthThird), + } +} + +func parseWeekOfMonth(input string) (*WeekOfMonth, error) { + vals := map[string]WeekOfMonth{ + "first": WeekOfMonthFirst, + "fourth": WeekOfMonthFourth, + "invalid": WeekOfMonthInvalid, + "last": WeekOfMonthLast, + "second": WeekOfMonthSecond, + "third": WeekOfMonthThird, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WeekOfMonth(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDBInstance), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy.go new file mode 100644 index 00000000000..5a01b232288 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy.go @@ -0,0 +1,139 @@ +package protectionpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupPolicyId{}) +} + +var _ resourceids.ResourceId = &BackupPolicyId{} + +// BackupPolicyId is a struct representing the Resource ID for a Backup Policy +type BackupPolicyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupPolicyName string +} + +// NewBackupPolicyID returns a new BackupPolicyId struct +func NewBackupPolicyID(subscriptionId string, resourceGroupName string, vaultName string, backupPolicyName string) BackupPolicyId { + return BackupPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupPolicyName: backupPolicyName, + } +} + +// ParseBackupPolicyID parses 'input' into a BackupPolicyId +func ParseBackupPolicyID(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupPolicyIDInsensitively parses 'input' case-insensitively into a BackupPolicyId +// note: this method should only be used for API response data and not user input +func ParseBackupPolicyIDInsensitively(input string) (*BackupPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupPolicyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupPolicyName, ok = input.Parsed["backupPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupPolicyName", input) + } + + return nil +} + +// ValidateBackupPolicyID checks that 'input' can be parsed as a Backup Policy ID +func ValidateBackupPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Policy ID +func (id BackupPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Policy ID +func (id BackupPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupPolicies", "backupPolicies", "backupPolicies"), + resourceids.UserSpecifiedSegment("backupPolicyName", "backupPolicyValue"), + } +} + +// String returns a human-readable description of this Backup Policy ID +func (id BackupPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Policy Name: %q", id.BackupPolicyName), + } + return fmt.Sprintf("Backup Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy_test.go new file mode 100644 index 00000000000..208670abbef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/id_backuppolicy_test.go @@ -0,0 +1,327 @@ +package protectionpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupPolicyId{} + +func TestNewBackupPolicyID(t *testing.T) { + id := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupPolicyName != "backupPolicyValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupPolicyName'", id.BackupPolicyName, "backupPolicyValue") + } +} + +func TestFormatBackupPolicyID(t *testing.T) { + actual := NewBackupPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupPolicyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupPolicyName: "backupPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestParseBackupPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupPolicyName: "backupPolicyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupPolicies/backupPolicyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPpOlIcIeS/bAcKuPpOlIcYvAlUe", + Expected: &BackupPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupPolicyName: "bAcKuPpOlIcYvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPpOlIcIeS/bAcKuPpOlIcYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupPolicyName != v.Expected.BackupPolicyName { + t.Fatalf("Expected %q but got %q for BackupPolicyName", v.Expected.BackupPolicyName, actual.BackupPolicyName) + } + + } +} + +func TestSegmentsForBackupPolicyId(t *testing.T) { + segments := BackupPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_createorupdate_autorest.go new file mode 100644 index 00000000000..24443b25235 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_createorupdate_autorest.go @@ -0,0 +1,98 @@ +package protectionpolicies + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionPolicyResource +} + +type CreateOrUpdateOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o CreateOrUpdateOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// CreateOrUpdate ... +func (c ProtectionPoliciesClient) CreateOrUpdate(ctx context.Context, id BackupPolicyId, input ProtectionPolicyResource, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + req, err := c.preparerForCreateOrUpdate(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForCreateOrUpdate(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForCreateOrUpdate prepares the CreateOrUpdate request. +func (c ProtectionPoliciesClient) preparerForCreateOrUpdate(ctx context.Context, id BackupPolicyId, input ProtectionPolicyResource, options CreateOrUpdateOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (c ProtectionPoliciesClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_delete_autorest.go new file mode 100644 index 00000000000..d8310df327c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_delete_autorest.go @@ -0,0 +1,78 @@ +package protectionpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Delete ... +func (c ProtectionPoliciesClient) Delete(ctx context.Context, id BackupPolicyId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = c.senderForDelete(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ProtectionPoliciesClient) DeleteThenPoll(ctx context.Context, id BackupPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} + +// preparerForDelete prepares the Delete request. +func (c ProtectionPoliciesClient) preparerForDelete(ctx context.Context, id BackupPolicyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c ProtectionPoliciesClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_get_autorest.go new file mode 100644 index 00000000000..bd3aabebfe7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/method_get_autorest.go @@ -0,0 +1,68 @@ +package protectionpolicies + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ProtectionPolicyResource +} + +// Get ... +func (c ProtectionPoliciesClient) Get(ctx context.Context, id BackupPolicyId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "protectionpolicies.ProtectionPoliciesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ProtectionPoliciesClient) preparerForGet(ctx context.Context, id BackupPolicyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ProtectionPoliciesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurefileshareprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurefileshareprotectionpolicy.go new file mode 100644 index 00000000000..90fb6638062 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurefileshareprotectionpolicy.go @@ -0,0 +1,85 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureFileShareProtectionPolicy{} + +type AzureFileShareProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + TimeZone *string `json:"timeZone,omitempty"` + VaultRetentionPolicy *VaultRetentionPolicy `json:"vaultRetentionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareProtectionPolicy{} + +func (s AzureFileShareProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureStorage" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureFileShareProtectionPolicy{} + +func (s *AzureFileShareProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureFileShareProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.TimeZone = decoded.TimeZone + s.VaultRetentionPolicy = decoded.VaultRetentionPolicy + s.WorkLoadType = decoded.WorkLoadType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureFileShareProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureFileShareProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go new file mode 100644 index 00000000000..cec013785db --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azureiaasvmprotectionpolicy.go @@ -0,0 +1,91 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureIaaSVMProtectionPolicy{} + +type AzureIaaSVMProtectionPolicy struct { + InstantRPDetails *InstantRPAdditionalDetails `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + PolicyType *IAASVMPolicyType `json:"policyType,omitempty"` + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + SnapshotConsistencyType *IaasVMSnapshotConsistencyType `json:"snapshotConsistencyType,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureIaaSVMProtectionPolicy{} + +func (s AzureIaaSVMProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSVMProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureIaasVM" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSVMProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureIaaSVMProtectionPolicy{} + +func (s *AzureIaaSVMProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureIaaSVMProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + + s.InstantRPDetails = decoded.InstantRPDetails + s.InstantRpRetentionRangeInDays = decoded.InstantRpRetentionRangeInDays + s.PolicyType = decoded.PolicyType + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + s.SnapshotConsistencyType = decoded.SnapshotConsistencyType + s.TieringPolicy = decoded.TieringPolicy + s.TimeZone = decoded.TimeZone + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureIaaSVMProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'AzureIaaSVMProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azuresqlprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azuresqlprotectionpolicy.go new file mode 100644 index 00000000000..5a691310aaf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azuresqlprotectionpolicy.go @@ -0,0 +1,70 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureSqlProtectionPolicy{} + +type AzureSqlProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureSqlProtectionPolicy{} + +func (s AzureSqlProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureSql" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureSqlProtectionPolicy{} + +func (s *AzureSqlProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias AzureSqlProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureSqlProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'AzureSqlProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go new file mode 100644 index 00000000000..4ad1179dc7c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_azurevmworkloadprotectionpolicy.go @@ -0,0 +1,46 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = AzureVMWorkloadProtectionPolicy{} + +type AzureVMWorkloadProtectionPolicy struct { + MakePolicyConsistent *bool `json:"makePolicyConsistent,omitempty"` + Settings *Settings `json:"settings,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + WorkLoadType *WorkloadType `json:"workLoadType,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureVMWorkloadProtectionPolicy{} + +func (s AzureVMWorkloadProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper AzureVMWorkloadProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "AzureWorkload" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMWorkloadProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionformat.go new file mode 100644 index 00000000000..f2f8a9c3693 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionformat.go @@ -0,0 +1,8 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailyRetentionFormat struct { + DaysOfTheMonth *[]Day `json:"daysOfTheMonth,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionschedule.go new file mode 100644 index 00000000000..40dc38fbcda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyretentionschedule.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailyRetentionSchedule struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyschedule.go new file mode 100644 index 00000000000..88826749b25 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_dailyschedule.go @@ -0,0 +1,8 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailySchedule struct { + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_day.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_day.go new file mode 100644 index 00000000000..ca922f3cfe2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_day.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Day struct { + Date *int64 `json:"date,omitempty"` + IsLast *bool `json:"isLast,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_genericprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_genericprotectionpolicy.go new file mode 100644 index 00000000000..c893e4e8051 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_genericprotectionpolicy.go @@ -0,0 +1,45 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = GenericProtectionPolicy{} + +type GenericProtectionPolicy struct { + FabricName *string `json:"fabricName,omitempty"` + SubProtectionPolicy *[]SubProtectionPolicy `json:"subProtectionPolicy,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = GenericProtectionPolicy{} + +func (s GenericProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper GenericProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "GenericProtectionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericProtectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_hourlyschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_hourlyschedule.go new file mode 100644 index 00000000000..8e573c02a5c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_hourlyschedule.go @@ -0,0 +1,28 @@ +package protectionpolicies + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HourlySchedule struct { + Interval *int64 `json:"interval,omitempty"` + ScheduleWindowDuration *int64 `json:"scheduleWindowDuration,omitempty"` + ScheduleWindowStartTime *string `json:"scheduleWindowStartTime,omitempty"` +} + +func (o *HourlySchedule) GetScheduleWindowStartTimeAsTime() (*time.Time, error) { + if o.ScheduleWindowStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduleWindowStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *HourlySchedule) SetScheduleWindowStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduleWindowStartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_instantrpadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_instantrpadditionaldetails.go new file mode 100644 index 00000000000..ea9cd7a24da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_instantrpadditionaldetails.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstantRPAdditionalDetails struct { + AzureBackupRGNamePrefix *string `json:"azureBackupRGNamePrefix,omitempty"` + AzureBackupRGNameSuffix *string `json:"azureBackupRGNameSuffix,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_logschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_logschedulepolicy.go new file mode 100644 index 00000000000..8f2cae11901 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_logschedulepolicy.go @@ -0,0 +1,41 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LogSchedulePolicy{} + +type LogSchedulePolicy struct { + ScheduleFrequencyInMins *int64 `json:"scheduleFrequencyInMins,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LogSchedulePolicy{} + +func (s LogSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LogSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LogSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LogSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LogSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LogSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermretentionpolicy.go new file mode 100644 index 00000000000..50f80900d4e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermretentionpolicy.go @@ -0,0 +1,44 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = LongTermRetentionPolicy{} + +type LongTermRetentionPolicy struct { + DailySchedule *DailyRetentionSchedule `json:"dailySchedule,omitempty"` + MonthlySchedule *MonthlyRetentionSchedule `json:"monthlySchedule,omitempty"` + WeeklySchedule *WeeklyRetentionSchedule `json:"weeklySchedule,omitempty"` + YearlySchedule *YearlyRetentionSchedule `json:"yearlySchedule,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = LongTermRetentionPolicy{} + +func (s LongTermRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "LongTermRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermschedulepolicy.go new file mode 100644 index 00000000000..06d19a60ab2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_longtermschedulepolicy.go @@ -0,0 +1,40 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = LongTermSchedulePolicy{} + +type LongTermSchedulePolicy struct { + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = LongTermSchedulePolicy{} + +func (s LongTermSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper LongTermSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LongTermSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LongTermSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "LongTermSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LongTermSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_mabprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_mabprotectionpolicy.go new file mode 100644 index 00000000000..4178653c4e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_mabprotectionpolicy.go @@ -0,0 +1,79 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionPolicy = MabProtectionPolicy{} + +type MabProtectionPolicy struct { + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + + // Fields inherited from ProtectionPolicy + ProtectedItemsCount *int64 `json:"protectedItemsCount,omitempty"` + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = MabProtectionPolicy{} + +func (s MabProtectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper MabProtectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabProtectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabProtectionPolicy: %+v", err) + } + decoded["backupManagementType"] = "MAB" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabProtectionPolicy: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &MabProtectionPolicy{} + +func (s *MabProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias MabProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + + s.ProtectedItemsCount = decoded.ProtectedItemsCount + s.ResourceGuardOperationRequests = decoded.ResourceGuardOperationRequests + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MabProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'MabProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'MabProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_monthlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_monthlyretentionschedule.go new file mode 100644 index 00000000000..4ceda36d875 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_monthlyretentionschedule.go @@ -0,0 +1,12 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonthlyRetentionSchedule struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionScheduleDaily *DailyRetentionFormat `json:"retentionScheduleDaily,omitempty"` + RetentionScheduleFormatType *RetentionScheduleFormat `json:"retentionScheduleFormatType,omitempty"` + RetentionScheduleWeekly *WeeklyRetentionFormat `json:"retentionScheduleWeekly,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicy.go new file mode 100644 index 00000000000..7d850fa25bd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicy.go @@ -0,0 +1,93 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicy interface { +} + +// RawProtectionPolicyImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionPolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionPolicyImplementation(input []byte) (ProtectionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["backupManagementType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureStorage") { + var out AzureFileShareProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureIaasVM") { + var out AzureIaaSVMProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSVMProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSql") { + var out AzureSqlProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkload") { + var out AzureVMWorkloadProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMWorkloadProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericProtectionPolicy") { + var out GenericProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericProtectionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MAB") { + var out MabProtectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabProtectionPolicy: %+v", err) + } + return out, nil + } + + out := RawProtectionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicyresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicyresource.go new file mode 100644 index 00000000000..03bda4d0a12 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_protectionpolicyresource.go @@ -0,0 +1,50 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionPolicyResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionPolicy `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionPolicyResource{} + +func (s *ProtectionPolicyResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionPolicyResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionPolicyResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionPolicyResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionPolicyResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionduration.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionduration.go new file mode 100644 index 00000000000..4b77b5e2f23 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionduration.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionDuration struct { + Count *int64 `json:"count,omitempty"` + DurationType *RetentionDurationType `json:"durationType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionpolicy.go new file mode 100644 index 00000000000..fa52632f677 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_retentionpolicy.go @@ -0,0 +1,61 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicy interface { +} + +// RawRetentionPolicyImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRetentionPolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRetentionPolicyImplementation(input []byte) (RetentionPolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RetentionPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["retentionPolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LongTermRetentionPolicy") { + var out LongTermRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermRetentionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleRetentionPolicy") { + var out SimpleRetentionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleRetentionPolicy: %+v", err) + } + return out, nil + } + + out := RawRetentionPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_schedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_schedulepolicy.go new file mode 100644 index 00000000000..6f395ac7fc7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_schedulepolicy.go @@ -0,0 +1,77 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SchedulePolicy interface { +} + +// RawSchedulePolicyImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawSchedulePolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalSchedulePolicyImplementation(input []byte) (SchedulePolicy, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling SchedulePolicy into map[string]interface: %+v", err) + } + + value, ok := temp["schedulePolicyType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "LogSchedulePolicy") { + var out LogSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LogSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "LongTermSchedulePolicy") { + var out LongTermSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LongTermSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicy") { + var out SimpleSchedulePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SimpleSchedulePolicyV2") { + var out SimpleSchedulePolicyV2 + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SimpleSchedulePolicyV2: %+v", err) + } + return out, nil + } + + out := RawSchedulePolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_settings.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_settings.go new file mode 100644 index 00000000000..585e96708fc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_settings.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Settings struct { + IsCompression *bool `json:"isCompression,omitempty"` + Issqlcompression *bool `json:"issqlcompression,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleretentionpolicy.go new file mode 100644 index 00000000000..37edb09a956 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleretentionpolicy.go @@ -0,0 +1,41 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RetentionPolicy = SimpleRetentionPolicy{} + +type SimpleRetentionPolicy struct { + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + + // Fields inherited from RetentionPolicy +} + +var _ json.Marshaler = SimpleRetentionPolicy{} + +func (s SimpleRetentionPolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleRetentionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleRetentionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleRetentionPolicy: %+v", err) + } + decoded["retentionPolicyType"] = "SimpleRetentionPolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleRetentionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicy.go new file mode 100644 index 00000000000..117247120b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicy.go @@ -0,0 +1,45 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicy{} + +type SimpleSchedulePolicy struct { + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunDays *[]DayOfWeek `json:"scheduleRunDays,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` + ScheduleWeeklyFrequency *int64 `json:"scheduleWeeklyFrequency,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicy{} + +func (s SimpleSchedulePolicy) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicy: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicy" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicyv2.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicyv2.go new file mode 100644 index 00000000000..f522d8d7184 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_simpleschedulepolicyv2.go @@ -0,0 +1,44 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SchedulePolicy = SimpleSchedulePolicyV2{} + +type SimpleSchedulePolicyV2 struct { + DailySchedule *DailySchedule `json:"dailySchedule,omitempty"` + HourlySchedule *HourlySchedule `json:"hourlySchedule,omitempty"` + ScheduleRunFrequency *ScheduleRunType `json:"scheduleRunFrequency,omitempty"` + WeeklySchedule *WeeklySchedule `json:"weeklySchedule,omitempty"` + + // Fields inherited from SchedulePolicy +} + +var _ json.Marshaler = SimpleSchedulePolicyV2{} + +func (s SimpleSchedulePolicyV2) MarshalJSON() ([]byte, error) { + type wrapper SimpleSchedulePolicyV2 + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SimpleSchedulePolicyV2: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SimpleSchedulePolicyV2: %+v", err) + } + decoded["schedulePolicyType"] = "SimpleSchedulePolicyV2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SimpleSchedulePolicyV2: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_snapshotbackupadditionaldetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_snapshotbackupadditionaldetails.go new file mode 100644 index 00000000000..7ac85d6090e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_snapshotbackupadditionaldetails.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotBackupAdditionalDetails struct { + InstantRPDetails *string `json:"instantRPDetails,omitempty"` + InstantRpRetentionRangeInDays *int64 `json:"instantRpRetentionRangeInDays,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_subprotectionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_subprotectionpolicy.go new file mode 100644 index 00000000000..f8d86c15304 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_subprotectionpolicy.go @@ -0,0 +1,53 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubProtectionPolicy struct { + PolicyType *PolicyType `json:"policyType,omitempty"` + RetentionPolicy RetentionPolicy `json:"retentionPolicy"` + SchedulePolicy SchedulePolicy `json:"schedulePolicy"` + SnapshotBackupAdditionalDetails *SnapshotBackupAdditionalDetails `json:"snapshotBackupAdditionalDetails,omitempty"` + TieringPolicy *map[string]TieringPolicy `json:"tieringPolicy,omitempty"` +} + +var _ json.Unmarshaler = &SubProtectionPolicy{} + +func (s *SubProtectionPolicy) UnmarshalJSON(bytes []byte) error { + type alias SubProtectionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into SubProtectionPolicy: %+v", err) + } + + s.PolicyType = decoded.PolicyType + s.SnapshotBackupAdditionalDetails = decoded.SnapshotBackupAdditionalDetails + s.TieringPolicy = decoded.TieringPolicy + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SubProtectionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["retentionPolicy"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RetentionPolicy' for 'SubProtectionPolicy': %+v", err) + } + s.RetentionPolicy = impl + } + + if v, ok := temp["schedulePolicy"]; ok { + impl, err := unmarshalSchedulePolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SchedulePolicy' for 'SubProtectionPolicy': %+v", err) + } + s.SchedulePolicy = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_tieringpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_tieringpolicy.go new file mode 100644 index 00000000000..51a5c8b97f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_tieringpolicy.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TieringPolicy struct { + Duration *int64 `json:"duration,omitempty"` + DurationType *RetentionDurationType `json:"durationType,omitempty"` + TieringMode *TieringMode `json:"tieringMode,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..7345c69f819 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..85ab2cf390a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_vaultretentionpolicy.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_vaultretentionpolicy.go new file mode 100644 index 00000000000..51b77729f01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_vaultretentionpolicy.go @@ -0,0 +1,40 @@ +package protectionpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultRetentionPolicy struct { + SnapshotRetentionInDays int64 `json:"snapshotRetentionInDays"` + VaultRetention RetentionPolicy `json:"vaultRetention"` +} + +var _ json.Unmarshaler = &VaultRetentionPolicy{} + +func (s *VaultRetentionPolicy) UnmarshalJSON(bytes []byte) error { + type alias VaultRetentionPolicy + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into VaultRetentionPolicy: %+v", err) + } + + s.SnapshotRetentionInDays = decoded.SnapshotRetentionInDays + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling VaultRetentionPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["vaultRetention"]; ok { + impl, err := unmarshalRetentionPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'VaultRetention' for 'VaultRetentionPolicy': %+v", err) + } + s.VaultRetention = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionformat.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionformat.go new file mode 100644 index 00000000000..082fcf7abe1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionformat.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklyRetentionFormat struct { + DaysOfTheWeek *[]DayOfWeek `json:"daysOfTheWeek,omitempty"` + WeeksOfTheMonth *[]WeekOfMonth `json:"weeksOfTheMonth,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionschedule.go new file mode 100644 index 00000000000..cde2551554d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyretentionschedule.go @@ -0,0 +1,10 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklyRetentionSchedule struct { + DaysOfTheWeek *[]DayOfWeek `json:"daysOfTheWeek,omitempty"` + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyschedule.go new file mode 100644 index 00000000000..f3005f7015f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_weeklyschedule.go @@ -0,0 +1,9 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklySchedule struct { + ScheduleRunDays *[]DayOfWeek `json:"scheduleRunDays,omitempty"` + ScheduleRunTimes *[]string `json:"scheduleRunTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_yearlyretentionschedule.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_yearlyretentionschedule.go new file mode 100644 index 00000000000..8d300368ef5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/model_yearlyretentionschedule.go @@ -0,0 +1,13 @@ +package protectionpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type YearlyRetentionSchedule struct { + MonthsOfYear *[]MonthOfYear `json:"monthsOfYear,omitempty"` + RetentionDuration *RetentionDuration `json:"retentionDuration,omitempty"` + RetentionScheduleDaily *DailyRetentionFormat `json:"retentionScheduleDaily,omitempty"` + RetentionScheduleFormatType *RetentionScheduleFormat `json:"retentionScheduleFormatType,omitempty"` + RetentionScheduleWeekly *WeeklyRetentionFormat `json:"retentionScheduleWeekly,omitempty"` + RetentionTimes *[]string `json:"retentionTimes,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/version.go new file mode 100644 index 00000000000..ab2d4c778fb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/protectionpolicies/version.go @@ -0,0 +1,12 @@ +package protectionpolicies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/protectionpolicies/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/README.md new file mode 100644 index 00000000000..9ce342d3483 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint` Documentation + +The `recoverypoint` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint" +``` + + +### Client Initialization + +```go +client := recoverypoint.NewRecoveryPointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointClient.MoveRecoveryPoint` + +```go +ctx := context.TODO() +id := recoverypoint.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +payload := recoverypoint.MoveRPAcrossTiersRequest{ + // ... +} + + +if err := client.MoveRecoveryPointThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/client.go new file mode 100644 index 00000000000..6c60cc292bc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/client.go @@ -0,0 +1,18 @@ +package recoverypoint + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointClient struct { + Client autorest.Client + baseUri string +} + +func NewRecoveryPointClientWithBaseURI(endpoint string) RecoveryPointClient { + return RecoveryPointClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/constants.go new file mode 100644 index 00000000000..90fc0ec9fcd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/constants.go @@ -0,0 +1,40 @@ +package recoverypoint + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint.go new file mode 100644 index 00000000000..f96affc2e8b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint.go @@ -0,0 +1,166 @@ +package recoverypoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint_test.go new file mode 100644 index 00000000000..afce76da591 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package recoverypoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/method_moverecoverypoint_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/method_moverecoverypoint_autorest.go new file mode 100644 index 00000000000..77b6f679042 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/method_moverecoverypoint_autorest.go @@ -0,0 +1,79 @@ +package recoverypoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MoveRecoveryPointOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// MoveRecoveryPoint ... +func (c RecoveryPointClient) MoveRecoveryPoint(ctx context.Context, id RecoveryPointId, input MoveRPAcrossTiersRequest) (result MoveRecoveryPointOperationResponse, err error) { + req, err := c.preparerForMoveRecoveryPoint(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoint.RecoveryPointClient", "MoveRecoveryPoint", nil, "Failure preparing request") + return + } + + result, err = c.senderForMoveRecoveryPoint(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoint.RecoveryPointClient", "MoveRecoveryPoint", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// MoveRecoveryPointThenPoll performs MoveRecoveryPoint then polls until it's completed +func (c RecoveryPointClient) MoveRecoveryPointThenPoll(ctx context.Context, id RecoveryPointId, input MoveRPAcrossTiersRequest) error { + result, err := c.MoveRecoveryPoint(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MoveRecoveryPoint: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after MoveRecoveryPoint: %+v", err) + } + + return nil +} + +// preparerForMoveRecoveryPoint prepares the MoveRecoveryPoint request. +func (c RecoveryPointClient) preparerForMoveRecoveryPoint(ctx context.Context, id RecoveryPointId, input MoveRPAcrossTiersRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/move", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForMoveRecoveryPoint sends the MoveRecoveryPoint request. The method will close the +// http.Response Body if it receives an error. +func (c RecoveryPointClient) senderForMoveRecoveryPoint(ctx context.Context, req *http.Request) (future MoveRecoveryPointOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/model_moverpacrosstiersrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/model_moverpacrosstiersrequest.go new file mode 100644 index 00000000000..c90154ae670 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/model_moverpacrosstiersrequest.go @@ -0,0 +1,10 @@ +package recoverypoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MoveRPAcrossTiersRequest struct { + ObjectType *string `json:"objectType,omitempty"` + SourceTierType *RecoveryPointTierType `json:"sourceTierType,omitempty"` + TargetTierType *RecoveryPointTierType `json:"targetTierType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/version.go new file mode 100644 index 00000000000..6dd0d8881d3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoint/version.go @@ -0,0 +1,12 @@ +package recoverypoint + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypoint/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/README.md new file mode 100644 index 00000000000..bd10d813570 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints` Documentation + +The `recoverypoints` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints" +``` + + +### Client Initialization + +```go +client := recoverypoints.NewRecoveryPointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointsClient.Get` + +```go +ctx := context.TODO() +id := recoverypoints.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecoveryPointsClient.List` + +```go +ctx := context.TODO() +id := recoverypoints.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +// alternatively `client.List(ctx, id, recoverypoints.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, recoverypoints.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/client.go new file mode 100644 index 00000000000..dab85424069 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/client.go @@ -0,0 +1,18 @@ +package recoverypoints + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointsClient struct { + Client autorest.Client + baseUri string +} + +func NewRecoveryPointsClientWithBaseURI(endpoint string) RecoveryPointsClient { + return RecoveryPointsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/constants.go new file mode 100644 index 00000000000..fa65db6e0e8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/constants.go @@ -0,0 +1,151 @@ +package recoverypoints + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierStatus string + +const ( + RecoveryPointTierStatusDeleted RecoveryPointTierStatus = "Deleted" + RecoveryPointTierStatusDisabled RecoveryPointTierStatus = "Disabled" + RecoveryPointTierStatusInvalid RecoveryPointTierStatus = "Invalid" + RecoveryPointTierStatusRehydrated RecoveryPointTierStatus = "Rehydrated" + RecoveryPointTierStatusValid RecoveryPointTierStatus = "Valid" +) + +func PossibleValuesForRecoveryPointTierStatus() []string { + return []string{ + string(RecoveryPointTierStatusDeleted), + string(RecoveryPointTierStatusDisabled), + string(RecoveryPointTierStatusInvalid), + string(RecoveryPointTierStatusRehydrated), + string(RecoveryPointTierStatusValid), + } +} + +func parseRecoveryPointTierStatus(input string) (*RecoveryPointTierStatus, error) { + vals := map[string]RecoveryPointTierStatus{ + "deleted": RecoveryPointTierStatusDeleted, + "disabled": RecoveryPointTierStatusDisabled, + "invalid": RecoveryPointTierStatusInvalid, + "rehydrated": RecoveryPointTierStatusRehydrated, + "valid": RecoveryPointTierStatusValid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierStatus(input) + return &out, nil +} + +type RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} + +type RestorePointType string + +const ( + RestorePointTypeDifferential RestorePointType = "Differential" + RestorePointTypeFull RestorePointType = "Full" + RestorePointTypeIncremental RestorePointType = "Incremental" + RestorePointTypeInvalid RestorePointType = "Invalid" + RestorePointTypeLog RestorePointType = "Log" + RestorePointTypeSnapshotCopyOnlyFull RestorePointType = "SnapshotCopyOnlyFull" + RestorePointTypeSnapshotFull RestorePointType = "SnapshotFull" +) + +func PossibleValuesForRestorePointType() []string { + return []string{ + string(RestorePointTypeDifferential), + string(RestorePointTypeFull), + string(RestorePointTypeIncremental), + string(RestorePointTypeInvalid), + string(RestorePointTypeLog), + string(RestorePointTypeSnapshotCopyOnlyFull), + string(RestorePointTypeSnapshotFull), + } +} + +func parseRestorePointType(input string) (*RestorePointType, error) { + vals := map[string]RestorePointType{ + "differential": RestorePointTypeDifferential, + "full": RestorePointTypeFull, + "incremental": RestorePointTypeIncremental, + "invalid": RestorePointTypeInvalid, + "log": RestorePointTypeLog, + "snapshotcopyonlyfull": RestorePointTypeSnapshotCopyOnlyFull, + "snapshotfull": RestorePointTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestorePointType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem.go new file mode 100644 index 00000000000..ef1302a98e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem.go @@ -0,0 +1,157 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProtectedItemIDInsensitively parses 'input' case-insensitively into a ProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseProtectedItemIDInsensitively(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return nil +} + +// ValidateProtectedItemID checks that 'input' can be parsed as a Protected Item ID +func ValidateProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protected Item ID +func (id ProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protected Item ID +func (id ProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem_test.go new file mode 100644 index 00000000000..60147759c19 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package recoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint.go new file mode 100644 index 00000000000..e180c744612 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint.go @@ -0,0 +1,166 @@ +package recoverypoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint_test.go new file mode 100644 index 00000000000..888c5b072a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package recoverypoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_get_autorest.go new file mode 100644 index 00000000000..dce6d176011 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_get_autorest.go @@ -0,0 +1,68 @@ +package recoverypoints + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *RecoveryPointResource +} + +// Get ... +func (c RecoveryPointsClient) Get(ctx context.Context, id RecoveryPointId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c RecoveryPointsClient) preparerForGet(ctx context.Context, id RecoveryPointId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c RecoveryPointsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_list_autorest.go new file mode 100644 index 00000000000..904ef293b39 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/method_list_autorest.go @@ -0,0 +1,215 @@ +package recoverypoints + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]RecoveryPointResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []RecoveryPointResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o ListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// List ... +func (c RecoveryPointsClient) List(ctx context.Context, id ProtectedItemId, options ListOperationOptions) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c RecoveryPointsClient) preparerForList(ctx context.Context, id ProtectedItemId, options ListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/recoveryPoints", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c RecoveryPointsClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c RecoveryPointsClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []RecoveryPointResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypoints.RecoveryPointsClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c RecoveryPointsClient) ListComplete(ctx context.Context, id ProtectedItemId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RecoveryPointResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RecoveryPointsClient) ListCompleteMatchingPredicate(ctx context.Context, id ProtectedItemId, options ListOperationOptions, predicate RecoveryPointResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]RecoveryPointResource, 0) + + page, err := c.List(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azurefilesharerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azurefilesharerecoverypoint.go new file mode 100644 index 00000000000..2a7c237f200 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azurefilesharerecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureFileShareRecoveryPoint{} + +type AzureFileShareRecoveryPoint struct { + FileShareSnapshotUri *string `json:"fileShareSnapshotUri,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointSizeInGB *int64 `json:"recoveryPointSizeInGB,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureFileShareRecoveryPoint{} + +func (s AzureFileShareRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureFileShareRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go new file mode 100644 index 00000000000..a36ed7d5894 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadpointintimerecoverypoint.go @@ -0,0 +1,46 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadPointInTimeRecoveryPoint{} + +type AzureWorkloadPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRecoveryPoint{} + +func (s AzureWorkloadPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadrecoverypoint.go new file mode 100644 index 00000000000..a060d0325a6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadrecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadRecoveryPoint{} + +type AzureWorkloadRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadRecoveryPoint{} + +func (s AzureWorkloadRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go new file mode 100644 index 00000000000..ba3317831d8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanapointintimerecoverypoint.go @@ -0,0 +1,46 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +type AzureWorkloadSAPHanaPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSAPHanaPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go new file mode 100644 index 00000000000..3cc6563ceee --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsaphanarecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSAPHanaRecoveryPoint{} + +type AzureWorkloadSAPHanaRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRecoveryPoint{} + +func (s AzureWorkloadSAPHanaRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go new file mode 100644 index 00000000000..0e54dcb88e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlpointintimerecoverypoint.go @@ -0,0 +1,47 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +type AzureWorkloadSQLPointInTimeRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSQLPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go new file mode 100644 index 00000000000..e4c16a37cbf --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypoint.go @@ -0,0 +1,46 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSQLRecoveryPoint{} + +type AzureWorkloadSQLRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSQLRecoveryPoint{} + +func (s AzureWorkloadSQLRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go new file mode 100644 index 00000000000..8ad178eb3ba --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_azureworkloadsqlrecoverypointextendedinfo.go @@ -0,0 +1,27 @@ +package recoverypoints + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadSQLRecoveryPointExtendedInfo struct { + DataDirectoryPaths *[]SQLDataDirectory `json:"dataDirectoryPaths,omitempty"` + DataDirectoryTimeInUTC *string `json:"dataDirectoryTimeInUTC,omitempty"` +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) GetDataDirectoryTimeInUTCAsTime() (*time.Time, error) { + if o.DataDirectoryTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DataDirectoryTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) SetDataDirectoryTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DataDirectoryTimeInUTC = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_bekdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_bekdetails.go new file mode 100644 index 00000000000..36772ad0169 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_bekdetails.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BEKDetails struct { + SecretData *string `json:"secretData,omitempty"` + SecretUrl *string `json:"secretUrl,omitempty"` + SecretVaultId *string `json:"secretVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_diskinformation.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_diskinformation.go new file mode 100644 index 00000000000..1d6ed082bf4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_diskinformation.go @@ -0,0 +1,9 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskInformation struct { + Lun *int64 `json:"lun,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_extendedlocation.go new file mode 100644 index 00000000000..a4b7423fd00 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_extendedlocation.go @@ -0,0 +1,9 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_genericrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_genericrecoverypoint.go new file mode 100644 index 00000000000..97d3952dc2c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_genericrecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = GenericRecoveryPoint{} + +type GenericRecoveryPoint struct { + FriendlyName *string `json:"friendlyName,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = GenericRecoveryPoint{} + +func (s GenericRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper GenericRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericRecoveryPoint: %+v", err) + } + decoded["objectType"] = "GenericRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_iaasvmrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_iaasvmrecoverypoint.go new file mode 100644 index 00000000000..dbd1d19b002 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_iaasvmrecoverypoint.go @@ -0,0 +1,61 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = IaasVMRecoveryPoint{} + +type IaasVMRecoveryPoint struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IsInstantIlrSessionActive *bool `json:"isInstantIlrSessionActive,omitempty"` + IsManagedVirtualMachine *bool `json:"isManagedVirtualMachine,omitempty"` + IsPrivateAccessEnabledOnAnyDisk *bool `json:"isPrivateAccessEnabledOnAnyDisk,omitempty"` + IsSourceVMEncrypted *bool `json:"isSourceVMEncrypted,omitempty"` + KeyAndSecret *KeyAndSecretDetails `json:"keyAndSecret,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + OsType *string `json:"osType,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointDiskConfiguration *RecoveryPointDiskConfiguration `json:"recoveryPointDiskConfiguration,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + SecurityType *string `json:"securityType,omitempty"` + SourceVMStorageType *string `json:"sourceVMStorageType,omitempty"` + VirtualMachineSize *string `json:"virtualMachineSize,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = IaasVMRecoveryPoint{} + +func (s IaasVMRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRecoveryPoint: %+v", err) + } + decoded["objectType"] = "IaasVMRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_kekdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_kekdetails.go new file mode 100644 index 00000000000..36abbae9609 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_kekdetails.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KEKDetails struct { + KeyBackupData *string `json:"keyBackupData,omitempty"` + KeyUrl *string `json:"keyUrl,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_keyandsecretdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_keyandsecretdetails.go new file mode 100644 index 00000000000..96c513fc516 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_keyandsecretdetails.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyAndSecretDetails struct { + BekDetails *BEKDetails `json:"bekDetails,omitempty"` + EncryptionMechanism *string `json:"encryptionMechanism,omitempty"` + KekDetails *KEKDetails `json:"kekDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_pointintimerange.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_pointintimerange.go new file mode 100644 index 00000000000..4190258e022 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_pointintimerange.go @@ -0,0 +1,39 @@ +package recoverypoints + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PointInTimeRange struct { + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *PointInTimeRange) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PointInTimeRange) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypoint.go new file mode 100644 index 00000000000..cb819e0f9c5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypoint.go @@ -0,0 +1,117 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPoint interface { +} + +// RawRecoveryPointImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRecoveryPointImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryPointImplementation(input []byte) (RecoveryPoint, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPoint into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareRecoveryPoint") { + var out AzureFileShareRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRecoveryPoint") { + var out AzureWorkloadPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRecoveryPoint") { + var out AzureWorkloadRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRecoveryPoint") { + var out AzureWorkloadSAPHanaPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRecoveryPoint") { + var out AzureWorkloadSAPHanaRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRecoveryPoint") { + var out AzureWorkloadSQLPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRecoveryPoint") { + var out AzureWorkloadSQLRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericRecoveryPoint") { + var out GenericRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRecoveryPoint") { + var out IaasVMRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRecoveryPoint: %+v", err) + } + return out, nil + } + + out := RawRecoveryPointImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointdiskconfiguration.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointdiskconfiguration.go new file mode 100644 index 00000000000..d3935380d03 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointdiskconfiguration.go @@ -0,0 +1,11 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointDiskConfiguration struct { + ExcludedDiskList *[]DiskInformation `json:"excludedDiskList,omitempty"` + IncludedDiskList *[]DiskInformation `json:"includedDiskList,omitempty"` + NumberOfDisksAttachedToVM *int64 `json:"numberOfDisksAttachedToVm,omitempty"` + NumberOfDisksIncludedInBackup *int64 `json:"numberOfDisksIncludedInBackup,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointmovereadinessinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointmovereadinessinfo.go new file mode 100644 index 00000000000..03cab067198 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointmovereadinessinfo.go @@ -0,0 +1,9 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointMoveReadinessInfo struct { + AdditionalInfo *string `json:"additionalInfo,omitempty"` + IsReadyForMove *bool `json:"isReadyForMove,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointproperties.go new file mode 100644 index 00000000000..4bd3f5e75a3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointproperties.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointProperties struct { + ExpiryTime *string `json:"expiryTime,omitempty"` + IsSoftDeleted *bool `json:"isSoftDeleted,omitempty"` + RuleName *string `json:"ruleName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointresource.go new file mode 100644 index 00000000000..8e67217424b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointresource.go @@ -0,0 +1,50 @@ +package recoverypoints + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties RecoveryPoint `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPointResource{} + +func (s *RecoveryPointResource) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPointResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPointResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPointResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalRecoveryPointImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'RecoveryPointResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointtierinformationv2.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointtierinformationv2.go new file mode 100644 index 00000000000..996285f0562 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_recoverypointtierinformationv2.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierInformationV2 struct { + ExtendedInfo *map[string]string `json:"extendedInfo,omitempty"` + Status *RecoveryPointTierStatus `json:"status,omitempty"` + Type *RecoveryPointTierType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_sqldatadirectory.go new file mode 100644 index 00000000000..8460946fc57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/model_sqldatadirectory.go @@ -0,0 +1,10 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectory struct { + LogicalName *string `json:"logicalName,omitempty"` + Path *string `json:"path,omitempty"` + Type *SQLDataDirectoryType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/predicates.go new file mode 100644 index 00000000000..c3db33a5e75 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/predicates.go @@ -0,0 +1,37 @@ +package recoverypoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPointResourceOperationPredicate) Matches(input RecoveryPointResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/version.go new file mode 100644 index 00000000000..0a6ee560dd4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypoints/version.go @@ -0,0 +1,12 @@ +package recoverypoints + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypoints/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/README.md new file mode 100644 index 00000000000..8fce050b309 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove` Documentation + +The `recoverypointsrecommendedformove` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove" +``` + + +### Client Initialization + +```go +client := recoverypointsrecommendedformove.NewRecoveryPointsRecommendedForMoveClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecoveryPointsRecommendedForMoveClient.List` + +```go +ctx := context.TODO() +id := recoverypointsrecommendedformove.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + +payload := recoverypointsrecommendedformove.ListRecoveryPointsRecommendedForMoveRequest{ + // ... +} + + +// alternatively `client.List(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/client.go new file mode 100644 index 00000000000..0f891c24f9b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/client.go @@ -0,0 +1,18 @@ +package recoverypointsrecommendedformove + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointsRecommendedForMoveClient struct { + Client autorest.Client + baseUri string +} + +func NewRecoveryPointsRecommendedForMoveClientWithBaseURI(endpoint string) RecoveryPointsRecommendedForMoveClient { + return RecoveryPointsRecommendedForMoveClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/constants.go new file mode 100644 index 00000000000..e2e55355df0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/constants.go @@ -0,0 +1,151 @@ +package recoverypointsrecommendedformove + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierStatus string + +const ( + RecoveryPointTierStatusDeleted RecoveryPointTierStatus = "Deleted" + RecoveryPointTierStatusDisabled RecoveryPointTierStatus = "Disabled" + RecoveryPointTierStatusInvalid RecoveryPointTierStatus = "Invalid" + RecoveryPointTierStatusRehydrated RecoveryPointTierStatus = "Rehydrated" + RecoveryPointTierStatusValid RecoveryPointTierStatus = "Valid" +) + +func PossibleValuesForRecoveryPointTierStatus() []string { + return []string{ + string(RecoveryPointTierStatusDeleted), + string(RecoveryPointTierStatusDisabled), + string(RecoveryPointTierStatusInvalid), + string(RecoveryPointTierStatusRehydrated), + string(RecoveryPointTierStatusValid), + } +} + +func parseRecoveryPointTierStatus(input string) (*RecoveryPointTierStatus, error) { + vals := map[string]RecoveryPointTierStatus{ + "deleted": RecoveryPointTierStatusDeleted, + "disabled": RecoveryPointTierStatusDisabled, + "invalid": RecoveryPointTierStatusInvalid, + "rehydrated": RecoveryPointTierStatusRehydrated, + "valid": RecoveryPointTierStatusValid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierStatus(input) + return &out, nil +} + +type RecoveryPointTierType string + +const ( + RecoveryPointTierTypeArchivedRP RecoveryPointTierType = "ArchivedRP" + RecoveryPointTierTypeHardenedRP RecoveryPointTierType = "HardenedRP" + RecoveryPointTierTypeInstantRP RecoveryPointTierType = "InstantRP" + RecoveryPointTierTypeInvalid RecoveryPointTierType = "Invalid" +) + +func PossibleValuesForRecoveryPointTierType() []string { + return []string{ + string(RecoveryPointTierTypeArchivedRP), + string(RecoveryPointTierTypeHardenedRP), + string(RecoveryPointTierTypeInstantRP), + string(RecoveryPointTierTypeInvalid), + } +} + +func parseRecoveryPointTierType(input string) (*RecoveryPointTierType, error) { + vals := map[string]RecoveryPointTierType{ + "archivedrp": RecoveryPointTierTypeArchivedRP, + "hardenedrp": RecoveryPointTierTypeHardenedRP, + "instantrp": RecoveryPointTierTypeInstantRP, + "invalid": RecoveryPointTierTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryPointTierType(input) + return &out, nil +} + +type RestorePointType string + +const ( + RestorePointTypeDifferential RestorePointType = "Differential" + RestorePointTypeFull RestorePointType = "Full" + RestorePointTypeIncremental RestorePointType = "Incremental" + RestorePointTypeInvalid RestorePointType = "Invalid" + RestorePointTypeLog RestorePointType = "Log" + RestorePointTypeSnapshotCopyOnlyFull RestorePointType = "SnapshotCopyOnlyFull" + RestorePointTypeSnapshotFull RestorePointType = "SnapshotFull" +) + +func PossibleValuesForRestorePointType() []string { + return []string{ + string(RestorePointTypeDifferential), + string(RestorePointTypeFull), + string(RestorePointTypeIncremental), + string(RestorePointTypeInvalid), + string(RestorePointTypeLog), + string(RestorePointTypeSnapshotCopyOnlyFull), + string(RestorePointTypeSnapshotFull), + } +} + +func parseRestorePointType(input string) (*RestorePointType, error) { + vals := map[string]RestorePointType{ + "differential": RestorePointTypeDifferential, + "full": RestorePointTypeFull, + "incremental": RestorePointTypeIncremental, + "invalid": RestorePointTypeInvalid, + "log": RestorePointTypeLog, + "snapshotcopyonlyfull": RestorePointTypeSnapshotCopyOnlyFull, + "snapshotfull": RestorePointTypeSnapshotFull, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestorePointType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem.go new file mode 100644 index 00000000000..a027aaa0b71 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem.go @@ -0,0 +1,157 @@ +package recoverypointsrecommendedformove + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProtectedItemId{}) +} + +var _ resourceids.ResourceId = &ProtectedItemId{} + +// ProtectedItemId is a struct representing the Resource ID for a Protected Item +type ProtectedItemId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string +} + +// NewProtectedItemID returns a new ProtectedItemId struct +func NewProtectedItemID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string) ProtectedItemId { + return ProtectedItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + } +} + +// ParseProtectedItemID parses 'input' into a ProtectedItemId +func ParseProtectedItemID(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProtectedItemIDInsensitively parses 'input' case-insensitively into a ProtectedItemId +// note: this method should only be used for API response data and not user input +func ParseProtectedItemIDInsensitively(input string) (*ProtectedItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProtectedItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProtectedItemId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProtectedItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + return nil +} + +// ValidateProtectedItemID checks that 'input' can be parsed as a Protected Item ID +func ValidateProtectedItemID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProtectedItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Protected Item ID +func (id ProtectedItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Protected Item ID +func (id ProtectedItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + } +} + +// String returns a human-readable description of this Protected Item ID +func (id ProtectedItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + } + return fmt.Sprintf("Protected Item (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem_test.go new file mode 100644 index 00000000000..a75698ad768 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/id_protecteditem_test.go @@ -0,0 +1,417 @@ +package recoverypointsrecommendedformove + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProtectedItemId{} + +func TestNewProtectedItemID(t *testing.T) { + id := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } +} + +func TestFormatProtectedItemID(t *testing.T) { + actual := NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProtectedItemID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestParseProtectedItemIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProtectedItemId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Expected: &ProtectedItemId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProtectedItemIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + } +} + +func TestSegmentsForProtectedItemId(t *testing.T) { + segments := ProtectedItemId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProtectedItemId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/method_list_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/method_list_autorest.go new file mode 100644 index 00000000000..71847a51411 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/method_list_autorest.go @@ -0,0 +1,187 @@ +package recoverypointsrecommendedformove + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + Model *[]RecoveryPointResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (ListOperationResponse, error) +} + +type ListCompleteResult struct { + Items []RecoveryPointResource +} + +func (r ListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r ListOperationResponse) LoadMore(ctx context.Context) (resp ListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// List ... +func (c RecoveryPointsRecommendedForMoveClient) List(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest) (resp ListOperationResponse, err error) { + req, err := c.preparerForList(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForList prepares the List request. +func (c RecoveryPointsRecommendedForMoveClient) preparerForList(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/recoveryPointsRecommendedForMove", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForListWithNextLink prepares the List request with the given nextLink token. +func (c RecoveryPointsRecommendedForMoveClient) preparerForListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForList handles the response to the List request. The method always +// closes the http.Response Body. +func (c RecoveryPointsRecommendedForMoveClient) responderForList(resp *http.Response) (result ListOperationResponse, err error) { + type page struct { + Values []RecoveryPointResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result ListOperationResponse, err error) { + req, err := c.preparerForListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "recoverypointsrecommendedformove.RecoveryPointsRecommendedForMoveClient", "List", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// ListComplete retrieves all of the results into a single object +func (c RecoveryPointsRecommendedForMoveClient) ListComplete(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, input, RecoveryPointResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c RecoveryPointsRecommendedForMoveClient) ListCompleteMatchingPredicate(ctx context.Context, id ProtectedItemId, input ListRecoveryPointsRecommendedForMoveRequest, predicate RecoveryPointResourceOperationPredicate) (resp ListCompleteResult, err error) { + items := make([]RecoveryPointResource, 0) + + page, err := c.List(ctx, id, input) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := ListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go new file mode 100644 index 00000000000..3654d6b1bf1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azurefilesharerecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureFileShareRecoveryPoint{} + +type AzureFileShareRecoveryPoint struct { + FileShareSnapshotUri *string `json:"fileShareSnapshotUri,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointSizeInGB *int64 `json:"recoveryPointSizeInGB,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureFileShareRecoveryPoint{} + +func (s AzureFileShareRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureFileShareRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go new file mode 100644 index 00000000000..4b477077a01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadpointintimerecoverypoint.go @@ -0,0 +1,46 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadPointInTimeRecoveryPoint{} + +type AzureWorkloadPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRecoveryPoint{} + +func (s AzureWorkloadPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go new file mode 100644 index 00000000000..6c7e5f6b958 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadrecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadRecoveryPoint{} + +type AzureWorkloadRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadRecoveryPoint{} + +func (s AzureWorkloadRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go new file mode 100644 index 00000000000..801a86e29aa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanapointintimerecoverypoint.go @@ -0,0 +1,46 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +type AzureWorkloadSAPHanaPointInTimeRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSAPHanaPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go new file mode 100644 index 00000000000..4ca5f3470d3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsaphanarecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSAPHanaRecoveryPoint{} + +type AzureWorkloadSAPHanaRecoveryPoint struct { + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRecoveryPoint{} + +func (s AzureWorkloadSAPHanaRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go new file mode 100644 index 00000000000..e5030f32945 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlpointintimerecoverypoint.go @@ -0,0 +1,47 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +type AzureWorkloadSQLPointInTimeRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + TimeRanges *[]PointInTimeRange `json:"timeRanges,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRecoveryPoint{} + +func (s AzureWorkloadSQLPointInTimeRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go new file mode 100644 index 00000000000..0e441f79cda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypoint.go @@ -0,0 +1,46 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = AzureWorkloadSQLRecoveryPoint{} + +type AzureWorkloadSQLRecoveryPoint struct { + ExtendedInfo *AzureWorkloadSQLRecoveryPointExtendedInfo `json:"extendedInfo,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTimeInUTC *string `json:"recoveryPointTimeInUTC,omitempty"` + Type *RestorePointType `json:"type,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = AzureWorkloadSQLRecoveryPoint{} + +func (s AzureWorkloadSQLRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go new file mode 100644 index 00000000000..f98b9b7a0b4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_azureworkloadsqlrecoverypointextendedinfo.go @@ -0,0 +1,27 @@ +package recoverypointsrecommendedformove + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadSQLRecoveryPointExtendedInfo struct { + DataDirectoryPaths *[]SQLDataDirectory `json:"dataDirectoryPaths,omitempty"` + DataDirectoryTimeInUTC *string `json:"dataDirectoryTimeInUTC,omitempty"` +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) GetDataDirectoryTimeInUTCAsTime() (*time.Time, error) { + if o.DataDirectoryTimeInUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.DataDirectoryTimeInUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureWorkloadSQLRecoveryPointExtendedInfo) SetDataDirectoryTimeInUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.DataDirectoryTimeInUTC = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_bekdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_bekdetails.go new file mode 100644 index 00000000000..2060eb3fa42 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_bekdetails.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BEKDetails struct { + SecretData *string `json:"secretData,omitempty"` + SecretUrl *string `json:"secretUrl,omitempty"` + SecretVaultId *string `json:"secretVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_diskinformation.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_diskinformation.go new file mode 100644 index 00000000000..efce1750999 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_diskinformation.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskInformation struct { + Lun *int64 `json:"lun,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_extendedlocation.go new file mode 100644 index 00000000000..04a4089410d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_extendedlocation.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go new file mode 100644 index 00000000000..040a2cf2cc1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_genericrecoverypoint.go @@ -0,0 +1,45 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = GenericRecoveryPoint{} + +type GenericRecoveryPoint struct { + FriendlyName *string `json:"friendlyName,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = GenericRecoveryPoint{} + +func (s GenericRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper GenericRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericRecoveryPoint: %+v", err) + } + decoded["objectType"] = "GenericRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go new file mode 100644 index 00000000000..12aa7a9b66b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_iaasvmrecoverypoint.go @@ -0,0 +1,61 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RecoveryPoint = IaasVMRecoveryPoint{} + +type IaasVMRecoveryPoint struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IsInstantIlrSessionActive *bool `json:"isInstantIlrSessionActive,omitempty"` + IsManagedVirtualMachine *bool `json:"isManagedVirtualMachine,omitempty"` + IsPrivateAccessEnabledOnAnyDisk *bool `json:"isPrivateAccessEnabledOnAnyDisk,omitempty"` + IsSourceVMEncrypted *bool `json:"isSourceVMEncrypted,omitempty"` + KeyAndSecret *KeyAndSecretDetails `json:"keyAndSecret,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + OsType *string `json:"osType,omitempty"` + RecoveryPointAdditionalInfo *string `json:"recoveryPointAdditionalInfo,omitempty"` + RecoveryPointDiskConfiguration *RecoveryPointDiskConfiguration `json:"recoveryPointDiskConfiguration,omitempty"` + RecoveryPointMoveReadinessInfo *map[string]RecoveryPointMoveReadinessInfo `json:"recoveryPointMoveReadinessInfo,omitempty"` + RecoveryPointProperties *RecoveryPointProperties `json:"recoveryPointProperties,omitempty"` + RecoveryPointTierDetails *[]RecoveryPointTierInformationV2 `json:"recoveryPointTierDetails,omitempty"` + RecoveryPointTime *string `json:"recoveryPointTime,omitempty"` + RecoveryPointType *string `json:"recoveryPointType,omitempty"` + SecurityType *string `json:"securityType,omitempty"` + SourceVMStorageType *string `json:"sourceVMStorageType,omitempty"` + VirtualMachineSize *string `json:"virtualMachineSize,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RecoveryPoint +} + +var _ json.Marshaler = IaasVMRecoveryPoint{} + +func (s IaasVMRecoveryPoint) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRecoveryPoint + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRecoveryPoint: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRecoveryPoint: %+v", err) + } + decoded["objectType"] = "IaasVMRecoveryPoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRecoveryPoint: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_kekdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_kekdetails.go new file mode 100644 index 00000000000..a3aeb5f2512 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_kekdetails.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KEKDetails struct { + KeyBackupData *string `json:"keyBackupData,omitempty"` + KeyUrl *string `json:"keyUrl,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go new file mode 100644 index 00000000000..65444fc0f49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_keyandsecretdetails.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyAndSecretDetails struct { + BekDetails *BEKDetails `json:"bekDetails,omitempty"` + EncryptionMechanism *string `json:"encryptionMechanism,omitempty"` + KekDetails *KEKDetails `json:"kekDetails,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go new file mode 100644 index 00000000000..0085a2a3b9d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_listrecoverypointsrecommendedformoverequest.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRecoveryPointsRecommendedForMoveRequest struct { + ExcludedRPList *[]string `json:"excludedRPList,omitempty"` + ObjectType *string `json:"objectType,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_pointintimerange.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_pointintimerange.go new file mode 100644 index 00000000000..9bb33473707 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_pointintimerange.go @@ -0,0 +1,39 @@ +package recoverypointsrecommendedformove + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PointInTimeRange struct { + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *PointInTimeRange) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PointInTimeRange) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PointInTimeRange) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypoint.go new file mode 100644 index 00000000000..7cd17561fd8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypoint.go @@ -0,0 +1,117 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPoint interface { +} + +// RawRecoveryPointImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRecoveryPointImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRecoveryPointImplementation(input []byte) (RecoveryPoint, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RecoveryPoint into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareRecoveryPoint") { + var out AzureFileShareRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRecoveryPoint") { + var out AzureWorkloadPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRecoveryPoint") { + var out AzureWorkloadRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRecoveryPoint") { + var out AzureWorkloadSAPHanaPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRecoveryPoint") { + var out AzureWorkloadSAPHanaRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRecoveryPoint") { + var out AzureWorkloadSQLPointInTimeRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRecoveryPoint") { + var out AzureWorkloadSQLRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericRecoveryPoint") { + var out GenericRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericRecoveryPoint: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRecoveryPoint") { + var out IaasVMRecoveryPoint + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRecoveryPoint: %+v", err) + } + return out, nil + } + + out := RawRecoveryPointImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go new file mode 100644 index 00000000000..6ec831b050f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointdiskconfiguration.go @@ -0,0 +1,11 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointDiskConfiguration struct { + ExcludedDiskList *[]DiskInformation `json:"excludedDiskList,omitempty"` + IncludedDiskList *[]DiskInformation `json:"includedDiskList,omitempty"` + NumberOfDisksAttachedToVM *int64 `json:"numberOfDisksAttachedToVm,omitempty"` + NumberOfDisksIncludedInBackup *int64 `json:"numberOfDisksIncludedInBackup,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go new file mode 100644 index 00000000000..2f638ab7bcd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointmovereadinessinfo.go @@ -0,0 +1,9 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointMoveReadinessInfo struct { + AdditionalInfo *string `json:"additionalInfo,omitempty"` + IsReadyForMove *bool `json:"isReadyForMove,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointproperties.go new file mode 100644 index 00000000000..97af2516cec --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointproperties.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointProperties struct { + ExpiryTime *string `json:"expiryTime,omitempty"` + IsSoftDeleted *bool `json:"isSoftDeleted,omitempty"` + RuleName *string `json:"ruleName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointresource.go new file mode 100644 index 00000000000..26a0bbdce62 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointresource.go @@ -0,0 +1,50 @@ +package recoverypointsrecommendedformove + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties RecoveryPoint `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &RecoveryPointResource{} + +func (s *RecoveryPointResource) UnmarshalJSON(bytes []byte) error { + type alias RecoveryPointResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RecoveryPointResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RecoveryPointResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalRecoveryPointImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'RecoveryPointResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go new file mode 100644 index 00000000000..6f014df3e1d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_recoverypointtierinformationv2.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointTierInformationV2 struct { + ExtendedInfo *map[string]string `json:"extendedInfo,omitempty"` + Status *RecoveryPointTierStatus `json:"status,omitempty"` + Type *RecoveryPointTierType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_sqldatadirectory.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_sqldatadirectory.go new file mode 100644 index 00000000000..74ae63ba5e5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/model_sqldatadirectory.go @@ -0,0 +1,10 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectory struct { + LogicalName *string `json:"logicalName,omitempty"` + Path *string `json:"path,omitempty"` + Type *SQLDataDirectoryType `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/predicates.go new file mode 100644 index 00000000000..9f73792f14b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/predicates.go @@ -0,0 +1,37 @@ +package recoverypointsrecommendedformove + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p RecoveryPointResourceOperationPredicate) Matches(input RecoveryPointResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/version.go new file mode 100644 index 00000000000..43d14d320b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/recoverypointsrecommendedformove/version.go @@ -0,0 +1,12 @@ +package recoverypointsrecommendedformove + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recoverypointsrecommendedformove/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/README.md new file mode 100644 index 00000000000..d65b176c401 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies` Documentation + +The `resourceguardproxies` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies" +``` + + +### Client Initialization + +```go +client := resourceguardproxies.NewResourceGuardProxiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceGuardProxiesClient.Get` + +```go +ctx := context.TODO() +id := resourceguardproxies.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.Get(ctx, id)` can be used to do batched pagination +items, err := client.GetComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/client.go new file mode 100644 index 00000000000..ad46ba07081 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/client.go @@ -0,0 +1,18 @@ +package resourceguardproxies + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxiesClient struct { + Client autorest.Client + baseUri string +} + +func NewResourceGuardProxiesClientWithBaseURI(endpoint string) ResourceGuardProxiesClient { + return ResourceGuardProxiesClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault.go new file mode 100644 index 00000000000..8f516c78ab1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault.go @@ -0,0 +1,130 @@ +package resourceguardproxies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault_test.go new file mode 100644 index 00000000000..61ba264e982 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/id_vault_test.go @@ -0,0 +1,282 @@ +package resourceguardproxies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/method_get_autorest.go new file mode 100644 index 00000000000..d7c440b262d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/method_get_autorest.go @@ -0,0 +1,186 @@ +package resourceguardproxies + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *[]ResourceGuardProxyBaseResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (GetOperationResponse, error) +} + +type GetCompleteResult struct { + Items []ResourceGuardProxyBaseResource +} + +func (r GetOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r GetOperationResponse) LoadMore(ctx context.Context) (resp GetOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +// Get ... +func (c ResourceGuardProxiesClient) Get(ctx context.Context, id VaultId) (resp GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForGet(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForGet prepares the Get request. +func (c ResourceGuardProxiesClient) preparerForGet(ctx context.Context, id VaultId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupResourceGuardProxies", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForGetWithNextLink prepares the Get request with the given nextLink token. +func (c ResourceGuardProxiesClient) preparerForGetWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxiesClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + type page struct { + Values []ResourceGuardProxyBaseResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result GetOperationResponse, err error) { + req, err := c.preparerForGetWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxies.ResourceGuardProxiesClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// GetComplete retrieves all of the results into a single object +func (c ResourceGuardProxiesClient) GetComplete(ctx context.Context, id VaultId) (GetCompleteResult, error) { + return c.GetCompleteMatchingPredicate(ctx, id, ResourceGuardProxyBaseResourceOperationPredicate{}) +} + +// GetCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c ResourceGuardProxiesClient) GetCompleteMatchingPredicate(ctx context.Context, id VaultId, predicate ResourceGuardProxyBaseResourceOperationPredicate) (resp GetCompleteResult, err error) { + items := make([]ResourceGuardProxyBaseResource, 0) + + page, err := c.Get(ctx, id) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := GetCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardoperationdetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardoperationdetail.go new file mode 100644 index 00000000000..fedeee2c425 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardoperationdetail.go @@ -0,0 +1,9 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardOperationDetail struct { + DefaultResourceRequest *string `json:"defaultResourceRequest,omitempty"` + VaultCriticalOperation *string `json:"vaultCriticalOperation,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybase.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybase.go new file mode 100644 index 00000000000..26938a5027c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybase.go @@ -0,0 +1,11 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBase struct { + Description *string `json:"description,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + ResourceGuardOperationDetails *[]ResourceGuardOperationDetail `json:"resourceGuardOperationDetails,omitempty"` + ResourceGuardResourceId string `json:"resourceGuardResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybaseresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybaseresource.go new file mode 100644 index 00000000000..bc307c162c1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/model_resourceguardproxybaseresource.go @@ -0,0 +1,14 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceGuardProxyBase `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/predicates.go new file mode 100644 index 00000000000..dca1b113f34 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/predicates.go @@ -0,0 +1,37 @@ +package resourceguardproxies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ResourceGuardProxyBaseResourceOperationPredicate) Matches(input ResourceGuardProxyBaseResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/version.go new file mode 100644 index 00000000000..90519540c49 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxies/version.go @@ -0,0 +1,12 @@ +package resourceguardproxies + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourceguardproxies/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/README.md new file mode 100644 index 00000000000..77735e9796d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/README.md @@ -0,0 +1,94 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy` Documentation + +The `resourceguardproxy` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy" +``` + + +### Client Initialization + +```go +client := resourceguardproxy.NewResourceGuardProxyClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceGuardProxyClient.Delete` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardProxyClient.Get` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardProxyClient.Put` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +payload := resourceguardproxy.ResourceGuardProxyBaseResource{ + // ... +} + + +read, err := client.Put(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceGuardProxyClient.UnlockDelete` + +```go +ctx := context.TODO() +id := resourceguardproxy.NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + +payload := resourceguardproxy.UnlockDeleteRequest{ + // ... +} + + +read, err := client.UnlockDelete(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/client.go new file mode 100644 index 00000000000..d07fa6e5381 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/client.go @@ -0,0 +1,18 @@ +package resourceguardproxy + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyClient struct { + Client autorest.Client + baseUri string +} + +func NewResourceGuardProxyClientWithBaseURI(endpoint string) ResourceGuardProxyClient { + return ResourceGuardProxyClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy.go new file mode 100644 index 00000000000..889a597614e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy.go @@ -0,0 +1,139 @@ +package resourceguardproxy + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupResourceGuardProxyId{}) +} + +var _ resourceids.ResourceId = &BackupResourceGuardProxyId{} + +// BackupResourceGuardProxyId is a struct representing the Resource ID for a Backup Resource Guard Proxy +type BackupResourceGuardProxyId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupResourceGuardProxyName string +} + +// NewBackupResourceGuardProxyID returns a new BackupResourceGuardProxyId struct +func NewBackupResourceGuardProxyID(subscriptionId string, resourceGroupName string, vaultName string, backupResourceGuardProxyName string) BackupResourceGuardProxyId { + return BackupResourceGuardProxyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupResourceGuardProxyName: backupResourceGuardProxyName, + } +} + +// ParseBackupResourceGuardProxyID parses 'input' into a BackupResourceGuardProxyId +func ParseBackupResourceGuardProxyID(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupResourceGuardProxyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupResourceGuardProxyIDInsensitively parses 'input' case-insensitively into a BackupResourceGuardProxyId +// note: this method should only be used for API response data and not user input +func ParseBackupResourceGuardProxyIDInsensitively(input string) (*BackupResourceGuardProxyId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupResourceGuardProxyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupResourceGuardProxyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupResourceGuardProxyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupResourceGuardProxyName, ok = input.Parsed["backupResourceGuardProxyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupResourceGuardProxyName", input) + } + + return nil +} + +// ValidateBackupResourceGuardProxyID checks that 'input' can be parsed as a Backup Resource Guard Proxy ID +func ValidateBackupResourceGuardProxyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupResourceGuardProxyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupResourceGuardProxies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupResourceGuardProxyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupResourceGuardProxies", "backupResourceGuardProxies", "backupResourceGuardProxies"), + resourceids.UserSpecifiedSegment("backupResourceGuardProxyName", "backupResourceGuardProxyValue"), + } +} + +// String returns a human-readable description of this Backup Resource Guard Proxy ID +func (id BackupResourceGuardProxyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Resource Guard Proxy Name: %q", id.BackupResourceGuardProxyName), + } + return fmt.Sprintf("Backup Resource Guard Proxy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy_test.go new file mode 100644 index 00000000000..6ec2131c440 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/id_backupresourceguardproxy_test.go @@ -0,0 +1,327 @@ +package resourceguardproxy + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupResourceGuardProxyId{} + +func TestNewBackupResourceGuardProxyID(t *testing.T) { + id := NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupResourceGuardProxyName != "backupResourceGuardProxyValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupResourceGuardProxyName'", id.BackupResourceGuardProxyName, "backupResourceGuardProxyValue") + } +} + +func TestFormatBackupResourceGuardProxyID(t *testing.T) { + actual := NewBackupResourceGuardProxyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupResourceGuardProxyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupResourceGuardProxyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupResourceGuardProxyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupResourceGuardProxyName: "backupResourceGuardProxyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupResourceGuardProxyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupResourceGuardProxyName != v.Expected.BackupResourceGuardProxyName { + t.Fatalf("Expected %q but got %q for BackupResourceGuardProxyName", v.Expected.BackupResourceGuardProxyName, actual.BackupResourceGuardProxyName) + } + + } +} + +func TestParseBackupResourceGuardProxyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupResourceGuardProxyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupResourceGuardProxyName: "backupResourceGuardProxyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupResourceGuardProxies/backupResourceGuardProxyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYvAlUe", + Expected: &BackupResourceGuardProxyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupResourceGuardProxyName: "bAcKuPrEsOuRcEgUaRdPrOxYvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPrEsOuRcEgUaRdPrOxIeS/bAcKuPrEsOuRcEgUaRdPrOxYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupResourceGuardProxyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupResourceGuardProxyName != v.Expected.BackupResourceGuardProxyName { + t.Fatalf("Expected %q but got %q for BackupResourceGuardProxyName", v.Expected.BackupResourceGuardProxyName, actual.BackupResourceGuardProxyName) + } + + } +} + +func TestSegmentsForBackupResourceGuardProxyId(t *testing.T) { + segments := BackupResourceGuardProxyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupResourceGuardProxyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_delete_autorest.go new file mode 100644 index 00000000000..5bc566a1459 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_delete_autorest.go @@ -0,0 +1,66 @@ +package resourceguardproxy + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response +} + +// Delete ... +func (c ResourceGuardProxyClient) Delete(ctx context.Context, id BackupResourceGuardProxyId) (result DeleteOperationResponse, err error) { + req, err := c.preparerForDelete(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Delete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForDelete prepares the Delete request. +func (c ResourceGuardProxyClient) preparerForDelete(ctx context.Context, id BackupResourceGuardProxyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsDelete(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDelete handles the response to the Delete request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusNoContent, http.StatusOK), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_get_autorest.go new file mode 100644 index 00000000000..34cbc308b05 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_get_autorest.go @@ -0,0 +1,68 @@ +package resourceguardproxy + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *ResourceGuardProxyBaseResource +} + +// Get ... +func (c ResourceGuardProxyClient) Get(ctx context.Context, id BackupResourceGuardProxyId) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c ResourceGuardProxyClient) preparerForGet(ctx context.Context, id BackupResourceGuardProxyId) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_put_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_put_autorest.go new file mode 100644 index 00000000000..251f699920c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_put_autorest.go @@ -0,0 +1,69 @@ +package resourceguardproxy + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutOperationResponse struct { + HttpResponse *http.Response + Model *ResourceGuardProxyBaseResource +} + +// Put ... +func (c ResourceGuardProxyClient) Put(ctx context.Context, id BackupResourceGuardProxyId, input ResourceGuardProxyBaseResource) (result PutOperationResponse, err error) { + req, err := c.preparerForPut(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForPut(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "Put", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForPut prepares the Put request. +func (c ResourceGuardProxyClient) preparerForPut(ctx context.Context, id BackupResourceGuardProxyId, input ResourceGuardProxyBaseResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(id.ID()), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForPut handles the response to the Put request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForPut(resp *http.Response) (result PutOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_unlockdelete_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_unlockdelete_autorest.go new file mode 100644 index 00000000000..4ddf4864869 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/method_unlockdelete_autorest.go @@ -0,0 +1,70 @@ +package resourceguardproxy + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteOperationResponse struct { + HttpResponse *http.Response + Model *UnlockDeleteResponse +} + +// UnlockDelete ... +func (c ResourceGuardProxyClient) UnlockDelete(ctx context.Context, id BackupResourceGuardProxyId, input UnlockDeleteRequest) (result UnlockDeleteOperationResponse, err error) { + req, err := c.preparerForUnlockDelete(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForUnlockDelete(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "resourceguardproxy.ResourceGuardProxyClient", "UnlockDelete", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForUnlockDelete prepares the UnlockDelete request. +func (c ResourceGuardProxyClient) preparerForUnlockDelete(ctx context.Context, id BackupResourceGuardProxyId, input UnlockDeleteRequest) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/unlockDelete", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForUnlockDelete handles the response to the UnlockDelete request. The method always +// closes the http.Response Body. +func (c ResourceGuardProxyClient) responderForUnlockDelete(resp *http.Response) (result UnlockDeleteOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardoperationdetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardoperationdetail.go new file mode 100644 index 00000000000..a211e1f34bb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardoperationdetail.go @@ -0,0 +1,9 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardOperationDetail struct { + DefaultResourceRequest *string `json:"defaultResourceRequest,omitempty"` + VaultCriticalOperation *string `json:"vaultCriticalOperation,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybase.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybase.go new file mode 100644 index 00000000000..9e601e04d32 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybase.go @@ -0,0 +1,11 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBase struct { + Description *string `json:"description,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + ResourceGuardOperationDetails *[]ResourceGuardOperationDetail `json:"resourceGuardOperationDetails,omitempty"` + ResourceGuardResourceId string `json:"resourceGuardResourceId"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybaseresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybaseresource.go new file mode 100644 index 00000000000..f68fdd803b7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_resourceguardproxybaseresource.go @@ -0,0 +1,14 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceGuardProxyBaseResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceGuardProxyBase `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleterequest.go new file mode 100644 index 00000000000..5ed0ee6ebfe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleterequest.go @@ -0,0 +1,9 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteRequest struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` + ResourceToBeDeleted *string `json:"resourceToBeDeleted,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleteresponse.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleteresponse.go new file mode 100644 index 00000000000..6304a0fa5e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/model_unlockdeleteresponse.go @@ -0,0 +1,8 @@ +package resourceguardproxy + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlockDeleteResponse struct { + UnlockDeleteExpiryTime *string `json:"unlockDeleteExpiryTime,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/version.go new file mode 100644 index 00000000000..8a3e381c024 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/resourceguardproxy/version.go @@ -0,0 +1,12 @@ +package resourceguardproxy + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourceguardproxy/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/restores/README.md new file mode 100644 index 00000000000..5e7bc04ae81 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/restores` Documentation + +The `restores` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/restores" +``` + + +### Client Initialization + +```go +client := restores.NewRestoresClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RestoresClient.Trigger` + +```go +ctx := context.TODO() +id := restores.NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + +payload := restores.RestoreRequestResource{ + // ... +} + + +if err := client.TriggerThenPoll(ctx, id, payload, restores.DefaultTriggerOperationOptions()); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/client.go new file mode 100644 index 00000000000..3263d991a1e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/client.go @@ -0,0 +1,18 @@ +package restores + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoresClient struct { + Client autorest.Client + baseUri string +} + +func NewRestoresClientWithBaseURI(endpoint string) RestoresClient { + return RestoresClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/constants.go new file mode 100644 index 00000000000..2bbf6f4139c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/constants.go @@ -0,0 +1,272 @@ +package restores + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CopyOptions string + +const ( + CopyOptionsCreateCopy CopyOptions = "CreateCopy" + CopyOptionsFailOnConflict CopyOptions = "FailOnConflict" + CopyOptionsInvalid CopyOptions = "Invalid" + CopyOptionsOverwrite CopyOptions = "Overwrite" + CopyOptionsSkip CopyOptions = "Skip" +) + +func PossibleValuesForCopyOptions() []string { + return []string{ + string(CopyOptionsCreateCopy), + string(CopyOptionsFailOnConflict), + string(CopyOptionsInvalid), + string(CopyOptionsOverwrite), + string(CopyOptionsSkip), + } +} + +func parseCopyOptions(input string) (*CopyOptions, error) { + vals := map[string]CopyOptions{ + "createcopy": CopyOptionsCreateCopy, + "failonconflict": CopyOptionsFailOnConflict, + "invalid": CopyOptionsInvalid, + "overwrite": CopyOptionsOverwrite, + "skip": CopyOptionsSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CopyOptions(input) + return &out, nil +} + +type OverwriteOptions string + +const ( + OverwriteOptionsFailOnConflict OverwriteOptions = "FailOnConflict" + OverwriteOptionsInvalid OverwriteOptions = "Invalid" + OverwriteOptionsOverwrite OverwriteOptions = "Overwrite" +) + +func PossibleValuesForOverwriteOptions() []string { + return []string{ + string(OverwriteOptionsFailOnConflict), + string(OverwriteOptionsInvalid), + string(OverwriteOptionsOverwrite), + } +} + +func parseOverwriteOptions(input string) (*OverwriteOptions, error) { + vals := map[string]OverwriteOptions{ + "failonconflict": OverwriteOptionsFailOnConflict, + "invalid": OverwriteOptionsInvalid, + "overwrite": OverwriteOptionsOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverwriteOptions(input) + return &out, nil +} + +type RecoveryMode string + +const ( + RecoveryModeFileRecovery RecoveryMode = "FileRecovery" + RecoveryModeInvalid RecoveryMode = "Invalid" + RecoveryModeRecoveryUsingSnapshot RecoveryMode = "RecoveryUsingSnapshot" + RecoveryModeSnapshotAttach RecoveryMode = "SnapshotAttach" + RecoveryModeSnapshotAttachAndRecover RecoveryMode = "SnapshotAttachAndRecover" + RecoveryModeWorkloadRecovery RecoveryMode = "WorkloadRecovery" +) + +func PossibleValuesForRecoveryMode() []string { + return []string{ + string(RecoveryModeFileRecovery), + string(RecoveryModeInvalid), + string(RecoveryModeRecoveryUsingSnapshot), + string(RecoveryModeSnapshotAttach), + string(RecoveryModeSnapshotAttachAndRecover), + string(RecoveryModeWorkloadRecovery), + } +} + +func parseRecoveryMode(input string) (*RecoveryMode, error) { + vals := map[string]RecoveryMode{ + "filerecovery": RecoveryModeFileRecovery, + "invalid": RecoveryModeInvalid, + "recoveryusingsnapshot": RecoveryModeRecoveryUsingSnapshot, + "snapshotattach": RecoveryModeSnapshotAttach, + "snapshotattachandrecover": RecoveryModeSnapshotAttachAndRecover, + "workloadrecovery": RecoveryModeWorkloadRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryMode(input) + return &out, nil +} + +type RecoveryType string + +const ( + RecoveryTypeAlternateLocation RecoveryType = "AlternateLocation" + RecoveryTypeInvalid RecoveryType = "Invalid" + RecoveryTypeOffline RecoveryType = "Offline" + RecoveryTypeOriginalLocation RecoveryType = "OriginalLocation" + RecoveryTypeRestoreDisks RecoveryType = "RestoreDisks" +) + +func PossibleValuesForRecoveryType() []string { + return []string{ + string(RecoveryTypeAlternateLocation), + string(RecoveryTypeInvalid), + string(RecoveryTypeOffline), + string(RecoveryTypeOriginalLocation), + string(RecoveryTypeRestoreDisks), + } +} + +func parseRecoveryType(input string) (*RecoveryType, error) { + vals := map[string]RecoveryType{ + "alternatelocation": RecoveryTypeAlternateLocation, + "invalid": RecoveryTypeInvalid, + "offline": RecoveryTypeOffline, + "originallocation": RecoveryTypeOriginalLocation, + "restoredisks": RecoveryTypeRestoreDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} + +type RestoreRequestType string + +const ( + RestoreRequestTypeFullShareRestore RestoreRequestType = "FullShareRestore" + RestoreRequestTypeInvalid RestoreRequestType = "Invalid" + RestoreRequestTypeItemLevelRestore RestoreRequestType = "ItemLevelRestore" +) + +func PossibleValuesForRestoreRequestType() []string { + return []string{ + string(RestoreRequestTypeFullShareRestore), + string(RestoreRequestTypeInvalid), + string(RestoreRequestTypeItemLevelRestore), + } +} + +func parseRestoreRequestType(input string) (*RestoreRequestType, error) { + vals := map[string]RestoreRequestType{ + "fullsharerestore": RestoreRequestTypeFullShareRestore, + "invalid": RestoreRequestTypeInvalid, + "itemlevelrestore": RestoreRequestTypeItemLevelRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreRequestType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} + +type TargetDiskNetworkAccessOption string + +const ( + TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePrivateAccessForAllDisks" + TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePublicAccessForAllDisks" + TargetDiskNetworkAccessOptionSameAsOnSourceDisks TargetDiskNetworkAccessOption = "SameAsOnSourceDisks" +) + +func PossibleValuesForTargetDiskNetworkAccessOption() []string { + return []string{ + string(TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks), + string(TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks), + string(TargetDiskNetworkAccessOptionSameAsOnSourceDisks), + } +} + +func parseTargetDiskNetworkAccessOption(input string) (*TargetDiskNetworkAccessOption, error) { + vals := map[string]TargetDiskNetworkAccessOption{ + "enableprivateaccessforalldisks": TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks, + "enablepublicaccessforalldisks": TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks, + "sameasonsourcedisks": TargetDiskNetworkAccessOptionSameAsOnSourceDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetDiskNetworkAccessOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint.go new file mode 100644 index 00000000000..851a22454ae --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint.go @@ -0,0 +1,166 @@ +package restores + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecoveryPointId{}) +} + +var _ resourceids.ResourceId = &RecoveryPointId{} + +// RecoveryPointId is a struct representing the Resource ID for a Recovery Point +type RecoveryPointId struct { + SubscriptionId string + ResourceGroupName string + VaultName string + BackupFabricName string + ProtectionContainerName string + ProtectedItemName string + RecoveryPointId string +} + +// NewRecoveryPointID returns a new RecoveryPointId struct +func NewRecoveryPointID(subscriptionId string, resourceGroupName string, vaultName string, backupFabricName string, protectionContainerName string, protectedItemName string, recoveryPointId string) RecoveryPointId { + return RecoveryPointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + BackupFabricName: backupFabricName, + ProtectionContainerName: protectionContainerName, + ProtectedItemName: protectedItemName, + RecoveryPointId: recoveryPointId, + } +} + +// ParseRecoveryPointID parses 'input' into a RecoveryPointId +func ParseRecoveryPointID(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecoveryPointIDInsensitively parses 'input' case-insensitively into a RecoveryPointId +// note: this method should only be used for API response data and not user input +func ParseRecoveryPointIDInsensitively(input string) (*RecoveryPointId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecoveryPointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecoveryPointId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecoveryPointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + if id.BackupFabricName, ok = input.Parsed["backupFabricName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupFabricName", input) + } + + if id.ProtectionContainerName, ok = input.Parsed["protectionContainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectionContainerName", input) + } + + if id.ProtectedItemName, ok = input.Parsed["protectedItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "protectedItemName", input) + } + + if id.RecoveryPointId, ok = input.Parsed["recoveryPointId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recoveryPointId", input) + } + + return nil +} + +// ValidateRecoveryPointID checks that 'input' can be parsed as a Recovery Point ID +func ValidateRecoveryPointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecoveryPointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recovery Point ID +func (id RecoveryPointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s/backupFabrics/%s/protectionContainers/%s/protectedItems/%s/recoveryPoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName, id.BackupFabricName, id.ProtectionContainerName, id.ProtectedItemName, id.RecoveryPointId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recovery Point ID +func (id RecoveryPointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + resourceids.StaticSegment("staticBackupFabrics", "backupFabrics", "backupFabrics"), + resourceids.UserSpecifiedSegment("backupFabricName", "backupFabricValue"), + resourceids.StaticSegment("staticProtectionContainers", "protectionContainers", "protectionContainers"), + resourceids.UserSpecifiedSegment("protectionContainerName", "protectionContainerValue"), + resourceids.StaticSegment("staticProtectedItems", "protectedItems", "protectedItems"), + resourceids.UserSpecifiedSegment("protectedItemName", "protectedItemValue"), + resourceids.StaticSegment("staticRecoveryPoints", "recoveryPoints", "recoveryPoints"), + resourceids.UserSpecifiedSegment("recoveryPointId", "recoveryPointIdValue"), + } +} + +// String returns a human-readable description of this Recovery Point ID +func (id RecoveryPointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + fmt.Sprintf("Backup Fabric Name: %q", id.BackupFabricName), + fmt.Sprintf("Protection Container Name: %q", id.ProtectionContainerName), + fmt.Sprintf("Protected Item Name: %q", id.ProtectedItemName), + fmt.Sprintf("Recovery Point: %q", id.RecoveryPointId), + } + return fmt.Sprintf("Recovery Point (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint_test.go new file mode 100644 index 00000000000..443509d2e47 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/id_recoverypoint_test.go @@ -0,0 +1,462 @@ +package restores + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RecoveryPointId{} + +func TestNewRecoveryPointID(t *testing.T) { + id := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } + + if id.BackupFabricName != "backupFabricValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupFabricName'", id.BackupFabricName, "backupFabricValue") + } + + if id.ProtectionContainerName != "protectionContainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectionContainerName'", id.ProtectionContainerName, "protectionContainerValue") + } + + if id.ProtectedItemName != "protectedItemValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProtectedItemName'", id.ProtectedItemName, "protectedItemValue") + } + + if id.RecoveryPointId != "recoveryPointIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecoveryPointId'", id.RecoveryPointId, "recoveryPointIdValue") + } +} + +func TestFormatRecoveryPointID(t *testing.T) { + actual := NewRecoveryPointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue", "backupFabricValue", "protectionContainerValue", "protectedItemValue", "recoveryPointIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecoveryPointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestParseRecoveryPointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecoveryPointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + BackupFabricName: "backupFabricValue", + ProtectionContainerName: "protectionContainerValue", + ProtectedItemName: "protectedItemValue", + RecoveryPointId: "recoveryPointIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/backupFabrics/backupFabricValue/protectionContainers/protectionContainerValue/protectedItems/protectedItemValue/recoveryPoints/recoveryPointIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE", + Expected: &RecoveryPointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + BackupFabricName: "bAcKuPfAbRiCvAlUe", + ProtectionContainerName: "pRoTeCtIoNcOnTaInErVaLuE", + ProtectedItemName: "pRoTeCtEdItEmVaLuE", + RecoveryPointId: "rEcOvErYpOiNtIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/bAcKuPfAbRiCs/bAcKuPfAbRiCvAlUe/pRoTeCtIoNcOnTaInErS/pRoTeCtIoNcOnTaInErVaLuE/pRoTeCtEdItEmS/pRoTeCtEdItEmVaLuE/rEcOvErYpOiNtS/rEcOvErYpOiNtIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecoveryPointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + if actual.BackupFabricName != v.Expected.BackupFabricName { + t.Fatalf("Expected %q but got %q for BackupFabricName", v.Expected.BackupFabricName, actual.BackupFabricName) + } + + if actual.ProtectionContainerName != v.Expected.ProtectionContainerName { + t.Fatalf("Expected %q but got %q for ProtectionContainerName", v.Expected.ProtectionContainerName, actual.ProtectionContainerName) + } + + if actual.ProtectedItemName != v.Expected.ProtectedItemName { + t.Fatalf("Expected %q but got %q for ProtectedItemName", v.Expected.ProtectedItemName, actual.ProtectedItemName) + } + + if actual.RecoveryPointId != v.Expected.RecoveryPointId { + t.Fatalf("Expected %q but got %q for RecoveryPointId", v.Expected.RecoveryPointId, actual.RecoveryPointId) + } + + } +} + +func TestSegmentsForRecoveryPointId(t *testing.T) { + segments := RecoveryPointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecoveryPointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/method_trigger_autorest.go new file mode 100644 index 00000000000..a5e6e3ece2a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/method_trigger_autorest.go @@ -0,0 +1,108 @@ +package restores + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +type TriggerOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultTriggerOperationOptions() TriggerOperationOptions { + return TriggerOperationOptions{} +} + +func (o TriggerOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o TriggerOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Trigger ... +func (c RestoresClient) Trigger(ctx context.Context, id RecoveryPointId, input RestoreRequestResource, options TriggerOperationOptions) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "restores.RestoresClient", "Trigger", nil, "Failure preparing request") + return + } + + result, err = c.senderForTrigger(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "restores.RestoresClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// TriggerThenPoll performs Trigger then polls until it's completed +func (c RestoresClient) TriggerThenPoll(ctx context.Context, id RecoveryPointId, input RestoreRequestResource, options TriggerOperationOptions) error { + result, err := c.Trigger(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Trigger: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Trigger: %+v", err) + } + + return nil +} + +// preparerForTrigger prepares the Trigger request. +func (c RestoresClient) preparerForTrigger(ctx context.Context, id RecoveryPointId, input RestoreRequestResource, options TriggerOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/restore", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForTrigger sends the Trigger request. The method will close the +// http.Response Body if it receives an error. +func (c RestoresClient) senderForTrigger(ctx context.Context, req *http.Request) (future TriggerOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..40acdf5995f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azurefilesharerestorerequest.go @@ -0,0 +1,47 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureFileShareRestoreRequest{} + +type AzureFileShareRestoreRequest struct { + CopyOptions *CopyOptions `json:"copyOptions,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + RestoreFileSpecs *[]RestoreFileSpecs `json:"restoreFileSpecs,omitempty"` + RestoreRequestType *RestoreRequestType `json:"restoreRequestType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetDetails *TargetAFSRestoreInfo `json:"targetDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareRestoreRequest{} + +func (s AzureFileShareRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureFileShareRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..ee85da2f449 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,51 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadPointInTimeRestoreRequest{} + +type AzureWorkloadPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRestoreRequest{} + +func (s AzureWorkloadPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..9eba6b70c3a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadrestorerequest.go @@ -0,0 +1,50 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadRestoreRequest{} + +type AzureWorkloadRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadRestoreRequest{} + +func (s AzureWorkloadRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..3dbe408063d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,51 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..0a94947905f --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,52 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..3b698e8c8ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,50 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaRestoreRequest{} + +type AzureWorkloadSAPHanaRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreRequest{} + +func (s AzureWorkloadSAPHanaRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..ed5905b7426 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,51 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaRestoreWithRehydrateRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..30372856038 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,54 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreRequest{} + +type AzureWorkloadSQLPointInTimeRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..b90eb502474 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,55 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..4edba1b178b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,53 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLRestoreRequest{} + +type AzureWorkloadSQLRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreRequest{} + +func (s AzureWorkloadSQLRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..bb5c079ac11 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,54 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_encryptiondetails.go new file mode 100644 index 00000000000..59b1b6b4b01 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_encryptiondetails.go @@ -0,0 +1,12 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionDetails struct { + EncryptionEnabled *bool `json:"encryptionEnabled,omitempty"` + KekUrl *string `json:"kekUrl,omitempty"` + KekVaultId *string `json:"kekVaultId,omitempty"` + SecretKeyUrl *string `json:"secretKeyUrl,omitempty"` + SecretKeyVaultId *string `json:"secretKeyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_extendedlocation.go new file mode 100644 index 00000000000..379c8d626ce --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_extendedlocation.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..b5a69cd9395 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorerequest.go @@ -0,0 +1,66 @@ +package restores + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreRequest{} + +type IaasVMRestoreRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = IaasVMRestoreRequest{} + +func (s IaasVMRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreRequest: %+v", err) + } + decoded["objectType"] = "IaasVMRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..b9b3aa12ebd --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,67 @@ +package restores + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreWithRehydrationRequest{} + +type IaasVMRestoreWithRehydrationRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = IaasVMRestoreWithRehydrationRequest{} + +func (s IaasVMRestoreWithRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreWithRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + decoded["objectType"] = "IaasVMRestoreWithRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..a9c51c27edc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identitybasedrestoredetails.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityBasedRestoreDetails struct { + ObjectType *string `json:"objectType,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identityinfo.go new file mode 100644 index 00000000000..54e5f53f23c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_identityinfo.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityInfo struct { + IsSystemAssignedIdentity *bool `json:"isSystemAssignedIdentity,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..73a3eba8ff1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_recoverypointrehydrationinfo.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointRehydrationInfo struct { + RehydrationPriority *RehydrationPriority `json:"rehydrationPriority,omitempty"` + RehydrationRetentionDuration *string `json:"rehydrationRetentionDuration,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorefilespecs.go new file mode 100644 index 00000000000..717dcbaffd2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorefilespecs.go @@ -0,0 +1,10 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFileSpecs struct { + FileSpecType *string `json:"fileSpecType,omitempty"` + Path *string `json:"path,omitempty"` + TargetFolderPath *string `json:"targetFolderPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequest.go new file mode 100644 index 00000000000..099b65bab20 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequest.go @@ -0,0 +1,149 @@ +package restores + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequest interface { +} + +// RawRestoreRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRestoreRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRestoreRequestImplementation(input []byte) (RestoreRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RestoreRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareRestoreRequest") { + var out AzureFileShareRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRestoreRequest") { + var out AzureWorkloadPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRestoreRequest") { + var out AzureWorkloadRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreRequest") { + var out AzureWorkloadSAPHanaRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreRequest") { + var out AzureWorkloadSQLPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreRequest") { + var out AzureWorkloadSQLRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreRequest") { + var out IaasVMRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreWithRehydrationRequest") { + var out IaasVMRestoreWithRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreWithRehydrationRequest: %+v", err) + } + return out, nil + } + + out := RawRestoreRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequestresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequestresource.go new file mode 100644 index 00000000000..47ea43b2a9e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_restorerequestresource.go @@ -0,0 +1,50 @@ +package restores + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequestResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties RestoreRequest `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &RestoreRequestResource{} + +func (s *RestoreRequestResource) UnmarshalJSON(bytes []byte) error { + type alias RestoreRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into RestoreRequestResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling RestoreRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'RestoreRequestResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_securedvmdetails.go new file mode 100644 index 00000000000..f83115fc592 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_securedvmdetails.go @@ -0,0 +1,8 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuredVMDetails struct { + SecuredVMOsDiskEncryptionSetId *string `json:"securedVMOsDiskEncryptionSetId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..dcd5798e292 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_snapshotrestoreparameters.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreParameters struct { + LogPointInTimeForDBRecovery *string `json:"logPointInTimeForDBRecovery,omitempty"` + SkipAttachAndMount *bool `json:"skipAttachAndMount,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..6a51b7654a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_sqldatadirectorymapping.go @@ -0,0 +1,11 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectoryMapping struct { + MappingType *SQLDataDirectoryType `json:"mappingType,omitempty"` + SourceLogicalName *string `json:"sourceLogicalName,omitempty"` + SourcePath *string `json:"sourcePath,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..c87d917d3d7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetafsrestoreinfo.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetAFSRestoreInfo struct { + Name *string `json:"name,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..a4aef071ffb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetdisknetworkaccesssettings.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetDiskNetworkAccessSettings struct { + TargetDiskAccessId *string `json:"targetDiskAccessId,omitempty"` + TargetDiskNetworkAccessOption *TargetDiskNetworkAccessOption `json:"targetDiskNetworkAccessOption,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetrestoreinfo.go new file mode 100644 index 00000000000..84b61c24b37 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_targetrestoreinfo.go @@ -0,0 +1,11 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetRestoreInfo struct { + ContainerId *string `json:"containerId,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + OverwriteOption *OverwriteOptions `json:"overwriteOption,omitempty"` + TargetDirectoryForFileRestore *string `json:"targetDirectoryForFileRestore,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..af278e430c4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..0544cfe81fe --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package restores + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/restores/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/restores/version.go new file mode 100644 index 00000000000..3ea6c5071b1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/restores/version.go @@ -0,0 +1,12 @@ +package restores + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/restores/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/README.md new file mode 100644 index 00000000000..09a1af9f381 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/securitypins` Documentation + +The `securitypins` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/securitypins" +``` + + +### Client Initialization + +```go +client := securitypins.NewSecurityPINsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityPINsClient.Get` + +```go +ctx := context.TODO() +id := securitypins.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := securitypins.SecurityPinBase{ + // ... +} + + +read, err := client.Get(ctx, id, payload, securitypins.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/client.go new file mode 100644 index 00000000000..117208a5554 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/client.go @@ -0,0 +1,18 @@ +package securitypins + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPINsClient struct { + Client autorest.Client + baseUri string +} + +func NewSecurityPINsClientWithBaseURI(endpoint string) SecurityPINsClient { + return SecurityPINsClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault.go new file mode 100644 index 00000000000..5f9d860ae82 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault.go @@ -0,0 +1,130 @@ +package securitypins + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault_test.go new file mode 100644 index 00000000000..13faade3656 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/id_vault_test.go @@ -0,0 +1,282 @@ +package securitypins + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/method_get_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/method_get_autorest.go new file mode 100644 index 00000000000..7680900edb8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/method_get_autorest.go @@ -0,0 +1,99 @@ +package securitypins + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + Model *TokenInformation +} + +type GetOperationOptions struct { + XMsAuthorizationAuxiliary *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + if o.XMsAuthorizationAuxiliary != nil { + out["x-ms-authorization-auxiliary"] = *o.XMsAuthorizationAuxiliary + } + + return out +} + +func (o GetOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +// Get ... +func (c SecurityPINsClient) Get(ctx context.Context, id VaultId, input SecurityPinBase, options GetOperationOptions) (result GetOperationResponse, err error) { + req, err := c.preparerForGet(ctx, id, input, options) + if err != nil { + err = autorest.NewErrorWithError(err, "securitypins.SecurityPINsClient", "Get", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "securitypins.SecurityPINsClient", "Get", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForGet(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "securitypins.SecurityPINsClient", "Get", result.HttpResponse, "Failure responding to request") + return + } + + return +} + +// preparerForGet prepares the Get request. +func (c SecurityPINsClient) preparerForGet(ctx context.Context, id VaultId, input SecurityPinBase, options GetOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupSecurityPIN", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForGet handles the response to the Get request. The method always +// closes the http.Response Body. +func (c SecurityPINsClient) responderForGet(resp *http.Response) (result GetOperationResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result.Model), + autorest.ByClosing()) + result.HttpResponse = resp + + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_securitypinbase.go b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_securitypinbase.go new file mode 100644 index 00000000000..acc76db8d99 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_securitypinbase.go @@ -0,0 +1,8 @@ +package securitypins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPinBase struct { + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_tokeninformation.go b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_tokeninformation.go new file mode 100644 index 00000000000..cfebb48a56d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/model_tokeninformation.go @@ -0,0 +1,10 @@ +package securitypins + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TokenInformation struct { + ExpiryTimeInUtcTicks *int64 `json:"expiryTimeInUtcTicks,omitempty"` + SecurityPIN *string `json:"securityPIN,omitempty"` + Token *string `json:"token,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/version.go new file mode 100644 index 00000000000..43ad63f287d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/securitypins/version.go @@ -0,0 +1,12 @@ +package securitypins + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/securitypins/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/README.md new file mode 100644 index 00000000000..5b5ea9bdb4d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers` Documentation + +The `softdeletedcontainers` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers" +``` + + +### Client Initialization + +```go +client := softdeletedcontainers.NewSoftDeletedContainersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SoftDeletedContainersClient.DeletedProtectionContainersList` + +```go +ctx := context.TODO() +id := softdeletedcontainers.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +// alternatively `client.DeletedProtectionContainersList(ctx, id, softdeletedcontainers.DefaultDeletedProtectionContainersListOperationOptions())` can be used to do batched pagination +items, err := client.DeletedProtectionContainersListComplete(ctx, id, softdeletedcontainers.DefaultDeletedProtectionContainersListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/client.go new file mode 100644 index 00000000000..a671a0559b3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/client.go @@ -0,0 +1,18 @@ +package softdeletedcontainers + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SoftDeletedContainersClient struct { + Client autorest.Client + baseUri string +} + +func NewSoftDeletedContainersClientWithBaseURI(endpoint string) SoftDeletedContainersClient { + return SoftDeletedContainersClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/constants.go new file mode 100644 index 00000000000..66a7b8fc216 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/constants.go @@ -0,0 +1,330 @@ +package softdeletedcontainers + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AcquireStorageAccountLock string + +const ( + AcquireStorageAccountLockAcquire AcquireStorageAccountLock = "Acquire" + AcquireStorageAccountLockNotAcquire AcquireStorageAccountLock = "NotAcquire" +) + +func PossibleValuesForAcquireStorageAccountLock() []string { + return []string{ + string(AcquireStorageAccountLockAcquire), + string(AcquireStorageAccountLockNotAcquire), + } +} + +func parseAcquireStorageAccountLock(input string) (*AcquireStorageAccountLock, error) { + vals := map[string]AcquireStorageAccountLock{ + "acquire": AcquireStorageAccountLockAcquire, + "notacquire": AcquireStorageAccountLockNotAcquire, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AcquireStorageAccountLock(input) + return &out, nil +} + +type BackupItemType string + +const ( + BackupItemTypeAzureFileShare BackupItemType = "AzureFileShare" + BackupItemTypeAzureSqlDb BackupItemType = "AzureSqlDb" + BackupItemTypeClient BackupItemType = "Client" + BackupItemTypeExchange BackupItemType = "Exchange" + BackupItemTypeFileFolder BackupItemType = "FileFolder" + BackupItemTypeGenericDataSource BackupItemType = "GenericDataSource" + BackupItemTypeInvalid BackupItemType = "Invalid" + BackupItemTypeSAPAseDatabase BackupItemType = "SAPAseDatabase" + BackupItemTypeSAPHanaDBInstance BackupItemType = "SAPHanaDBInstance" + BackupItemTypeSAPHanaDatabase BackupItemType = "SAPHanaDatabase" + BackupItemTypeSQLDB BackupItemType = "SQLDB" + BackupItemTypeSQLDataBase BackupItemType = "SQLDataBase" + BackupItemTypeSharepoint BackupItemType = "Sharepoint" + BackupItemTypeSystemState BackupItemType = "SystemState" + BackupItemTypeVM BackupItemType = "VM" + BackupItemTypeVMwareVM BackupItemType = "VMwareVM" +) + +func PossibleValuesForBackupItemType() []string { + return []string{ + string(BackupItemTypeAzureFileShare), + string(BackupItemTypeAzureSqlDb), + string(BackupItemTypeClient), + string(BackupItemTypeExchange), + string(BackupItemTypeFileFolder), + string(BackupItemTypeGenericDataSource), + string(BackupItemTypeInvalid), + string(BackupItemTypeSAPAseDatabase), + string(BackupItemTypeSAPHanaDBInstance), + string(BackupItemTypeSAPHanaDatabase), + string(BackupItemTypeSQLDB), + string(BackupItemTypeSQLDataBase), + string(BackupItemTypeSharepoint), + string(BackupItemTypeSystemState), + string(BackupItemTypeVM), + string(BackupItemTypeVMwareVM), + } +} + +func parseBackupItemType(input string) (*BackupItemType, error) { + vals := map[string]BackupItemType{ + "azurefileshare": BackupItemTypeAzureFileShare, + "azuresqldb": BackupItemTypeAzureSqlDb, + "client": BackupItemTypeClient, + "exchange": BackupItemTypeExchange, + "filefolder": BackupItemTypeFileFolder, + "genericdatasource": BackupItemTypeGenericDataSource, + "invalid": BackupItemTypeInvalid, + "sapasedatabase": BackupItemTypeSAPAseDatabase, + "saphanadbinstance": BackupItemTypeSAPHanaDBInstance, + "saphanadatabase": BackupItemTypeSAPHanaDatabase, + "sqldb": BackupItemTypeSQLDB, + "sqldatabase": BackupItemTypeSQLDataBase, + "sharepoint": BackupItemTypeSharepoint, + "systemstate": BackupItemTypeSystemState, + "vm": BackupItemTypeVM, + "vmwarevm": BackupItemTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupItemType(input) + return &out, nil +} + +type BackupManagementType string + +const ( + BackupManagementTypeAzureBackupServer BackupManagementType = "AzureBackupServer" + BackupManagementTypeAzureIaasVM BackupManagementType = "AzureIaasVM" + BackupManagementTypeAzureSql BackupManagementType = "AzureSql" + BackupManagementTypeAzureStorage BackupManagementType = "AzureStorage" + BackupManagementTypeAzureWorkload BackupManagementType = "AzureWorkload" + BackupManagementTypeDPM BackupManagementType = "DPM" + BackupManagementTypeDefaultBackup BackupManagementType = "DefaultBackup" + BackupManagementTypeInvalid BackupManagementType = "Invalid" + BackupManagementTypeMAB BackupManagementType = "MAB" +) + +func PossibleValuesForBackupManagementType() []string { + return []string{ + string(BackupManagementTypeAzureBackupServer), + string(BackupManagementTypeAzureIaasVM), + string(BackupManagementTypeAzureSql), + string(BackupManagementTypeAzureStorage), + string(BackupManagementTypeAzureWorkload), + string(BackupManagementTypeDPM), + string(BackupManagementTypeDefaultBackup), + string(BackupManagementTypeInvalid), + string(BackupManagementTypeMAB), + } +} + +func parseBackupManagementType(input string) (*BackupManagementType, error) { + vals := map[string]BackupManagementType{ + "azurebackupserver": BackupManagementTypeAzureBackupServer, + "azureiaasvm": BackupManagementTypeAzureIaasVM, + "azuresql": BackupManagementTypeAzureSql, + "azurestorage": BackupManagementTypeAzureStorage, + "azureworkload": BackupManagementTypeAzureWorkload, + "dpm": BackupManagementTypeDPM, + "defaultbackup": BackupManagementTypeDefaultBackup, + "invalid": BackupManagementTypeInvalid, + "mab": BackupManagementTypeMAB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupManagementType(input) + return &out, nil +} + +type OperationType string + +const ( + OperationTypeInvalid OperationType = "Invalid" + OperationTypeRegister OperationType = "Register" + OperationTypeReregister OperationType = "Reregister" +) + +func PossibleValuesForOperationType() []string { + return []string{ + string(OperationTypeInvalid), + string(OperationTypeRegister), + string(OperationTypeReregister), + } +} + +func parseOperationType(input string) (*OperationType, error) { + vals := map[string]OperationType{ + "invalid": OperationTypeInvalid, + "register": OperationTypeRegister, + "reregister": OperationTypeReregister, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationType(input) + return &out, nil +} + +type ProtectableContainerType string + +const ( + ProtectableContainerTypeAzureBackupServerContainer ProtectableContainerType = "AzureBackupServerContainer" + ProtectableContainerTypeAzureSqlContainer ProtectableContainerType = "AzureSqlContainer" + ProtectableContainerTypeAzureWorkloadContainer ProtectableContainerType = "AzureWorkloadContainer" + ProtectableContainerTypeCluster ProtectableContainerType = "Cluster" + ProtectableContainerTypeDPMContainer ProtectableContainerType = "DPMContainer" + ProtectableContainerTypeGenericContainer ProtectableContainerType = "GenericContainer" + ProtectableContainerTypeIaasVMContainer ProtectableContainerType = "IaasVMContainer" + ProtectableContainerTypeIaasVMServiceContainer ProtectableContainerType = "IaasVMServiceContainer" + ProtectableContainerTypeInvalid ProtectableContainerType = "Invalid" + ProtectableContainerTypeMABContainer ProtectableContainerType = "MABContainer" + ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines ProtectableContainerType = "Microsoft.ClassicCompute/virtualMachines" + ProtectableContainerTypeMicrosoftPointComputeVirtualMachines ProtectableContainerType = "Microsoft.Compute/virtualMachines" + ProtectableContainerTypeSQLAGWorkLoadContainer ProtectableContainerType = "SQLAGWorkLoadContainer" + ProtectableContainerTypeStorageContainer ProtectableContainerType = "StorageContainer" + ProtectableContainerTypeUnknown ProtectableContainerType = "Unknown" + ProtectableContainerTypeVCenter ProtectableContainerType = "VCenter" + ProtectableContainerTypeVMAppContainer ProtectableContainerType = "VMAppContainer" + ProtectableContainerTypeWindows ProtectableContainerType = "Windows" +) + +func PossibleValuesForProtectableContainerType() []string { + return []string{ + string(ProtectableContainerTypeAzureBackupServerContainer), + string(ProtectableContainerTypeAzureSqlContainer), + string(ProtectableContainerTypeAzureWorkloadContainer), + string(ProtectableContainerTypeCluster), + string(ProtectableContainerTypeDPMContainer), + string(ProtectableContainerTypeGenericContainer), + string(ProtectableContainerTypeIaasVMContainer), + string(ProtectableContainerTypeIaasVMServiceContainer), + string(ProtectableContainerTypeInvalid), + string(ProtectableContainerTypeMABContainer), + string(ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines), + string(ProtectableContainerTypeMicrosoftPointComputeVirtualMachines), + string(ProtectableContainerTypeSQLAGWorkLoadContainer), + string(ProtectableContainerTypeStorageContainer), + string(ProtectableContainerTypeUnknown), + string(ProtectableContainerTypeVCenter), + string(ProtectableContainerTypeVMAppContainer), + string(ProtectableContainerTypeWindows), + } +} + +func parseProtectableContainerType(input string) (*ProtectableContainerType, error) { + vals := map[string]ProtectableContainerType{ + "azurebackupservercontainer": ProtectableContainerTypeAzureBackupServerContainer, + "azuresqlcontainer": ProtectableContainerTypeAzureSqlContainer, + "azureworkloadcontainer": ProtectableContainerTypeAzureWorkloadContainer, + "cluster": ProtectableContainerTypeCluster, + "dpmcontainer": ProtectableContainerTypeDPMContainer, + "genericcontainer": ProtectableContainerTypeGenericContainer, + "iaasvmcontainer": ProtectableContainerTypeIaasVMContainer, + "iaasvmservicecontainer": ProtectableContainerTypeIaasVMServiceContainer, + "invalid": ProtectableContainerTypeInvalid, + "mabcontainer": ProtectableContainerTypeMABContainer, + "microsoft.classiccompute/virtualmachines": ProtectableContainerTypeMicrosoftPointClassicComputeVirtualMachines, + "microsoft.compute/virtualmachines": ProtectableContainerTypeMicrosoftPointComputeVirtualMachines, + "sqlagworkloadcontainer": ProtectableContainerTypeSQLAGWorkLoadContainer, + "storagecontainer": ProtectableContainerTypeStorageContainer, + "unknown": ProtectableContainerTypeUnknown, + "vcenter": ProtectableContainerTypeVCenter, + "vmappcontainer": ProtectableContainerTypeVMAppContainer, + "windows": ProtectableContainerTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtectableContainerType(input) + return &out, nil +} + +type WorkloadType string + +const ( + WorkloadTypeAzureFileShare WorkloadType = "AzureFileShare" + WorkloadTypeAzureSqlDb WorkloadType = "AzureSqlDb" + WorkloadTypeClient WorkloadType = "Client" + WorkloadTypeExchange WorkloadType = "Exchange" + WorkloadTypeFileFolder WorkloadType = "FileFolder" + WorkloadTypeGenericDataSource WorkloadType = "GenericDataSource" + WorkloadTypeInvalid WorkloadType = "Invalid" + WorkloadTypeSAPAseDatabase WorkloadType = "SAPAseDatabase" + WorkloadTypeSAPHanaDBInstance WorkloadType = "SAPHanaDBInstance" + WorkloadTypeSAPHanaDatabase WorkloadType = "SAPHanaDatabase" + WorkloadTypeSQLDB WorkloadType = "SQLDB" + WorkloadTypeSQLDataBase WorkloadType = "SQLDataBase" + WorkloadTypeSharepoint WorkloadType = "Sharepoint" + WorkloadTypeSystemState WorkloadType = "SystemState" + WorkloadTypeVM WorkloadType = "VM" + WorkloadTypeVMwareVM WorkloadType = "VMwareVM" +) + +func PossibleValuesForWorkloadType() []string { + return []string{ + string(WorkloadTypeAzureFileShare), + string(WorkloadTypeAzureSqlDb), + string(WorkloadTypeClient), + string(WorkloadTypeExchange), + string(WorkloadTypeFileFolder), + string(WorkloadTypeGenericDataSource), + string(WorkloadTypeInvalid), + string(WorkloadTypeSAPAseDatabase), + string(WorkloadTypeSAPHanaDBInstance), + string(WorkloadTypeSAPHanaDatabase), + string(WorkloadTypeSQLDB), + string(WorkloadTypeSQLDataBase), + string(WorkloadTypeSharepoint), + string(WorkloadTypeSystemState), + string(WorkloadTypeVM), + string(WorkloadTypeVMwareVM), + } +} + +func parseWorkloadType(input string) (*WorkloadType, error) { + vals := map[string]WorkloadType{ + "azurefileshare": WorkloadTypeAzureFileShare, + "azuresqldb": WorkloadTypeAzureSqlDb, + "client": WorkloadTypeClient, + "exchange": WorkloadTypeExchange, + "filefolder": WorkloadTypeFileFolder, + "genericdatasource": WorkloadTypeGenericDataSource, + "invalid": WorkloadTypeInvalid, + "sapasedatabase": WorkloadTypeSAPAseDatabase, + "saphanadbinstance": WorkloadTypeSAPHanaDBInstance, + "saphanadatabase": WorkloadTypeSAPHanaDatabase, + "sqldb": WorkloadTypeSQLDB, + "sqldatabase": WorkloadTypeSQLDataBase, + "sharepoint": WorkloadTypeSharepoint, + "systemstate": WorkloadTypeSystemState, + "vm": WorkloadTypeVM, + "vmwarevm": WorkloadTypeVMwareVM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadType(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault.go new file mode 100644 index 00000000000..b9506bebfc1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault.go @@ -0,0 +1,130 @@ +package softdeletedcontainers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault_test.go new file mode 100644 index 00000000000..be6885444be --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/id_vault_test.go @@ -0,0 +1,282 @@ +package softdeletedcontainers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go new file mode 100644 index 00000000000..412ffcc44a7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/method_deletedprotectioncontainerslist_autorest.go @@ -0,0 +1,215 @@ +package softdeletedcontainers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedProtectionContainersListOperationResponse struct { + HttpResponse *http.Response + Model *[]ProtectionContainerResource + + nextLink *string + nextPageFunc func(ctx context.Context, nextLink string) (DeletedProtectionContainersListOperationResponse, error) +} + +type DeletedProtectionContainersListCompleteResult struct { + Items []ProtectionContainerResource +} + +func (r DeletedProtectionContainersListOperationResponse) HasMore() bool { + return r.nextLink != nil +} + +func (r DeletedProtectionContainersListOperationResponse) LoadMore(ctx context.Context) (resp DeletedProtectionContainersListOperationResponse, err error) { + if !r.HasMore() { + err = fmt.Errorf("no more pages returned") + return + } + return r.nextPageFunc(ctx, *r.nextLink) +} + +type DeletedProtectionContainersListOperationOptions struct { + Filter *string +} + +func DefaultDeletedProtectionContainersListOperationOptions() DeletedProtectionContainersListOperationOptions { + return DeletedProtectionContainersListOperationOptions{} +} + +func (o DeletedProtectionContainersListOperationOptions) toHeaders() map[string]interface{} { + out := make(map[string]interface{}) + + return out +} + +func (o DeletedProtectionContainersListOperationOptions) toQueryString() map[string]interface{} { + out := make(map[string]interface{}) + + if o.Filter != nil { + out["$filter"] = *o.Filter + } + + return out +} + +// DeletedProtectionContainersList ... +func (c SoftDeletedContainersClient) DeletedProtectionContainersList(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions) (resp DeletedProtectionContainersListOperationResponse, err error) { + req, err := c.preparerForDeletedProtectionContainersList(ctx, id, options) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", nil, "Failure preparing request") + return + } + + resp.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", resp.HttpResponse, "Failure sending request") + return + } + + resp, err = c.responderForDeletedProtectionContainersList(resp.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", resp.HttpResponse, "Failure responding to request") + return + } + return +} + +// preparerForDeletedProtectionContainersList prepares the DeletedProtectionContainersList request. +func (c SoftDeletedContainersClient) preparerForDeletedProtectionContainersList(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + for k, v := range options.toQueryString() { + queryParameters[k] = autorest.Encode("query", v) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithHeaders(options.toHeaders()), + autorest.WithPath(fmt.Sprintf("%s/backupDeletedProtectionContainers", id.ID())), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// preparerForDeletedProtectionContainersListWithNextLink prepares the DeletedProtectionContainersList request with the given nextLink token. +func (c SoftDeletedContainersClient) preparerForDeletedProtectionContainersListWithNextLink(ctx context.Context, nextLink string) (*http.Request, error) { + uri, err := url.Parse(nextLink) + if err != nil { + return nil, fmt.Errorf("parsing nextLink %q: %+v", nextLink, err) + } + queryParameters := map[string]interface{}{} + for k, v := range uri.Query() { + if len(v) == 0 { + continue + } + val := v[0] + val = autorest.Encode("query", val) + queryParameters[k] = val + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsGet(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(uri.Path), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// responderForDeletedProtectionContainersList handles the response to the DeletedProtectionContainersList request. The method always +// closes the http.Response Body. +func (c SoftDeletedContainersClient) responderForDeletedProtectionContainersList(resp *http.Response) (result DeletedProtectionContainersListOperationResponse, err error) { + type page struct { + Values []ProtectionContainerResource `json:"value"` + NextLink *string `json:"nextLink"` + } + var respObj page + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&respObj), + autorest.ByClosing()) + result.HttpResponse = resp + result.Model = &respObj.Values + result.nextLink = respObj.NextLink + if respObj.NextLink != nil { + result.nextPageFunc = func(ctx context.Context, nextLink string) (result DeletedProtectionContainersListOperationResponse, err error) { + req, err := c.preparerForDeletedProtectionContainersListWithNextLink(ctx, nextLink) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", nil, "Failure preparing request") + return + } + + result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", result.HttpResponse, "Failure sending request") + return + } + + result, err = c.responderForDeletedProtectionContainersList(result.HttpResponse) + if err != nil { + err = autorest.NewErrorWithError(err, "softdeletedcontainers.SoftDeletedContainersClient", "DeletedProtectionContainersList", result.HttpResponse, "Failure responding to request") + return + } + + return + } + } + return +} + +// DeletedProtectionContainersListComplete retrieves all of the results into a single object +func (c SoftDeletedContainersClient) DeletedProtectionContainersListComplete(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions) (DeletedProtectionContainersListCompleteResult, error) { + return c.DeletedProtectionContainersListCompleteMatchingPredicate(ctx, id, options, ProtectionContainerResourceOperationPredicate{}) +} + +// DeletedProtectionContainersListCompleteMatchingPredicate retrieves all of the results and then applied the predicate +func (c SoftDeletedContainersClient) DeletedProtectionContainersListCompleteMatchingPredicate(ctx context.Context, id VaultId, options DeletedProtectionContainersListOperationOptions, predicate ProtectionContainerResourceOperationPredicate) (resp DeletedProtectionContainersListCompleteResult, err error) { + items := make([]ProtectionContainerResource, 0) + + page, err := c.DeletedProtectionContainersList(ctx, id, options) + if err != nil { + err = fmt.Errorf("loading the initial page: %+v", err) + return + } + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + for page.HasMore() { + page, err = page.LoadMore(ctx) + if err != nil { + err = fmt.Errorf("loading the next page: %+v", err) + return + } + + if page.Model != nil { + for _, v := range *page.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + } + + out := DeletedProtectionContainersListCompleteResult{ + Items: items, + } + return out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurebackupservercontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurebackupservercontainer.go new file mode 100644 index 00000000000..573efc50aa1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurebackupservercontainer.go @@ -0,0 +1,53 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureBackupServerContainer{} + +type AzureBackupServerContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureBackupServerContainer{} + +func (s AzureBackupServerContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureBackupServerContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBackupServerContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBackupServerContainer: %+v", err) + } + decoded["containerType"] = "AzureBackupServerContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBackupServerContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go new file mode 100644 index 00000000000..1ffb8ed0e0d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaasclassiccomputevmcontainer.go @@ -0,0 +1,48 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSClassicComputeVMContainer{} + +type AzureIaaSClassicComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSClassicComputeVMContainer{} + +func (s AzureIaaSClassicComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSClassicComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.ClassicCompute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSClassicComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go new file mode 100644 index 00000000000..24481ef7aeb --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureiaascomputevmcontainer.go @@ -0,0 +1,48 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureIaaSComputeVMContainer{} + +type AzureIaaSComputeVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureIaaSComputeVMContainer{} + +func (s AzureIaaSComputeVMContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureIaaSComputeVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureIaaSComputeVMContainer: %+v", err) + } + decoded["containerType"] = "Microsoft.Compute/virtualMachines" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureIaaSComputeVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go new file mode 100644 index 00000000000..e359f39f411 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlagworkloadcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSQLAGWorkloadContainerProtectionContainer{} + +type AzureSQLAGWorkloadContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSQLAGWorkloadContainerProtectionContainer{} + +func (s AzureSQLAGWorkloadContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSQLAGWorkloadContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "SQLAGWorkLoadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlcontainer.go new file mode 100644 index 00000000000..e45c918f9ff --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azuresqlcontainer.go @@ -0,0 +1,45 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureSqlContainer{} + +type AzureSqlContainer struct { + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureSqlContainer{} + +func (s AzureSqlContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureSqlContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureSqlContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureSqlContainer: %+v", err) + } + decoded["containerType"] = "AzureSqlContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureSqlContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurestoragecontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurestoragecontainer.go new file mode 100644 index 00000000000..f0c84f07fa1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurestoragecontainer.go @@ -0,0 +1,50 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureStorageContainer{} + +type AzureStorageContainer struct { + AcquireStorageAccountLock *AcquireStorageAccountLock `json:"acquireStorageAccountLock,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountVersion *string `json:"storageAccountVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureStorageContainer{} + +func (s AzureStorageContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureStorageContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureStorageContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureStorageContainer: %+v", err) + } + decoded["containerType"] = "StorageContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureStorageContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go new file mode 100644 index 00000000000..19bc1ebe0f0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azurevmappcontainerprotectioncontainer.go @@ -0,0 +1,50 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureVMAppContainerProtectionContainer{} + +type AzureVMAppContainerProtectionContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureVMAppContainerProtectionContainer{} + +func (s AzureVMAppContainerProtectionContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureVMAppContainerProtectionContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + decoded["containerType"] = "VMAppContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureVMAppContainerProtectionContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainer.go new file mode 100644 index 00000000000..e89bdafedc4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainer.go @@ -0,0 +1,50 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = AzureWorkloadContainer{} + +type AzureWorkloadContainer struct { + ExtendedInfo *AzureWorkloadContainerExtendedInfo `json:"extendedInfo,omitempty"` + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + OperationType *OperationType `json:"operationType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + WorkloadType *WorkloadType `json:"workloadType,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadContainer{} + +func (s AzureWorkloadContainer) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadContainer: %+v", err) + } + decoded["containerType"] = "AzureWorkloadContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go new file mode 100644 index 00000000000..141007ebdda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_azureworkloadcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWorkloadContainerExtendedInfo struct { + HostServerName *string `json:"hostServerName,omitempty"` + InquiryInfo *InquiryInfo `json:"inquiryInfo,omitempty"` + NodesList *[]DistributedNodesInfo `json:"nodesList,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_containeridentityinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_containeridentityinfo.go new file mode 100644 index 00000000000..367cba6804a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_containeridentityinfo.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerIdentityInfo struct { + AadTenantId *string `json:"aadTenantId,omitempty"` + Audience *string `json:"audience,omitempty"` + ServicePrincipalClientId *string `json:"servicePrincipalClientId,omitempty"` + UniqueName *string `json:"uniqueName,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_distributednodesinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_distributednodesinfo.go new file mode 100644 index 00000000000..3e35634654c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_distributednodesinfo.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DistributedNodesInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + NodeName *string `json:"nodeName,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainer.go new file mode 100644 index 00000000000..349969c7db5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainer.go @@ -0,0 +1,53 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = DpmContainer{} + +type DpmContainer struct { + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerId *string `json:"containerId,omitempty"` + DpmAgentVersion *string `json:"dpmAgentVersion,omitempty"` + DpmServers *[]string `json:"dpmServers,omitempty"` + ExtendedInfo *DPMContainerExtendedInfo `json:"extendedInfo,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + ProtectionStatus *string `json:"protectionStatus,omitempty"` + UpgradeAvailable *bool `json:"upgradeAvailable,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = DpmContainer{} + +func (s DpmContainer) MarshalJSON() ([]byte, error) { + type wrapper DpmContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DpmContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DpmContainer: %+v", err) + } + decoded["containerType"] = "DPMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DpmContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go new file mode 100644 index 00000000000..c0f911a34b6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_dpmcontainerextendedinfo.go @@ -0,0 +1,26 @@ +package softdeletedcontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DPMContainerExtendedInfo struct { + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` +} + +func (o *DPMContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DPMContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_errordetail.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_errordetail.go new file mode 100644 index 00000000000..b76617c0e57 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_errordetail.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainer.go new file mode 100644 index 00000000000..c5e6d8bd349 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainer.go @@ -0,0 +1,47 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = GenericContainer{} + +type GenericContainer struct { + ExtendedInformation *GenericContainerExtendedInfo `json:"extendedInformation,omitempty"` + FabricName *string `json:"fabricName,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = GenericContainer{} + +func (s GenericContainer) MarshalJSON() ([]byte, error) { + type wrapper GenericContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GenericContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GenericContainer: %+v", err) + } + decoded["containerType"] = "GenericContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GenericContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainerextendedinfo.go new file mode 100644 index 00000000000..79e66b1ffda --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_genericcontainerextendedinfo.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenericContainerExtendedInfo struct { + ContainerIdentityInfo *ContainerIdentityInfo `json:"containerIdentityInfo,omitempty"` + RawCertData *string `json:"rawCertData,omitempty"` + ServiceEndpoints *map[string]string `json:"serviceEndpoints,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_iaasvmcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_iaasvmcontainer.go new file mode 100644 index 00000000000..b8f3da1ebe1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_iaasvmcontainer.go @@ -0,0 +1,48 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = IaaSVMContainer{} + +type IaaSVMContainer struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + VirtualMachineId *string `json:"virtualMachineId,omitempty"` + VirtualMachineVersion *string `json:"virtualMachineVersion,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = IaaSVMContainer{} + +func (s IaaSVMContainer) MarshalJSON() ([]byte, error) { + type wrapper IaaSVMContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaaSVMContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaaSVMContainer: %+v", err) + } + decoded["containerType"] = "IaasVMContainer" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaaSVMContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryinfo.go new file mode 100644 index 00000000000..c4d9f8360b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryinfo.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryInfo struct { + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + InquiryDetails *[]WorkloadInquiryDetails `json:"inquiryDetails,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryvalidation.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryvalidation.go new file mode 100644 index 00000000000..5d9553ccad7 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_inquiryvalidation.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InquiryValidation struct { + AdditionalDetail *string `json:"additionalDetail,omitempty"` + ErrorDetail *ErrorDetail `json:"errorDetail,omitempty"` + ProtectableItemCount *interface{} `json:"protectableItemCount,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainer.go new file mode 100644 index 00000000000..6a7fcdfdffa --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainer.go @@ -0,0 +1,52 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ProtectionContainer = MabContainer{} + +type MabContainer struct { + AgentVersion *string `json:"agentVersion,omitempty"` + CanReRegister *bool `json:"canReRegister,omitempty"` + ContainerHealthState *string `json:"containerHealthState,omitempty"` + ContainerId *int64 `json:"containerId,omitempty"` + ExtendedInfo *MabContainerExtendedInfo `json:"extendedInfo,omitempty"` + MabContainerHealthDetails *[]MABContainerHealthDetails `json:"mabContainerHealthDetails,omitempty"` + ProtectedItemCount *int64 `json:"protectedItemCount,omitempty"` + + // Fields inherited from ProtectionContainer + BackupManagementType *BackupManagementType `json:"backupManagementType,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HealthStatus *string `json:"healthStatus,omitempty"` + ProtectableObjectType *string `json:"protectableObjectType,omitempty"` + RegistrationStatus *string `json:"registrationStatus,omitempty"` +} + +var _ json.Marshaler = MabContainer{} + +func (s MabContainer) MarshalJSON() ([]byte, error) { + type wrapper MabContainer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MabContainer: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MabContainer: %+v", err) + } + decoded["containerType"] = "Windows" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MabContainer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerextendedinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerextendedinfo.go new file mode 100644 index 00000000000..a5bc672fcf2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerextendedinfo.go @@ -0,0 +1,30 @@ +package softdeletedcontainers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MabContainerExtendedInfo struct { + BackupItemType *BackupItemType `json:"backupItemType,omitempty"` + BackupItems *[]string `json:"backupItems,omitempty"` + LastBackupStatus *string `json:"lastBackupStatus,omitempty"` + LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"` + PolicyName *string `json:"policyName,omitempty"` +} + +func (o *MabContainerExtendedInfo) GetLastRefreshedAtAsTime() (*time.Time, error) { + if o.LastRefreshedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRefreshedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *MabContainerExtendedInfo) SetLastRefreshedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRefreshedAt = &formatted +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerhealthdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerhealthdetails.go new file mode 100644 index 00000000000..8e91b126cc6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_mabcontainerhealthdetails.go @@ -0,0 +1,11 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MABContainerHealthDetails struct { + Code *int64 `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Recommendations *[]string `json:"recommendations,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainer.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainer.go new file mode 100644 index 00000000000..46f032ed5da --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainer.go @@ -0,0 +1,141 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainer interface { +} + +// RawProtectionContainerImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawProtectionContainerImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalProtectionContainerImplementation(input []byte) (ProtectionContainer, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ProtectionContainer into map[string]interface: %+v", err) + } + + value, ok := temp["containerType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureBackupServerContainer") { + var out AzureBackupServerContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBackupServerContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.ClassicCompute/virtualMachines") { + var out AzureIaaSClassicComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSClassicComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Microsoft.Compute/virtualMachines") { + var out AzureIaaSComputeVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureIaaSComputeVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SQLAGWorkLoadContainer") { + var out AzureSQLAGWorkloadContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSQLAGWorkloadContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureSqlContainer") { + var out AzureSqlContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureSqlContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "StorageContainer") { + var out AzureStorageContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureStorageContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VMAppContainer") { + var out AzureVMAppContainerProtectionContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureVMAppContainerProtectionContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadContainer") { + var out AzureWorkloadContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DPMContainer") { + var out DpmContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DpmContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "GenericContainer") { + var out GenericContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GenericContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMContainer") { + var out IaaSVMContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaaSVMContainer: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Windows") { + var out MabContainer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MabContainer: %+v", err) + } + return out, nil + } + + out := RawProtectionContainerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainerresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainerresource.go new file mode 100644 index 00000000000..2d5ed02148a --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_protectioncontainerresource.go @@ -0,0 +1,50 @@ +package softdeletedcontainers + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResource struct { + ETag *string `json:"eTag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ProtectionContainer `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ProtectionContainerResource{} + +func (s *ProtectionContainerResource) UnmarshalJSON(bytes []byte) error { + type alias ProtectionContainerResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ProtectionContainerResource: %+v", err) + } + + s.ETag = decoded.ETag + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ProtectionContainerResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalProtectionContainerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ProtectionContainerResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_workloadinquirydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_workloadinquirydetails.go new file mode 100644 index 00000000000..ca519886a94 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/model_workloadinquirydetails.go @@ -0,0 +1,10 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkloadInquiryDetails struct { + InquiryValidation *InquiryValidation `json:"inquiryValidation,omitempty"` + ItemCount *int64 `json:"itemCount,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/predicates.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/predicates.go new file mode 100644 index 00000000000..65cbf0427e6 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/predicates.go @@ -0,0 +1,37 @@ +package softdeletedcontainers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtectionContainerResourceOperationPredicate struct { + ETag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ProtectionContainerResourceOperationPredicate) Matches(input ProtectionContainerResource) bool { + + if p.ETag != nil && (input.ETag == nil || *p.ETag != *input.ETag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/version.go new file mode 100644 index 00000000000..1f4d2ebca30 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/softdeletedcontainers/version.go @@ -0,0 +1,12 @@ +package softdeletedcontainers + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/softdeletedcontainers/%s", defaultApiVersion) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/README.md b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/README.md new file mode 100644 index 00000000000..0efe9c9a59e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation` Documentation + +The `validateoperation` SDK allows for interaction with the Azure Resource Manager Service `recoveryservicesbackup` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation" +``` + + +### Client Initialization + +```go +client := validateoperation.NewValidateOperationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ValidateOperationClient.Trigger` + +```go +ctx := context.TODO() +id := validateoperation.NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + +payload := validateoperation.ValidateOperationRequestResource{ + // ... +} + + +if err := client.TriggerThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/client.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/client.go new file mode 100644 index 00000000000..e729f452d88 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/client.go @@ -0,0 +1,18 @@ +package validateoperation + +import "github.com/Azure/go-autorest/autorest" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationClient struct { + Client autorest.Client + baseUri string +} + +func NewValidateOperationClientWithBaseURI(endpoint string) ValidateOperationClient { + return ValidateOperationClient{ + Client: autorest.NewClientWithUserAgent(userAgent()), + baseUri: endpoint, + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/constants.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/constants.go new file mode 100644 index 00000000000..1e9aaff03ed --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/constants.go @@ -0,0 +1,272 @@ +package validateoperation + +import "strings" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CopyOptions string + +const ( + CopyOptionsCreateCopy CopyOptions = "CreateCopy" + CopyOptionsFailOnConflict CopyOptions = "FailOnConflict" + CopyOptionsInvalid CopyOptions = "Invalid" + CopyOptionsOverwrite CopyOptions = "Overwrite" + CopyOptionsSkip CopyOptions = "Skip" +) + +func PossibleValuesForCopyOptions() []string { + return []string{ + string(CopyOptionsCreateCopy), + string(CopyOptionsFailOnConflict), + string(CopyOptionsInvalid), + string(CopyOptionsOverwrite), + string(CopyOptionsSkip), + } +} + +func parseCopyOptions(input string) (*CopyOptions, error) { + vals := map[string]CopyOptions{ + "createcopy": CopyOptionsCreateCopy, + "failonconflict": CopyOptionsFailOnConflict, + "invalid": CopyOptionsInvalid, + "overwrite": CopyOptionsOverwrite, + "skip": CopyOptionsSkip, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CopyOptions(input) + return &out, nil +} + +type OverwriteOptions string + +const ( + OverwriteOptionsFailOnConflict OverwriteOptions = "FailOnConflict" + OverwriteOptionsInvalid OverwriteOptions = "Invalid" + OverwriteOptionsOverwrite OverwriteOptions = "Overwrite" +) + +func PossibleValuesForOverwriteOptions() []string { + return []string{ + string(OverwriteOptionsFailOnConflict), + string(OverwriteOptionsInvalid), + string(OverwriteOptionsOverwrite), + } +} + +func parseOverwriteOptions(input string) (*OverwriteOptions, error) { + vals := map[string]OverwriteOptions{ + "failonconflict": OverwriteOptionsFailOnConflict, + "invalid": OverwriteOptionsInvalid, + "overwrite": OverwriteOptionsOverwrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverwriteOptions(input) + return &out, nil +} + +type RecoveryMode string + +const ( + RecoveryModeFileRecovery RecoveryMode = "FileRecovery" + RecoveryModeInvalid RecoveryMode = "Invalid" + RecoveryModeRecoveryUsingSnapshot RecoveryMode = "RecoveryUsingSnapshot" + RecoveryModeSnapshotAttach RecoveryMode = "SnapshotAttach" + RecoveryModeSnapshotAttachAndRecover RecoveryMode = "SnapshotAttachAndRecover" + RecoveryModeWorkloadRecovery RecoveryMode = "WorkloadRecovery" +) + +func PossibleValuesForRecoveryMode() []string { + return []string{ + string(RecoveryModeFileRecovery), + string(RecoveryModeInvalid), + string(RecoveryModeRecoveryUsingSnapshot), + string(RecoveryModeSnapshotAttach), + string(RecoveryModeSnapshotAttachAndRecover), + string(RecoveryModeWorkloadRecovery), + } +} + +func parseRecoveryMode(input string) (*RecoveryMode, error) { + vals := map[string]RecoveryMode{ + "filerecovery": RecoveryModeFileRecovery, + "invalid": RecoveryModeInvalid, + "recoveryusingsnapshot": RecoveryModeRecoveryUsingSnapshot, + "snapshotattach": RecoveryModeSnapshotAttach, + "snapshotattachandrecover": RecoveryModeSnapshotAttachAndRecover, + "workloadrecovery": RecoveryModeWorkloadRecovery, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryMode(input) + return &out, nil +} + +type RecoveryType string + +const ( + RecoveryTypeAlternateLocation RecoveryType = "AlternateLocation" + RecoveryTypeInvalid RecoveryType = "Invalid" + RecoveryTypeOffline RecoveryType = "Offline" + RecoveryTypeOriginalLocation RecoveryType = "OriginalLocation" + RecoveryTypeRestoreDisks RecoveryType = "RestoreDisks" +) + +func PossibleValuesForRecoveryType() []string { + return []string{ + string(RecoveryTypeAlternateLocation), + string(RecoveryTypeInvalid), + string(RecoveryTypeOffline), + string(RecoveryTypeOriginalLocation), + string(RecoveryTypeRestoreDisks), + } +} + +func parseRecoveryType(input string) (*RecoveryType, error) { + vals := map[string]RecoveryType{ + "alternatelocation": RecoveryTypeAlternateLocation, + "invalid": RecoveryTypeInvalid, + "offline": RecoveryTypeOffline, + "originallocation": RecoveryTypeOriginalLocation, + "restoredisks": RecoveryTypeRestoreDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecoveryType(input) + return &out, nil +} + +type RehydrationPriority string + +const ( + RehydrationPriorityHigh RehydrationPriority = "High" + RehydrationPriorityStandard RehydrationPriority = "Standard" +) + +func PossibleValuesForRehydrationPriority() []string { + return []string{ + string(RehydrationPriorityHigh), + string(RehydrationPriorityStandard), + } +} + +func parseRehydrationPriority(input string) (*RehydrationPriority, error) { + vals := map[string]RehydrationPriority{ + "high": RehydrationPriorityHigh, + "standard": RehydrationPriorityStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RehydrationPriority(input) + return &out, nil +} + +type RestoreRequestType string + +const ( + RestoreRequestTypeFullShareRestore RestoreRequestType = "FullShareRestore" + RestoreRequestTypeInvalid RestoreRequestType = "Invalid" + RestoreRequestTypeItemLevelRestore RestoreRequestType = "ItemLevelRestore" +) + +func PossibleValuesForRestoreRequestType() []string { + return []string{ + string(RestoreRequestTypeFullShareRestore), + string(RestoreRequestTypeInvalid), + string(RestoreRequestTypeItemLevelRestore), + } +} + +func parseRestoreRequestType(input string) (*RestoreRequestType, error) { + vals := map[string]RestoreRequestType{ + "fullsharerestore": RestoreRequestTypeFullShareRestore, + "invalid": RestoreRequestTypeInvalid, + "itemlevelrestore": RestoreRequestTypeItemLevelRestore, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestoreRequestType(input) + return &out, nil +} + +type SQLDataDirectoryType string + +const ( + SQLDataDirectoryTypeData SQLDataDirectoryType = "Data" + SQLDataDirectoryTypeInvalid SQLDataDirectoryType = "Invalid" + SQLDataDirectoryTypeLog SQLDataDirectoryType = "Log" +) + +func PossibleValuesForSQLDataDirectoryType() []string { + return []string{ + string(SQLDataDirectoryTypeData), + string(SQLDataDirectoryTypeInvalid), + string(SQLDataDirectoryTypeLog), + } +} + +func parseSQLDataDirectoryType(input string) (*SQLDataDirectoryType, error) { + vals := map[string]SQLDataDirectoryType{ + "data": SQLDataDirectoryTypeData, + "invalid": SQLDataDirectoryTypeInvalid, + "log": SQLDataDirectoryTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SQLDataDirectoryType(input) + return &out, nil +} + +type TargetDiskNetworkAccessOption string + +const ( + TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePrivateAccessForAllDisks" + TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks TargetDiskNetworkAccessOption = "EnablePublicAccessForAllDisks" + TargetDiskNetworkAccessOptionSameAsOnSourceDisks TargetDiskNetworkAccessOption = "SameAsOnSourceDisks" +) + +func PossibleValuesForTargetDiskNetworkAccessOption() []string { + return []string{ + string(TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks), + string(TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks), + string(TargetDiskNetworkAccessOptionSameAsOnSourceDisks), + } +} + +func parseTargetDiskNetworkAccessOption(input string) (*TargetDiskNetworkAccessOption, error) { + vals := map[string]TargetDiskNetworkAccessOption{ + "enableprivateaccessforalldisks": TargetDiskNetworkAccessOptionEnablePrivateAccessForAllDisks, + "enablepublicaccessforalldisks": TargetDiskNetworkAccessOptionEnablePublicAccessForAllDisks, + "sameasonsourcedisks": TargetDiskNetworkAccessOptionSameAsOnSourceDisks, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetDiskNetworkAccessOption(input) + return &out, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault.go new file mode 100644 index 00000000000..68ab98ce4de --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault.go @@ -0,0 +1,130 @@ +package validateoperation + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VaultId{}) +} + +var _ resourceids.ResourceId = &VaultId{} + +// VaultId is a struct representing the Resource ID for a Vault +type VaultId struct { + SubscriptionId string + ResourceGroupName string + VaultName string +} + +// NewVaultID returns a new VaultId struct +func NewVaultID(subscriptionId string, resourceGroupName string, vaultName string) VaultId { + return VaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VaultName: vaultName, + } +} + +// ParseVaultID parses 'input' into a VaultId +func ParseVaultID(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVaultIDInsensitively parses 'input' case-insensitively into a VaultId +// note: this method should only be used for API response data and not user input +func ParseVaultIDInsensitively(input string) (*VaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&VaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VaultName, ok = input.Parsed["vaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vaultName", input) + } + + return nil +} + +// ValidateVaultID checks that 'input' can be parsed as a Vault ID +func ValidateVaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vault ID +func (id VaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.RecoveryServices/vaults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VaultName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vault ID +func (id VaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftRecoveryServices", "Microsoft.RecoveryServices", "Microsoft.RecoveryServices"), + resourceids.StaticSegment("staticVaults", "vaults", "vaults"), + resourceids.UserSpecifiedSegment("vaultName", "vaultValue"), + } +} + +// String returns a human-readable description of this Vault ID +func (id VaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vault Name: %q", id.VaultName), + } + return fmt.Sprintf("Vault (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault_test.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault_test.go new file mode 100644 index 00000000000..8cea883e88e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/id_vault_test.go @@ -0,0 +1,282 @@ +package validateoperation + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VaultId{} + +func TestNewVaultID(t *testing.T) { + id := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VaultName != "vaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'VaultName'", id.VaultName, "vaultValue") + } +} + +func TestFormatVaultID(t *testing.T) { + actual := NewVaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestParseVaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VaultName: "vaultValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.RecoveryServices/vaults/vaultValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE", + Expected: &VaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VaultName: "vAuLtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.rEcOvErYsErViCeS/vAuLtS/vAuLtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VaultName != v.Expected.VaultName { + t.Fatalf("Expected %q but got %q for VaultName", v.Expected.VaultName, actual.VaultName) + } + + } +} + +func TestSegmentsForVaultId(t *testing.T) { + segments := VaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/method_trigger_autorest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/method_trigger_autorest.go new file mode 100644 index 00000000000..1255fd9377e --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/method_trigger_autorest.go @@ -0,0 +1,79 @@ +package validateoperation + +import ( + "context" + "fmt" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggerOperationResponse struct { + Poller polling.LongRunningPoller + HttpResponse *http.Response +} + +// Trigger ... +func (c ValidateOperationClient) Trigger(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (result TriggerOperationResponse, err error) { + req, err := c.preparerForTrigger(ctx, id, input) + if err != nil { + err = autorest.NewErrorWithError(err, "validateoperation.ValidateOperationClient", "Trigger", nil, "Failure preparing request") + return + } + + result, err = c.senderForTrigger(ctx, req) + if err != nil { + err = autorest.NewErrorWithError(err, "validateoperation.ValidateOperationClient", "Trigger", result.HttpResponse, "Failure sending request") + return + } + + return +} + +// TriggerThenPoll performs Trigger then polls until it's completed +func (c ValidateOperationClient) TriggerThenPoll(ctx context.Context, id VaultId, input ValidateOperationRequestResource) error { + result, err := c.Trigger(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Trigger: %+v", err) + } + + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Trigger: %+v", err) + } + + return nil +} + +// preparerForTrigger prepares the Trigger request. +func (c ValidateOperationClient) preparerForTrigger(ctx context.Context, id VaultId, input ValidateOperationRequestResource) (*http.Request, error) { + queryParameters := map[string]interface{}{ + "api-version": defaultApiVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(c.baseUri), + autorest.WithPath(fmt.Sprintf("%s/backupTriggerValidateOperation", id.ID())), + autorest.WithJSON(input), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// senderForTrigger sends the Trigger request. The method will close the +// http.Response Body if it receives an error. +func (c ValidateOperationClient) senderForTrigger(ctx context.Context, req *http.Request) (future TriggerOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) + return +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azurefilesharerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azurefilesharerestorerequest.go new file mode 100644 index 00000000000..59b55a316c0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azurefilesharerestorerequest.go @@ -0,0 +1,47 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureFileShareRestoreRequest{} + +type AzureFileShareRestoreRequest struct { + CopyOptions *CopyOptions `json:"copyOptions,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + RestoreFileSpecs *[]RestoreFileSpecs `json:"restoreFileSpecs,omitempty"` + RestoreRequestType *RestoreRequestType `json:"restoreRequestType,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetDetails *TargetAFSRestoreInfo `json:"targetDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureFileShareRestoreRequest{} + +func (s AzureFileShareRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureFileShareRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileShareRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileShareRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureFileShareRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileShareRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadpointintimerestorerequest.go new file mode 100644 index 00000000000..f21d434d5ef --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadpointintimerestorerequest.go @@ -0,0 +1,51 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadPointInTimeRestoreRequest{} + +type AzureWorkloadPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadPointInTimeRestoreRequest{} + +func (s AzureWorkloadPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadrestorerequest.go new file mode 100644 index 00000000000..785256f71e2 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadrestorerequest.go @@ -0,0 +1,50 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadRestoreRequest{} + +type AzureWorkloadRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadRestoreRequest{} + +func (s AzureWorkloadRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go new file mode 100644 index 00000000000..f5caa5525e8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorerequest.go @@ -0,0 +1,51 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..6075c6ac44b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanapointintimerestorewithrehydraterequest.go @@ -0,0 +1,52 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest struct { + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorerequest.go new file mode 100644 index 00000000000..e2bedba14ab --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorerequest.go @@ -0,0 +1,50 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaRestoreRequest{} + +type AzureWorkloadSAPHanaRestoreRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreRequest{} + +func (s AzureWorkloadSAPHanaRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go new file mode 100644 index 00000000000..ae5f5d5bd38 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsaphanarestorewithrehydraterequest.go @@ -0,0 +1,51 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +type AzureWorkloadSAPHanaRestoreWithRehydrateRequest struct { + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSAPHanaRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSAPHanaRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSAPHanaRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSAPHanaRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go new file mode 100644 index 00000000000..526c5a93887 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorerequest.go @@ -0,0 +1,54 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreRequest{} + +type AzureWorkloadSQLPointInTimeRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go new file mode 100644 index 00000000000..15112f53464 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlpointintimerestorewithrehydraterequest.go @@ -0,0 +1,55 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PointInTime *string `json:"pointInTime,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorerequest.go new file mode 100644 index 00000000000..60a30c6fe4d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorerequest.go @@ -0,0 +1,53 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLRestoreRequest{} + +type AzureWorkloadSQLRestoreRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreRequest{} + +func (s AzureWorkloadSQLRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go new file mode 100644 index 00000000000..5f0ebfef74b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_azureworkloadsqlrestorewithrehydraterequest.go @@ -0,0 +1,54 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +type AzureWorkloadSQLRestoreWithRehydrateRequest struct { + AlternateDirectoryPaths *[]SQLDataDirectoryMapping `json:"alternateDirectoryPaths,omitempty"` + IsNonRecoverable *bool `json:"isNonRecoverable,omitempty"` + PropertyBag *map[string]string `json:"propertyBag,omitempty"` + RecoveryMode *RecoveryMode `json:"recoveryMode,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + ShouldUseAlternateTargetLocation *bool `json:"shouldUseAlternateTargetLocation,omitempty"` + SnapshotRestoreParameters *SnapshotRestoreParameters `json:"snapshotRestoreParameters,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + TargetInfo *TargetRestoreInfo `json:"targetInfo,omitempty"` + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + UserAssignedManagedIdentityDetails *UserAssignedManagedIdentityDetails `json:"userAssignedManagedIdentityDetails,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = AzureWorkloadSQLRestoreWithRehydrateRequest{} + +func (s AzureWorkloadSQLRestoreWithRehydrateRequest) MarshalJSON() ([]byte, error) { + type wrapper AzureWorkloadSQLRestoreWithRehydrateRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + decoded["objectType"] = "AzureWorkloadSQLRestoreWithRehydrateRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_encryptiondetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_encryptiondetails.go new file mode 100644 index 00000000000..68be47387a8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_encryptiondetails.go @@ -0,0 +1,12 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionDetails struct { + EncryptionEnabled *bool `json:"encryptionEnabled,omitempty"` + KekUrl *string `json:"kekUrl,omitempty"` + KekVaultId *string `json:"kekVaultId,omitempty"` + SecretKeyUrl *string `json:"secretKeyUrl,omitempty"` + SecretKeyVaultId *string `json:"secretKeyVaultId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_extendedlocation.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_extendedlocation.go new file mode 100644 index 00000000000..608d19191a4 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_extendedlocation.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorerequest.go new file mode 100644 index 00000000000..390c5d82ec8 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorerequest.go @@ -0,0 +1,66 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreRequest{} + +type IaasVMRestoreRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = IaasVMRestoreRequest{} + +func (s IaasVMRestoreRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreRequest: %+v", err) + } + decoded["objectType"] = "IaasVMRestoreRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go new file mode 100644 index 00000000000..7980f7e5e5d --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_iaasvmrestorewithrehydrationrequest.go @@ -0,0 +1,67 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ RestoreRequest = IaasVMRestoreWithRehydrationRequest{} + +type IaasVMRestoreWithRehydrationRequest struct { + AffinityGroup *string `json:"affinityGroup,omitempty"` + CreateNewCloudService *bool `json:"createNewCloudService,omitempty"` + DiskEncryptionSetId *string `json:"diskEncryptionSetId,omitempty"` + EncryptionDetails *EncryptionDetails `json:"encryptionDetails,omitempty"` + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + IdentityBasedRestoreDetails *IdentityBasedRestoreDetails `json:"identityBasedRestoreDetails,omitempty"` + IdentityInfo *IdentityInfo `json:"identityInfo,omitempty"` + OriginalStorageAccountOption *bool `json:"originalStorageAccountOption,omitempty"` + RecoveryPointId *string `json:"recoveryPointId,omitempty"` + RecoveryPointRehydrationInfo *RecoveryPointRehydrationInfo `json:"recoveryPointRehydrationInfo,omitempty"` + RecoveryType *RecoveryType `json:"recoveryType,omitempty"` + Region *string `json:"region,omitempty"` + RestoreDiskLunList *[]int64 `json:"restoreDiskLunList,omitempty"` + RestoreWithManagedDisks *bool `json:"restoreWithManagedDisks,omitempty"` + SecuredVMDetails *SecuredVMDetails `json:"securedVMDetails,omitempty"` + SourceResourceId *string `json:"sourceResourceId,omitempty"` + StorageAccountId *string `json:"storageAccountId,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + TargetDiskNetworkAccessSettings *TargetDiskNetworkAccessSettings `json:"targetDiskNetworkAccessSettings,omitempty"` + TargetDomainNameId *string `json:"targetDomainNameId,omitempty"` + TargetResourceGroupId *string `json:"targetResourceGroupId,omitempty"` + TargetVirtualMachineId *string `json:"targetVirtualMachineId,omitempty"` + VirtualNetworkId *string `json:"virtualNetworkId,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` + + // Fields inherited from RestoreRequest + ResourceGuardOperationRequests *[]string `json:"resourceGuardOperationRequests,omitempty"` +} + +var _ json.Marshaler = IaasVMRestoreWithRehydrationRequest{} + +func (s IaasVMRestoreWithRehydrationRequest) MarshalJSON() ([]byte, error) { + type wrapper IaasVMRestoreWithRehydrationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + decoded["objectType"] = "IaasVMRestoreWithRehydrationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IaasVMRestoreWithRehydrationRequest: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identitybasedrestoredetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identitybasedrestoredetails.go new file mode 100644 index 00000000000..d804db396e3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identitybasedrestoredetails.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityBasedRestoreDetails struct { + ObjectType *string `json:"objectType,omitempty"` + TargetStorageAccountId *string `json:"targetStorageAccountId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identityinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identityinfo.go new file mode 100644 index 00000000000..71e633fc3ea --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_identityinfo.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityInfo struct { + IsSystemAssignedIdentity *bool `json:"isSystemAssignedIdentity,omitempty"` + ManagedIdentityResourceId *string `json:"managedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_recoverypointrehydrationinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_recoverypointrehydrationinfo.go new file mode 100644 index 00000000000..9f5b85e6ad0 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_recoverypointrehydrationinfo.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoveryPointRehydrationInfo struct { + RehydrationPriority *RehydrationPriority `json:"rehydrationPriority,omitempty"` + RehydrationRetentionDuration *string `json:"rehydrationRetentionDuration,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorefilespecs.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorefilespecs.go new file mode 100644 index 00000000000..f850cae1f62 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorefilespecs.go @@ -0,0 +1,10 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFileSpecs struct { + FileSpecType *string `json:"fileSpecType,omitempty"` + Path *string `json:"path,omitempty"` + TargetFolderPath *string `json:"targetFolderPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorerequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorerequest.go new file mode 100644 index 00000000000..f4c271d65e1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_restorerequest.go @@ -0,0 +1,149 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequest interface { +} + +// RawRestoreRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawRestoreRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalRestoreRequestImplementation(input []byte) (RestoreRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling RestoreRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AzureFileShareRestoreRequest") { + var out AzureFileShareRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileShareRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadPointInTimeRestoreRequest") { + var out AzureWorkloadPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadRestoreRequest") { + var out AzureWorkloadRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreRequest") { + var out AzureWorkloadSAPHanaRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSAPHanaRestoreWithRehydrateRequest") { + var out AzureWorkloadSAPHanaRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSAPHanaRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreRequest") { + var out AzureWorkloadSQLPointInTimeRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLPointInTimeRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreRequest") { + var out AzureWorkloadSQLRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureWorkloadSQLRestoreWithRehydrateRequest") { + var out AzureWorkloadSQLRestoreWithRehydrateRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureWorkloadSQLRestoreWithRehydrateRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreRequest") { + var out IaasVMRestoreRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "IaasVMRestoreWithRehydrationRequest") { + var out IaasVMRestoreWithRehydrationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IaasVMRestoreWithRehydrationRequest: %+v", err) + } + return out, nil + } + + out := RawRestoreRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_securedvmdetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_securedvmdetails.go new file mode 100644 index 00000000000..d6bbd38ddcc --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_securedvmdetails.go @@ -0,0 +1,8 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecuredVMDetails struct { + SecuredVMOsDiskEncryptionSetId *string `json:"securedVMOsDiskEncryptionSetId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_snapshotrestoreparameters.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_snapshotrestoreparameters.go new file mode 100644 index 00000000000..f9a96fc887b --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_snapshotrestoreparameters.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreParameters struct { + LogPointInTimeForDBRecovery *string `json:"logPointInTimeForDBRecovery,omitempty"` + SkipAttachAndMount *bool `json:"skipAttachAndMount,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_sqldatadirectorymapping.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_sqldatadirectorymapping.go new file mode 100644 index 00000000000..3d7ad759e25 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_sqldatadirectorymapping.go @@ -0,0 +1,11 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLDataDirectoryMapping struct { + MappingType *SQLDataDirectoryType `json:"mappingType,omitempty"` + SourceLogicalName *string `json:"sourceLogicalName,omitempty"` + SourcePath *string `json:"sourcePath,omitempty"` + TargetPath *string `json:"targetPath,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetafsrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetafsrestoreinfo.go new file mode 100644 index 00000000000..32d155ab051 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetafsrestoreinfo.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetAFSRestoreInfo struct { + Name *string `json:"name,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetdisknetworkaccesssettings.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetdisknetworkaccesssettings.go new file mode 100644 index 00000000000..9185ea14d0c --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetdisknetworkaccesssettings.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetDiskNetworkAccessSettings struct { + TargetDiskAccessId *string `json:"targetDiskAccessId,omitempty"` + TargetDiskNetworkAccessOption *TargetDiskNetworkAccessOption `json:"targetDiskNetworkAccessOption,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetrestoreinfo.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetrestoreinfo.go new file mode 100644 index 00000000000..03ec88a3e93 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_targetrestoreinfo.go @@ -0,0 +1,11 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TargetRestoreInfo struct { + ContainerId *string `json:"containerId,omitempty"` + DatabaseName *string `json:"databaseName,omitempty"` + OverwriteOption *OverwriteOptions `json:"overwriteOption,omitempty"` + TargetDirectoryForFileRestore *string `json:"targetDirectoryForFileRestore,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedidentityproperties.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedidentityproperties.go new file mode 100644 index 00000000000..572eae60d18 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedidentityproperties.go @@ -0,0 +1,9 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentityProperties struct { + ClientId *string `json:"clientId,omitempty"` + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedmanagedidentitydetails.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedmanagedidentitydetails.go new file mode 100644 index 00000000000..b8d3bbe00a1 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_userassignedmanagedidentitydetails.go @@ -0,0 +1,10 @@ +package validateoperation + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedManagedIdentityDetails struct { + IdentityArmId *string `json:"identityArmId,omitempty"` + IdentityName *string `json:"identityName,omitempty"` + UserAssignedIdentityProperties *UserAssignedIdentityProperties `json:"userAssignedIdentityProperties,omitempty"` +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go new file mode 100644 index 00000000000..01dc3ab0f73 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateiaasvmrestoreoperationrequest.go @@ -0,0 +1,60 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ValidateOperationRequest = ValidateIaasVMRestoreOperationRequest{} + +type ValidateIaasVMRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +var _ json.Marshaler = ValidateIaasVMRestoreOperationRequest{} + +func (s ValidateIaasVMRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateIaasVMRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + decoded["objectType"] = "ValidateIaasVMRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateIaasVMRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateIaasVMRestoreOperationRequest{} + +func (s *ValidateIaasVMRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateIaasVMRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := unmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateIaasVMRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequest.go new file mode 100644 index 00000000000..1874b1156b5 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequest.go @@ -0,0 +1,61 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationRequest interface { +} + +// RawValidateOperationRequestImpl is returned when the Discriminated Value +// doesn't match any of the defined types +// NOTE: this should only be used when a type isn't defined for this type of Object (as a workaround) +// and is used only for Deserialization (e.g. this cannot be used as a Request Payload). +type RawValidateOperationRequestImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalValidateOperationRequestImplementation(input []byte) (ValidateOperationRequest, error) { + if input == nil { + return nil, nil + } + + var temp map[string]interface{} + if err := json.Unmarshal(input, &temp); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateOperationRequest into map[string]interface: %+v", err) + } + + value, ok := temp["objectType"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "ValidateIaasVMRestoreOperationRequest") { + var out ValidateIaasVMRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateIaasVMRestoreOperationRequest: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ValidateRestoreOperationRequest") { + var out ValidateRestoreOperationRequest + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ValidateRestoreOperationRequest: %+v", err) + } + return out, nil + } + + out := RawValidateOperationRequestImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequestresource.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequestresource.go new file mode 100644 index 00000000000..d86e4783597 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validateoperationrequestresource.go @@ -0,0 +1,40 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationRequestResource struct { + Id string `json:"id"` + Properties ValidateOperationRequest `json:"properties"` +} + +var _ json.Unmarshaler = &ValidateOperationRequestResource{} + +func (s *ValidateOperationRequestResource) UnmarshalJSON(bytes []byte) error { + type alias ValidateOperationRequestResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ValidateOperationRequestResource: %+v", err) + } + + s.Id = decoded.Id + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateOperationRequestResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalValidateOperationRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ValidateOperationRequestResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validaterestoreoperationrequest.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validaterestoreoperationrequest.go new file mode 100644 index 00000000000..16aa0307fac --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/model_validaterestoreoperationrequest.go @@ -0,0 +1,60 @@ +package validateoperation + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ValidateOperationRequest = ValidateRestoreOperationRequest{} + +type ValidateRestoreOperationRequest struct { + RestoreRequest RestoreRequest `json:"restoreRequest"` + + // Fields inherited from ValidateOperationRequest +} + +var _ json.Marshaler = ValidateRestoreOperationRequest{} + +func (s ValidateRestoreOperationRequest) MarshalJSON() ([]byte, error) { + type wrapper ValidateRestoreOperationRequest + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ValidateRestoreOperationRequest: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ValidateRestoreOperationRequest: %+v", err) + } + decoded["objectType"] = "ValidateRestoreOperationRequest" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ValidateRestoreOperationRequest: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ValidateRestoreOperationRequest{} + +func (s *ValidateRestoreOperationRequest) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ValidateRestoreOperationRequest into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["restoreRequest"]; ok { + impl, err := unmarshalRestoreRequestImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'RestoreRequest' for 'ValidateRestoreOperationRequest': %+v", err) + } + s.RestoreRequest = impl + } + return nil +} diff --git a/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/version.go b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/version.go new file mode 100644 index 00000000000..c1aab434bd3 --- /dev/null +++ b/resource-manager/recoveryservicesbackup/2024-04-01/validateoperation/version.go @@ -0,0 +1,12 @@ +package validateoperation + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/validateoperation/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/README.md new file mode 100644 index 00000000000..002a3b01539 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/README.md @@ -0,0 +1,144 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/application` Documentation + +The `application` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/application" +``` + + +### Client Initialization + +```go +client := application.NewApplicationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +payload := application.ApplicationResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationClient.Delete` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationClient.Get` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +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: `ApplicationClient.List` + +```go +ctx := context.TODO() +id := application.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// 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: `ApplicationClient.ReadUpgrade` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +if err := client.ReadUpgradeThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationClient.ResumeUpgrade` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +payload := application.RuntimeResumeApplicationUpgradeParameters{ + // ... +} + + +if err := client.ResumeUpgradeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationClient.StartRollback` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +if err := client.StartRollbackThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationClient.Update` + +```go +ctx := context.TODO() +id := application.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +payload := application.ApplicationUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/client.go new file mode 100644 index 00000000000..c87320630e0 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/client.go @@ -0,0 +1,26 @@ +package application + +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 ApplicationClient struct { + Client *resourcemanager.Client +} + +func NewApplicationClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "application", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationClient: %+v", err) + } + + return &ApplicationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/constants.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/constants.go new file mode 100644 index 00000000000..5456526a734 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/constants.go @@ -0,0 +1,92 @@ +package application + +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 FailureAction string + +const ( + FailureActionManual FailureAction = "Manual" + FailureActionRollback FailureAction = "Rollback" +) + +func PossibleValuesForFailureAction() []string { + return []string{ + string(FailureActionManual), + string(FailureActionRollback), + } +} + +func (s *FailureAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailureAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailureAction(input string) (*FailureAction, error) { + vals := map[string]FailureAction{ + "manual": FailureActionManual, + "rollback": FailureActionRollback, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailureAction(input) + return &out, nil +} + +type RollingUpgradeMode string + +const ( + RollingUpgradeModeMonitored RollingUpgradeMode = "Monitored" + RollingUpgradeModeUnmonitoredAuto RollingUpgradeMode = "UnmonitoredAuto" +) + +func PossibleValuesForRollingUpgradeMode() []string { + return []string{ + string(RollingUpgradeModeMonitored), + string(RollingUpgradeModeUnmonitoredAuto), + } +} + +func (s *RollingUpgradeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRollingUpgradeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRollingUpgradeMode(input string) (*RollingUpgradeMode, error) { + vals := map[string]RollingUpgradeMode{ + "monitored": RollingUpgradeModeMonitored, + "unmonitoredauto": RollingUpgradeModeUnmonitoredAuto, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RollingUpgradeMode(input) + return &out, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application.go new file mode 100644 index 00000000000..b7564fa70e1 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application.go @@ -0,0 +1,139 @@ +package application + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationId{}) +} + +var _ resourceids.ResourceId = &ApplicationId{} + +// ApplicationId is a struct representing the Resource ID for a Application +type ApplicationId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + ApplicationName string +} + +// NewApplicationID returns a new ApplicationId struct +func NewApplicationID(subscriptionId string, resourceGroupName string, managedClusterName string, applicationName string) ApplicationId { + return ApplicationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + ApplicationName: applicationName, + } +} + +// ParseApplicationID parses 'input' into a ApplicationId +func ParseApplicationID(input string) (*ApplicationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationIDInsensitively parses 'input' case-insensitively into a ApplicationId +// note: this method should only be used for API response data and not user input +func ParseApplicationIDInsensitively(input string) (*ApplicationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.ApplicationName, ok = input.Parsed["applicationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationName", input) + } + + return nil +} + +// ValidateApplicationID checks that 'input' can be parsed as a Application ID +func ValidateApplicationID(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 := ParseApplicationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application ID +func (id ApplicationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/applications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.ApplicationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application ID +func (id ApplicationId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticApplications", "applications", "applications"), + resourceids.UserSpecifiedSegment("applicationName", "applicationValue"), + } +} + +// String returns a human-readable description of this Application ID +func (id ApplicationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + } + return fmt.Sprintf("Application (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application_test.go new file mode 100644 index 00000000000..111c21ef47c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_application_test.go @@ -0,0 +1,327 @@ +package application + +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 = &ApplicationId{} + +func TestNewApplicationID(t *testing.T) { + id := NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.ApplicationName != "applicationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationName'", id.ApplicationName, "applicationValue") + } +} + +func TestFormatApplicationID(t *testing.T) { + actual := NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + } +} + +func TestParseApplicationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + ApplicationName: "aPpLiCaTiOnVaLuE", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + } +} + +func TestSegmentsForApplicationId(t *testing.T) { + segments := ApplicationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationId 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/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster.go new file mode 100644 index 00000000000..b36cc1b41c6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster.go @@ -0,0 +1,130 @@ +package application + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterId{} + +// ManagedClusterId is a struct representing the Resource ID for a Managed Cluster +type ManagedClusterId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string +} + +// NewManagedClusterID returns a new ManagedClusterId struct +func NewManagedClusterID(subscriptionId string, resourceGroupName string, managedClusterName string) ManagedClusterId { + return ManagedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + } +} + +// ParseManagedClusterID parses 'input' into a ManagedClusterId +func ParseManagedClusterID(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterIDInsensitively parses 'input' case-insensitively into a ManagedClusterId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterIDInsensitively(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + return nil +} + +// ValidateManagedClusterID checks that 'input' can be parsed as a Managed Cluster ID +func ValidateManagedClusterID(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 := ParseManagedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster ID +func (id ManagedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster ID +func (id ManagedClusterId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + } +} + +// String returns a human-readable description of this Managed Cluster ID +func (id ManagedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + } + return fmt.Sprintf("Managed Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster_test.go new file mode 100644 index 00000000000..50009ee3c97 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/id_managedcluster_test.go @@ -0,0 +1,282 @@ +package application + +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 = &ManagedClusterId{} + +func TestNewManagedClusterID(t *testing.T) { + id := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } +} + +func TestFormatManagedClusterID(t *testing.T) { + actual := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestParseManagedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestSegmentsForManagedClusterId(t *testing.T) { + segments := ManagedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterId 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/servicefabricmanagedcluster/2024-04-01/application/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_createorupdate.go new file mode 100644 index 00000000000..a6c822e721e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_createorupdate.go @@ -0,0 +1,75 @@ +package application + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationResource +} + +// CreateOrUpdate ... +func (c ApplicationClient) CreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationId, input ApplicationResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_delete.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_delete.go new file mode 100644 index 00000000000..3770a2d10be --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_delete.go @@ -0,0 +1,71 @@ +package application + +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 ApplicationClient) Delete(ctx context.Context, id ApplicationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ApplicationClient) DeleteThenPoll(ctx context.Context, id ApplicationId) 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/servicefabricmanagedcluster/2024-04-01/application/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_get.go new file mode 100644 index 00000000000..6c37d8d5c58 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_get.go @@ -0,0 +1,54 @@ +package application + +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 *ApplicationResource +} + +// Get ... +func (c ApplicationClient) Get(ctx context.Context, id ApplicationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_list.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_list.go new file mode 100644 index 00000000000..6749eb898a8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_list.go @@ -0,0 +1,91 @@ +package application + +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 *[]ApplicationResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationResource +} + +// List ... +func (c ApplicationClient) List(ctx context.Context, id ManagedClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/applications", 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 *[]ApplicationResource `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 ApplicationClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationResource, 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/servicefabricmanagedcluster/2024-04-01/application/method_readupgrade.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_readupgrade.go new file mode 100644 index 00000000000..03c35de36b6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_readupgrade.go @@ -0,0 +1,69 @@ +package application + +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 ReadUpgradeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ReadUpgrade ... +func (c ApplicationClient) ReadUpgrade(ctx context.Context, id ApplicationId) (result ReadUpgradeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/fetchUpgradeStatus", 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 +} + +// ReadUpgradeThenPoll performs ReadUpgrade then polls until it's completed +func (c ApplicationClient) ReadUpgradeThenPoll(ctx context.Context, id ApplicationId) error { + result, err := c.ReadUpgrade(ctx, id) + if err != nil { + return fmt.Errorf("performing ReadUpgrade: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ReadUpgrade: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_resumeupgrade.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_resumeupgrade.go new file mode 100644 index 00000000000..1b85a4ba28c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_resumeupgrade.go @@ -0,0 +1,73 @@ +package application + +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 ResumeUpgradeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResumeUpgrade ... +func (c ApplicationClient) ResumeUpgrade(ctx context.Context, id ApplicationId, input RuntimeResumeApplicationUpgradeParameters) (result ResumeUpgradeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resumeUpgrade", 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 +} + +// ResumeUpgradeThenPoll performs ResumeUpgrade then polls until it's completed +func (c ApplicationClient) ResumeUpgradeThenPoll(ctx context.Context, id ApplicationId, input RuntimeResumeApplicationUpgradeParameters) error { + result, err := c.ResumeUpgrade(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResumeUpgrade: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResumeUpgrade: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_startrollback.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_startrollback.go new file mode 100644 index 00000000000..15b7605df8b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_startrollback.go @@ -0,0 +1,69 @@ +package application + +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 StartRollbackOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StartRollback ... +func (c ApplicationClient) StartRollback(ctx context.Context, id ApplicationId) (result StartRollbackOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startRollback", 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 +} + +// StartRollbackThenPoll performs StartRollback then polls until it's completed +func (c ApplicationClient) StartRollbackThenPoll(ctx context.Context, id ApplicationId) error { + result, err := c.StartRollback(ctx, id) + if err != nil { + return fmt.Errorf("performing StartRollback: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartRollback: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_update.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_update.go new file mode 100644 index 00000000000..290a1d5f26f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/method_update.go @@ -0,0 +1,58 @@ +package application + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationResource +} + +// Update ... +func (c ApplicationClient) Update(ctx context.Context, id ApplicationId, input ApplicationUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ApplicationResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationhealthpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationhealthpolicy.go new file mode 100644 index 00000000000..a93068ce723 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationhealthpolicy.go @@ -0,0 +1,11 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationHealthPolicy struct { + ConsiderWarningAsError bool `json:"considerWarningAsError"` + DefaultServiceTypeHealthPolicy *ServiceTypeHealthPolicy `json:"defaultServiceTypeHealthPolicy,omitempty"` + MaxPercentUnhealthyDeployedApplications int64 `json:"maxPercentUnhealthyDeployedApplications"` + ServiceTypeHealthPolicyMap *map[string]ServiceTypeHealthPolicy `json:"serviceTypeHealthPolicyMap,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresource.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresource.go new file mode 100644 index 00000000000..27565351e87 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresource.go @@ -0,0 +1,19 @@ +package application + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationResourceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresourceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresourceproperties.go new file mode 100644 index 00000000000..943c91727cd --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationresourceproperties.go @@ -0,0 +1,12 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationResourceProperties struct { + ManagedIdentities *[]ApplicationUserAssignedIdentity `json:"managedIdentities,omitempty"` + Parameters *map[string]string `json:"parameters,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + UpgradePolicy *ApplicationUpgradePolicy `json:"upgradePolicy,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupdateparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupdateparameters.go new file mode 100644 index 00000000000..5b61487e69f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupdateparameters.go @@ -0,0 +1,8 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationUpdateParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupgradepolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupgradepolicy.go new file mode 100644 index 00000000000..92ffad2adc4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationupgradepolicy.go @@ -0,0 +1,14 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationUpgradePolicy struct { + ApplicationHealthPolicy *ApplicationHealthPolicy `json:"applicationHealthPolicy,omitempty"` + ForceRestart *bool `json:"forceRestart,omitempty"` + InstanceCloseDelayDuration *int64 `json:"instanceCloseDelayDuration,omitempty"` + RecreateApplication *bool `json:"recreateApplication,omitempty"` + RollingUpgradeMonitoringPolicy *RollingUpgradeMonitoringPolicy `json:"rollingUpgradeMonitoringPolicy,omitempty"` + UpgradeMode *RollingUpgradeMode `json:"upgradeMode,omitempty"` + UpgradeReplicaSetCheckTimeout *int64 `json:"upgradeReplicaSetCheckTimeout,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationuserassignedidentity.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationuserassignedidentity.go new file mode 100644 index 00000000000..2c8d9e8bb98 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_applicationuserassignedidentity.go @@ -0,0 +1,9 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationUserAssignedIdentity struct { + Name string `json:"name"` + PrincipalId string `json:"principalId"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_rollingupgrademonitoringpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_rollingupgrademonitoringpolicy.go new file mode 100644 index 00000000000..0d6137c0071 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_rollingupgrademonitoringpolicy.go @@ -0,0 +1,13 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RollingUpgradeMonitoringPolicy struct { + FailureAction FailureAction `json:"failureAction"` + HealthCheckRetryTimeout string `json:"healthCheckRetryTimeout"` + HealthCheckStableDuration string `json:"healthCheckStableDuration"` + HealthCheckWaitDuration string `json:"healthCheckWaitDuration"` + UpgradeDomainTimeout string `json:"upgradeDomainTimeout"` + UpgradeTimeout string `json:"upgradeTimeout"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_runtimeresumeapplicationupgradeparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_runtimeresumeapplicationupgradeparameters.go new file mode 100644 index 00000000000..56521e75bd6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_runtimeresumeapplicationupgradeparameters.go @@ -0,0 +1,8 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RuntimeResumeApplicationUpgradeParameters struct { + UpgradeDomainName *string `json:"upgradeDomainName,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_servicetypehealthpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_servicetypehealthpolicy.go new file mode 100644 index 00000000000..975b669ebae --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_servicetypehealthpolicy.go @@ -0,0 +1,10 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTypeHealthPolicy struct { + MaxPercentUnhealthyPartitionsPerService int64 `json:"maxPercentUnhealthyPartitionsPerService"` + MaxPercentUnhealthyReplicasPerPartition int64 `json:"maxPercentUnhealthyReplicasPerPartition"` + MaxPercentUnhealthyServices int64 `json:"maxPercentUnhealthyServices"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_systemdata.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_systemdata.go new file mode 100644 index 00000000000..d508adc2ce2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/model_systemdata.go @@ -0,0 +1,43 @@ +package application + +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 SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *string `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *string `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/application/predicates.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/predicates.go new file mode 100644 index 00000000000..908be2b26b6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/predicates.go @@ -0,0 +1,32 @@ +package application + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ApplicationResourceOperationPredicate) Matches(input ApplicationResource) 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/servicefabricmanagedcluster/2024-04-01/application/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/version.go new file mode 100644 index 00000000000..957da3a5986 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/application/version.go @@ -0,0 +1,12 @@ +package application + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/application/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/README.md new file mode 100644 index 00000000000..7f801e9f4d5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype` Documentation + +The `applicationtype` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/applicationtype" +``` + + +### Client Initialization + +```go +client := applicationtype.NewApplicationTypeClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationTypeClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := applicationtype.NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue") + +payload := applicationtype.ApplicationTypeResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationTypeClient.Delete` + +```go +ctx := context.TODO() +id := applicationtype.NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationTypeClient.Get` + +```go +ctx := context.TODO() +id := applicationtype.NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue") + +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: `ApplicationTypeClient.List` + +```go +ctx := context.TODO() +id := applicationtype.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// 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: `ApplicationTypeClient.Update` + +```go +ctx := context.TODO() +id := applicationtype.NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue") + +payload := applicationtype.ApplicationTypeUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/client.go new file mode 100644 index 00000000000..08cc08e353a --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/client.go @@ -0,0 +1,26 @@ +package applicationtype + +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 ApplicationTypeClient struct { + Client *resourcemanager.Client +} + +func NewApplicationTypeClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "applicationtype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationTypeClient: %+v", err) + } + + return &ApplicationTypeClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype.go new file mode 100644 index 00000000000..6b53a94684c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype.go @@ -0,0 +1,139 @@ +package applicationtype + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationTypeId{}) +} + +var _ resourceids.ResourceId = &ApplicationTypeId{} + +// ApplicationTypeId is a struct representing the Resource ID for a Application Type +type ApplicationTypeId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + ApplicationTypeName string +} + +// NewApplicationTypeID returns a new ApplicationTypeId struct +func NewApplicationTypeID(subscriptionId string, resourceGroupName string, managedClusterName string, applicationTypeName string) ApplicationTypeId { + return ApplicationTypeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + ApplicationTypeName: applicationTypeName, + } +} + +// ParseApplicationTypeID parses 'input' into a ApplicationTypeId +func ParseApplicationTypeID(input string) (*ApplicationTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationTypeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationTypeIDInsensitively parses 'input' case-insensitively into a ApplicationTypeId +// note: this method should only be used for API response data and not user input +func ParseApplicationTypeIDInsensitively(input string) (*ApplicationTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationTypeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationTypeId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.ApplicationTypeName, ok = input.Parsed["applicationTypeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationTypeName", input) + } + + return nil +} + +// ValidateApplicationTypeID checks that 'input' can be parsed as a Application Type ID +func ValidateApplicationTypeID(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 := ParseApplicationTypeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Type ID +func (id ApplicationTypeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/applicationTypes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.ApplicationTypeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Type ID +func (id ApplicationTypeId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticApplicationTypes", "applicationTypes", "applicationTypes"), + resourceids.UserSpecifiedSegment("applicationTypeName", "applicationTypeValue"), + } +} + +// String returns a human-readable description of this Application Type ID +func (id ApplicationTypeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Application Type Name: %q", id.ApplicationTypeName), + } + return fmt.Sprintf("Application Type (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype_test.go new file mode 100644 index 00000000000..febaa0eaa97 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_applicationtype_test.go @@ -0,0 +1,327 @@ +package applicationtype + +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 = &ApplicationTypeId{} + +func TestNewApplicationTypeID(t *testing.T) { + id := NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.ApplicationTypeName != "applicationTypeValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationTypeName'", id.ApplicationTypeName, "applicationTypeValue") + } +} + +func TestFormatApplicationTypeID(t *testing.T) { + actual := NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationTypeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationTypeId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue", + Expected: &ApplicationTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationTypeName: "applicationTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationTypeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationTypeName != v.Expected.ApplicationTypeName { + t.Fatalf("Expected %q but got %q for ApplicationTypeName", v.Expected.ApplicationTypeName, actual.ApplicationTypeName) + } + + } +} + +func TestParseApplicationTypeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationTypeId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue", + Expected: &ApplicationTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationTypeName: "applicationTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE", + Expected: &ApplicationTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + ApplicationTypeName: "aPpLiCaTiOnTyPeVaLuE", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationTypeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationTypeName != v.Expected.ApplicationTypeName { + t.Fatalf("Expected %q but got %q for ApplicationTypeName", v.Expected.ApplicationTypeName, actual.ApplicationTypeName) + } + + } +} + +func TestSegmentsForApplicationTypeId(t *testing.T) { + segments := ApplicationTypeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationTypeId 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/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster.go new file mode 100644 index 00000000000..a654b81e564 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster.go @@ -0,0 +1,130 @@ +package applicationtype + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterId{} + +// ManagedClusterId is a struct representing the Resource ID for a Managed Cluster +type ManagedClusterId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string +} + +// NewManagedClusterID returns a new ManagedClusterId struct +func NewManagedClusterID(subscriptionId string, resourceGroupName string, managedClusterName string) ManagedClusterId { + return ManagedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + } +} + +// ParseManagedClusterID parses 'input' into a ManagedClusterId +func ParseManagedClusterID(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterIDInsensitively parses 'input' case-insensitively into a ManagedClusterId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterIDInsensitively(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + return nil +} + +// ValidateManagedClusterID checks that 'input' can be parsed as a Managed Cluster ID +func ValidateManagedClusterID(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 := ParseManagedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster ID +func (id ManagedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster ID +func (id ManagedClusterId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + } +} + +// String returns a human-readable description of this Managed Cluster ID +func (id ManagedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + } + return fmt.Sprintf("Managed Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster_test.go new file mode 100644 index 00000000000..da30a2c71be --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/id_managedcluster_test.go @@ -0,0 +1,282 @@ +package applicationtype + +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 = &ManagedClusterId{} + +func TestNewManagedClusterID(t *testing.T) { + id := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } +} + +func TestFormatManagedClusterID(t *testing.T) { + actual := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestParseManagedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestSegmentsForManagedClusterId(t *testing.T) { + segments := ManagedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterId 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/servicefabricmanagedcluster/2024-04-01/applicationtype/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_createorupdate.go new file mode 100644 index 00000000000..3c3f226984c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_createorupdate.go @@ -0,0 +1,58 @@ +package applicationtype + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationTypeResource +} + +// CreateOrUpdate ... +func (c ApplicationTypeClient) CreateOrUpdate(ctx context.Context, id ApplicationTypeId, input ApplicationTypeResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationTypeResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_delete.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_delete.go new file mode 100644 index 00000000000..6842c7382a7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_delete.go @@ -0,0 +1,71 @@ +package applicationtype + +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 ApplicationTypeClient) Delete(ctx context.Context, id ApplicationTypeId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ApplicationTypeClient) DeleteThenPoll(ctx context.Context, id ApplicationTypeId) 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/servicefabricmanagedcluster/2024-04-01/applicationtype/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_get.go new file mode 100644 index 00000000000..38112e40e44 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_get.go @@ -0,0 +1,54 @@ +package applicationtype + +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 *ApplicationTypeResource +} + +// Get ... +func (c ApplicationTypeClient) Get(ctx context.Context, id ApplicationTypeId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationTypeResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_list.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_list.go new file mode 100644 index 00000000000..57d64fde1a2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_list.go @@ -0,0 +1,91 @@ +package applicationtype + +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 *[]ApplicationTypeResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationTypeResource +} + +// List ... +func (c ApplicationTypeClient) List(ctx context.Context, id ManagedClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/applicationTypes", 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 *[]ApplicationTypeResource `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 ApplicationTypeClient) ListComplete(ctx context.Context, id ManagedClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationTypeResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationTypeClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate ApplicationTypeResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationTypeResource, 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/servicefabricmanagedcluster/2024-04-01/applicationtype/method_update.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_update.go new file mode 100644 index 00000000000..657c46f68a9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/method_update.go @@ -0,0 +1,58 @@ +package applicationtype + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationTypeResource +} + +// Update ... +func (c ApplicationTypeClient) Update(ctx context.Context, id ApplicationTypeId, input ApplicationTypeUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ApplicationTypeResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesource.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesource.go new file mode 100644 index 00000000000..8e126ba3bac --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesource.go @@ -0,0 +1,14 @@ +package applicationtype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeResource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationTypeResourceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesourceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesourceproperties.go new file mode 100644 index 00000000000..44ee3072f0d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtyperesourceproperties.go @@ -0,0 +1,8 @@ +package applicationtype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeResourceProperties struct { + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtypeupdateparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtypeupdateparameters.go new file mode 100644 index 00000000000..16e3bb40ce8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_applicationtypeupdateparameters.go @@ -0,0 +1,8 @@ +package applicationtype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeUpdateParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_systemdata.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_systemdata.go new file mode 100644 index 00000000000..fdb5779c387 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/model_systemdata.go @@ -0,0 +1,43 @@ +package applicationtype + +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 SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *string `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *string `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/predicates.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/predicates.go new file mode 100644 index 00000000000..e7ba87695dd --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/predicates.go @@ -0,0 +1,32 @@ +package applicationtype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ApplicationTypeResourceOperationPredicate) Matches(input ApplicationTypeResource) 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/servicefabricmanagedcluster/2024-04-01/applicationtype/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/version.go new file mode 100644 index 00000000000..b0782349b7b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype/version.go @@ -0,0 +1,12 @@ +package applicationtype + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/applicationtype/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/README.md new file mode 100644 index 00000000000..f631c30f355 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion` Documentation + +The `applicationtypeversion` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/applicationtypeversion" +``` + + +### Client Initialization + +```go +client := applicationtypeversion.NewApplicationTypeVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationTypeVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := applicationtypeversion.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue", "versionValue") + +payload := applicationtypeversion.ApplicationTypeVersionResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationTypeVersionClient.Delete` + +```go +ctx := context.TODO() +id := applicationtypeversion.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue", "versionValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationTypeVersionClient.Get` + +```go +ctx := context.TODO() +id := applicationtypeversion.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue", "versionValue") + +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: `ApplicationTypeVersionClient.ListByApplicationTypes` + +```go +ctx := context.TODO() +id := applicationtypeversion.NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue") + +// alternatively `client.ListByApplicationTypes(ctx, id)` can be used to do batched pagination +items, err := client.ListByApplicationTypesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationTypeVersionClient.Update` + +```go +ctx := context.TODO() +id := applicationtypeversion.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue", "versionValue") + +payload := applicationtypeversion.ApplicationTypeVersionUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/client.go new file mode 100644 index 00000000000..fbfd96f6ea3 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/client.go @@ -0,0 +1,26 @@ +package applicationtypeversion + +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 ApplicationTypeVersionClient struct { + Client *resourcemanager.Client +} + +func NewApplicationTypeVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationTypeVersionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "applicationtypeversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationTypeVersionClient: %+v", err) + } + + return &ApplicationTypeVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype.go new file mode 100644 index 00000000000..9ed6c9b5f69 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype.go @@ -0,0 +1,139 @@ +package applicationtypeversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationTypeId{}) +} + +var _ resourceids.ResourceId = &ApplicationTypeId{} + +// ApplicationTypeId is a struct representing the Resource ID for a Application Type +type ApplicationTypeId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + ApplicationTypeName string +} + +// NewApplicationTypeID returns a new ApplicationTypeId struct +func NewApplicationTypeID(subscriptionId string, resourceGroupName string, managedClusterName string, applicationTypeName string) ApplicationTypeId { + return ApplicationTypeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + ApplicationTypeName: applicationTypeName, + } +} + +// ParseApplicationTypeID parses 'input' into a ApplicationTypeId +func ParseApplicationTypeID(input string) (*ApplicationTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationTypeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationTypeIDInsensitively parses 'input' case-insensitively into a ApplicationTypeId +// note: this method should only be used for API response data and not user input +func ParseApplicationTypeIDInsensitively(input string) (*ApplicationTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationTypeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationTypeId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.ApplicationTypeName, ok = input.Parsed["applicationTypeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationTypeName", input) + } + + return nil +} + +// ValidateApplicationTypeID checks that 'input' can be parsed as a Application Type ID +func ValidateApplicationTypeID(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 := ParseApplicationTypeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Type ID +func (id ApplicationTypeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/applicationTypes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.ApplicationTypeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Type ID +func (id ApplicationTypeId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticApplicationTypes", "applicationTypes", "applicationTypes"), + resourceids.UserSpecifiedSegment("applicationTypeName", "applicationTypeValue"), + } +} + +// String returns a human-readable description of this Application Type ID +func (id ApplicationTypeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Application Type Name: %q", id.ApplicationTypeName), + } + return fmt.Sprintf("Application Type (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype_test.go new file mode 100644 index 00000000000..2361f0d13ae --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_applicationtype_test.go @@ -0,0 +1,327 @@ +package applicationtypeversion + +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 = &ApplicationTypeId{} + +func TestNewApplicationTypeID(t *testing.T) { + id := NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.ApplicationTypeName != "applicationTypeValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationTypeName'", id.ApplicationTypeName, "applicationTypeValue") + } +} + +func TestFormatApplicationTypeID(t *testing.T) { + actual := NewApplicationTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationTypeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationTypeId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue", + Expected: &ApplicationTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationTypeName: "applicationTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationTypeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationTypeName != v.Expected.ApplicationTypeName { + t.Fatalf("Expected %q but got %q for ApplicationTypeName", v.Expected.ApplicationTypeName, actual.ApplicationTypeName) + } + + } +} + +func TestParseApplicationTypeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationTypeId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue", + Expected: &ApplicationTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationTypeName: "applicationTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE", + Expected: &ApplicationTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + ApplicationTypeName: "aPpLiCaTiOnTyPeVaLuE", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationTypeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationTypeName != v.Expected.ApplicationTypeName { + t.Fatalf("Expected %q but got %q for ApplicationTypeName", v.Expected.ApplicationTypeName, actual.ApplicationTypeName) + } + + } +} + +func TestSegmentsForApplicationTypeId(t *testing.T) { + segments := ApplicationTypeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationTypeId 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/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version.go new file mode 100644 index 00000000000..f66f60d87f9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version.go @@ -0,0 +1,148 @@ +package applicationtypeversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VersionId{}) +} + +var _ resourceids.ResourceId = &VersionId{} + +// VersionId is a struct representing the Resource ID for a Version +type VersionId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + ApplicationTypeName string + VersionName string +} + +// NewVersionID returns a new VersionId struct +func NewVersionID(subscriptionId string, resourceGroupName string, managedClusterName string, applicationTypeName string, versionName string) VersionId { + return VersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + ApplicationTypeName: applicationTypeName, + VersionName: versionName, + } +} + +// ParseVersionID parses 'input' into a VersionId +func ParseVersionID(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVersionIDInsensitively parses 'input' case-insensitively into a VersionId +// note: this method should only be used for API response data and not user input +func ParseVersionIDInsensitively(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VersionId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.ApplicationTypeName, ok = input.Parsed["applicationTypeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationTypeName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateVersionID checks that 'input' can be parsed as a Version ID +func ValidateVersionID(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 := ParseVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Version ID +func (id VersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/applicationTypes/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.ApplicationTypeName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Version ID +func (id VersionId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticApplicationTypes", "applicationTypes", "applicationTypes"), + resourceids.UserSpecifiedSegment("applicationTypeName", "applicationTypeValue"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionValue"), + } +} + +// String returns a human-readable description of this Version ID +func (id VersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Application Type Name: %q", id.ApplicationTypeName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version_test.go new file mode 100644 index 00000000000..71b90538945 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/id_version_test.go @@ -0,0 +1,372 @@ +package applicationtypeversion + +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 = &VersionId{} + +func TestNewVersionID(t *testing.T) { + id := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue", "versionValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.ApplicationTypeName != "applicationTypeValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationTypeName'", id.ApplicationTypeName, "applicationTypeValue") + } + + if id.VersionName != "versionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionValue") + } +} + +func TestFormatVersionID(t *testing.T) { + actual := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationTypeValue", "versionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/versions/versionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/versions/versionValue", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationTypeName: "applicationTypeValue", + VersionName: "versionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/versions/versionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationTypeName != v.Expected.ApplicationTypeName { + t.Fatalf("Expected %q but got %q for ApplicationTypeName", v.Expected.ApplicationTypeName, actual.ApplicationTypeName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/versions/versionValue", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationTypeName: "applicationTypeValue", + VersionName: "versionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applicationTypes/applicationTypeValue/versions/versionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE/vErSiOnS/vErSiOnVaLuE", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + ApplicationTypeName: "aPpLiCaTiOnTyPeVaLuE", + VersionName: "vErSiOnVaLuE", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnTyPeS/aPpLiCaTiOnTyPeVaLuE/vErSiOnS/vErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationTypeName != v.Expected.ApplicationTypeName { + t.Fatalf("Expected %q but got %q for ApplicationTypeName", v.Expected.ApplicationTypeName, actual.ApplicationTypeName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForVersionId(t *testing.T) { + segments := VersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VersionId 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/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_createorupdate.go new file mode 100644 index 00000000000..4fbc5cb8b62 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_createorupdate.go @@ -0,0 +1,75 @@ +package applicationtypeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationTypeVersionResource +} + +// CreateOrUpdate ... +func (c ApplicationTypeVersionClient) CreateOrUpdate(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationTypeVersionClient) CreateOrUpdateThenPoll(ctx context.Context, id VersionId, input ApplicationTypeVersionResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_delete.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_delete.go new file mode 100644 index 00000000000..7ed42106836 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_delete.go @@ -0,0 +1,71 @@ +package applicationtypeversion + +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 ApplicationTypeVersionClient) Delete(ctx context.Context, id VersionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ApplicationTypeVersionClient) DeleteThenPoll(ctx context.Context, id VersionId) 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/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_get.go new file mode 100644 index 00000000000..94794cf4274 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_get.go @@ -0,0 +1,54 @@ +package applicationtypeversion + +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 *ApplicationTypeVersionResource +} + +// Get ... +func (c ApplicationTypeVersionClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationTypeVersionResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_listbyapplicationtypes.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_listbyapplicationtypes.go new file mode 100644 index 00000000000..d6cec2a7c45 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_listbyapplicationtypes.go @@ -0,0 +1,91 @@ +package applicationtypeversion + +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 ListByApplicationTypesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationTypeVersionResource +} + +type ListByApplicationTypesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationTypeVersionResource +} + +// ListByApplicationTypes ... +func (c ApplicationTypeVersionClient) ListByApplicationTypes(ctx context.Context, id ApplicationTypeId) (result ListByApplicationTypesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/versions", 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 *[]ApplicationTypeVersionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApplicationTypesComplete retrieves all the results into a single object +func (c ApplicationTypeVersionClient) ListByApplicationTypesComplete(ctx context.Context, id ApplicationTypeId) (ListByApplicationTypesCompleteResult, error) { + return c.ListByApplicationTypesCompleteMatchingPredicate(ctx, id, ApplicationTypeVersionResourceOperationPredicate{}) +} + +// ListByApplicationTypesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationTypeVersionClient) ListByApplicationTypesCompleteMatchingPredicate(ctx context.Context, id ApplicationTypeId, predicate ApplicationTypeVersionResourceOperationPredicate) (result ListByApplicationTypesCompleteResult, err error) { + items := make([]ApplicationTypeVersionResource, 0) + + resp, err := c.ListByApplicationTypes(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 = ListByApplicationTypesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_update.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_update.go new file mode 100644 index 00000000000..9d6b032e644 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/method_update.go @@ -0,0 +1,58 @@ +package applicationtypeversion + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationTypeVersionResource +} + +// Update ... +func (c ApplicationTypeVersionClient) Update(ctx context.Context, id VersionId, input ApplicationTypeVersionUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ApplicationTypeVersionResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresource.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresource.go new file mode 100644 index 00000000000..9b4e06ba815 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresource.go @@ -0,0 +1,14 @@ +package applicationtypeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeVersionResource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationTypeVersionResourceProperties `json:"properties,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresourceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresourceproperties.go new file mode 100644 index 00000000000..a69c5a1fcfa --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionresourceproperties.go @@ -0,0 +1,9 @@ +package applicationtypeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeVersionResourceProperties struct { + AppPackageUrl string `json:"appPackageUrl"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionupdateparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionupdateparameters.go new file mode 100644 index 00000000000..3ec62e1723e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_applicationtypeversionupdateparameters.go @@ -0,0 +1,8 @@ +package applicationtypeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeVersionUpdateParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_systemdata.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_systemdata.go new file mode 100644 index 00000000000..008ee515135 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/model_systemdata.go @@ -0,0 +1,43 @@ +package applicationtypeversion + +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 SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *string `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *string `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/predicates.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/predicates.go new file mode 100644 index 00000000000..a5ea562b77d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/predicates.go @@ -0,0 +1,32 @@ +package applicationtypeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeVersionResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ApplicationTypeVersionResourceOperationPredicate) Matches(input ApplicationTypeVersionResource) 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/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/version.go new file mode 100644 index 00000000000..7aaccc764b7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion/version.go @@ -0,0 +1,12 @@ +package applicationtypeversion + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/applicationtypeversion/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/client.go new file mode 100644 index 00000000000..54e3e17ce76 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/client.go @@ -0,0 +1,127 @@ +package v2024_04_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/servicefabricmanagedcluster/2024-04-01/application" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtype" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/applicationtypeversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/service" + "github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/services" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + Application *application.ApplicationClient + ApplicationType *applicationtype.ApplicationTypeClient + ApplicationTypeVersion *applicationtypeversion.ApplicationTypeVersionClient + ManagedApplyMaintenanceWindow *managedapplymaintenancewindow.ManagedApplyMaintenanceWindowClient + ManagedAzResiliencyStatus *managedazresiliencystatus.ManagedAzResiliencyStatusClient + ManagedCluster *managedcluster.ManagedClusterClient + ManagedClusterVersion *managedclusterversion.ManagedClusterVersionClient + ManagedMaintenanceWindowStatus *managedmaintenancewindowstatus.ManagedMaintenanceWindowStatusClient + ManagedVMSizes *managedvmsizes.ManagedVMSizesClient + NodeType *nodetype.NodeTypeClient + Service *service.ServiceClient + Services *services.ServicesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + applicationClient, err := application.NewApplicationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Application client: %+v", err) + } + configureFunc(applicationClient.Client) + + applicationTypeClient, err := applicationtype.NewApplicationTypeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationType client: %+v", err) + } + configureFunc(applicationTypeClient.Client) + + applicationTypeVersionClient, err := applicationtypeversion.NewApplicationTypeVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationTypeVersion client: %+v", err) + } + configureFunc(applicationTypeVersionClient.Client) + + managedApplyMaintenanceWindowClient, err := managedapplymaintenancewindow.NewManagedApplyMaintenanceWindowClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedApplyMaintenanceWindow client: %+v", err) + } + configureFunc(managedApplyMaintenanceWindowClient.Client) + + managedAzResiliencyStatusClient, err := managedazresiliencystatus.NewManagedAzResiliencyStatusClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedAzResiliencyStatus client: %+v", err) + } + configureFunc(managedAzResiliencyStatusClient.Client) + + managedClusterClient, err := managedcluster.NewManagedClusterClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedCluster client: %+v", err) + } + configureFunc(managedClusterClient.Client) + + managedClusterVersionClient, err := managedclusterversion.NewManagedClusterVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedClusterVersion client: %+v", err) + } + configureFunc(managedClusterVersionClient.Client) + + managedMaintenanceWindowStatusClient, err := managedmaintenancewindowstatus.NewManagedMaintenanceWindowStatusClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedMaintenanceWindowStatus client: %+v", err) + } + configureFunc(managedMaintenanceWindowStatusClient.Client) + + managedVMSizesClient, err := managedvmsizes.NewManagedVMSizesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedVMSizes client: %+v", err) + } + configureFunc(managedVMSizesClient.Client) + + nodeTypeClient, err := nodetype.NewNodeTypeClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NodeType client: %+v", err) + } + configureFunc(nodeTypeClient.Client) + + serviceClient, err := service.NewServiceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Service client: %+v", err) + } + configureFunc(serviceClient.Client) + + servicesClient, err := services.NewServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Services client: %+v", err) + } + configureFunc(servicesClient.Client) + + return &Client{ + Application: applicationClient, + ApplicationType: applicationTypeClient, + ApplicationTypeVersion: applicationTypeVersionClient, + ManagedApplyMaintenanceWindow: managedApplyMaintenanceWindowClient, + ManagedAzResiliencyStatus: managedAzResiliencyStatusClient, + ManagedCluster: managedClusterClient, + ManagedClusterVersion: managedClusterVersionClient, + ManagedMaintenanceWindowStatus: managedMaintenanceWindowStatusClient, + ManagedVMSizes: managedVMSizesClient, + NodeType: nodeTypeClient, + Service: serviceClient, + Services: servicesClient, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/client.go new file mode 100644 index 00000000000..e4d56cec321 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/client.go @@ -0,0 +1,26 @@ +package managedapplymaintenancewindow + +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 ManagedApplyMaintenanceWindowClient struct { + Client *resourcemanager.Client +} + +func NewManagedApplyMaintenanceWindowClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedApplyMaintenanceWindowClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedapplymaintenancewindow", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedApplyMaintenanceWindowClient: %+v", err) + } + + return &ManagedApplyMaintenanceWindowClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster.go new file mode 100644 index 00000000000..3e111ef23a3 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster.go @@ -0,0 +1,130 @@ +package managedapplymaintenancewindow + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterId{} + +// ManagedClusterId is a struct representing the Resource ID for a Managed Cluster +type ManagedClusterId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string +} + +// NewManagedClusterID returns a new ManagedClusterId struct +func NewManagedClusterID(subscriptionId string, resourceGroupName string, managedClusterName string) ManagedClusterId { + return ManagedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + } +} + +// ParseManagedClusterID parses 'input' into a ManagedClusterId +func ParseManagedClusterID(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterIDInsensitively parses 'input' case-insensitively into a ManagedClusterId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterIDInsensitively(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + return nil +} + +// ValidateManagedClusterID checks that 'input' can be parsed as a Managed Cluster ID +func ValidateManagedClusterID(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 := ParseManagedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster ID +func (id ManagedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster ID +func (id ManagedClusterId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + } +} + +// String returns a human-readable description of this Managed Cluster ID +func (id ManagedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + } + return fmt.Sprintf("Managed Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster_test.go new file mode 100644 index 00000000000..0ab476ff0da --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/id_managedcluster_test.go @@ -0,0 +1,282 @@ +package managedapplymaintenancewindow + +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 = &ManagedClusterId{} + +func TestNewManagedClusterID(t *testing.T) { + id := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } +} + +func TestFormatManagedClusterID(t *testing.T) { + actual := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestParseManagedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestSegmentsForManagedClusterId(t *testing.T) { + segments := ManagedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterId 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/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/method_post.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/method_post.go new file mode 100644 index 00000000000..7deec37876f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/method_post.go @@ -0,0 +1,47 @@ +package managedapplymaintenancewindow + +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 PostOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Post ... +func (c ManagedApplyMaintenanceWindowClient) Post(ctx context.Context, id ManagedClusterId) (result PostOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applyMaintenanceWindow", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/version.go new file mode 100644 index 00000000000..5584c5eeed5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedapplymaintenancewindow/version.go @@ -0,0 +1,12 @@ +package managedapplymaintenancewindow + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedapplymaintenancewindow/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/README.md new file mode 100644 index 00000000000..77e9d35cd50 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus` Documentation + +The `managedazresiliencystatus` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus" +``` + + +### Client Initialization + +```go +client := managedazresiliencystatus.NewManagedAzResiliencyStatusClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedAzResiliencyStatusClient.Get` + +```go +ctx := context.TODO() +id := managedazresiliencystatus.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/client.go new file mode 100644 index 00000000000..b24d135f910 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/client.go @@ -0,0 +1,26 @@ +package managedazresiliencystatus + +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 ManagedAzResiliencyStatusClient struct { + Client *resourcemanager.Client +} + +func NewManagedAzResiliencyStatusClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedAzResiliencyStatusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedazresiliencystatus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedAzResiliencyStatusClient: %+v", err) + } + + return &ManagedAzResiliencyStatusClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster.go new file mode 100644 index 00000000000..e7f04b5eeec --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster.go @@ -0,0 +1,130 @@ +package managedazresiliencystatus + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterId{} + +// ManagedClusterId is a struct representing the Resource ID for a Managed Cluster +type ManagedClusterId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string +} + +// NewManagedClusterID returns a new ManagedClusterId struct +func NewManagedClusterID(subscriptionId string, resourceGroupName string, managedClusterName string) ManagedClusterId { + return ManagedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + } +} + +// ParseManagedClusterID parses 'input' into a ManagedClusterId +func ParseManagedClusterID(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterIDInsensitively parses 'input' case-insensitively into a ManagedClusterId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterIDInsensitively(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + return nil +} + +// ValidateManagedClusterID checks that 'input' can be parsed as a Managed Cluster ID +func ValidateManagedClusterID(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 := ParseManagedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster ID +func (id ManagedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster ID +func (id ManagedClusterId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + } +} + +// String returns a human-readable description of this Managed Cluster ID +func (id ManagedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + } + return fmt.Sprintf("Managed Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster_test.go new file mode 100644 index 00000000000..69e4da8fda2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/id_managedcluster_test.go @@ -0,0 +1,282 @@ +package managedazresiliencystatus + +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 = &ManagedClusterId{} + +func TestNewManagedClusterID(t *testing.T) { + id := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } +} + +func TestFormatManagedClusterID(t *testing.T) { + actual := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestParseManagedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestSegmentsForManagedClusterId(t *testing.T) { + segments := ManagedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterId 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/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/method_get.go new file mode 100644 index 00000000000..62fe3999bee --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/method_get.go @@ -0,0 +1,55 @@ +package managedazresiliencystatus + +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 *ManagedAzResiliencyStatus +} + +// Get ... +func (c ManagedAzResiliencyStatusClient) Get(ctx context.Context, id ManagedClusterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getazresiliencystatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedAzResiliencyStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_managedazresiliencystatus.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_managedazresiliencystatus.go new file mode 100644 index 00000000000..b4fffb52726 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_managedazresiliencystatus.go @@ -0,0 +1,9 @@ +package managedazresiliencystatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedAzResiliencyStatus struct { + BaseResourceStatus *[]ResourceAzStatus `json:"baseResourceStatus,omitempty"` + IsClusterZoneResilient *bool `json:"isClusterZoneResilient,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_resourceazstatus.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_resourceazstatus.go new file mode 100644 index 00000000000..6ca5e9ecf1d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/model_resourceazstatus.go @@ -0,0 +1,11 @@ +package managedazresiliencystatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceAzStatus struct { + Details *string `json:"details,omitempty"` + IsZoneResilient *bool `json:"isZoneResilient,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/version.go new file mode 100644 index 00000000000..0f60a1fb5b1 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedazresiliencystatus/version.go @@ -0,0 +1,12 @@ +package managedazresiliencystatus + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedazresiliencystatus/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/README.md new file mode 100644 index 00000000000..afbf63a1181 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster` Documentation + +The `managedcluster` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/managedcluster" +``` + + +### Client Initialization + +```go +client := managedcluster.NewManagedClusterClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedClusterClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := managedcluster.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := managedcluster.ManagedCluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClusterClient.Delete` + +```go +ctx := context.TODO() +id := managedcluster.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClusterClient.Get` + +```go +ctx := context.TODO() +id := managedcluster.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +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: `ManagedClusterClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClusterClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClusterClient.Update` + +```go +ctx := context.TODO() +id := managedcluster.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := managedcluster.ManagedClusterUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/client.go new file mode 100644 index 00000000000..14c21d22764 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/client.go @@ -0,0 +1,26 @@ +package managedcluster + +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 ManagedClusterClient struct { + Client *resourcemanager.Client +} + +func NewManagedClusterClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClusterClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedcluster", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClusterClient: %+v", err) + } + + return &ManagedClusterClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/constants.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/constants.go new file mode 100644 index 00000000000..a631ecb9574 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/constants.go @@ -0,0 +1,644 @@ +package managedcluster + +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 Access string + +const ( + AccessAllow Access = "allow" + AccessDeny Access = "deny" +) + +func PossibleValuesForAccess() []string { + return []string{ + string(AccessAllow), + string(AccessDeny), + } +} + +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccess(input string) (*Access, error) { + vals := map[string]Access{ + "allow": AccessAllow, + "deny": AccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Access(input) + return &out, nil +} + +type ClusterState string + +const ( + ClusterStateBaselineUpgrade ClusterState = "BaselineUpgrade" + ClusterStateDeploying ClusterState = "Deploying" + ClusterStateReady ClusterState = "Ready" + ClusterStateUpgradeFailed ClusterState = "UpgradeFailed" + ClusterStateUpgrading ClusterState = "Upgrading" + ClusterStateWaitingForNodes ClusterState = "WaitingForNodes" +) + +func PossibleValuesForClusterState() []string { + return []string{ + string(ClusterStateBaselineUpgrade), + string(ClusterStateDeploying), + string(ClusterStateReady), + string(ClusterStateUpgradeFailed), + string(ClusterStateUpgrading), + string(ClusterStateWaitingForNodes), + } +} + +func (s *ClusterState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterState(input string) (*ClusterState, error) { + vals := map[string]ClusterState{ + "baselineupgrade": ClusterStateBaselineUpgrade, + "deploying": ClusterStateDeploying, + "ready": ClusterStateReady, + "upgradefailed": ClusterStateUpgradeFailed, + "upgrading": ClusterStateUpgrading, + "waitingfornodes": ClusterStateWaitingForNodes, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterState(input) + return &out, nil +} + +type ClusterUpgradeCadence string + +const ( + ClusterUpgradeCadenceWaveOne ClusterUpgradeCadence = "Wave1" + ClusterUpgradeCadenceWaveTwo ClusterUpgradeCadence = "Wave2" + ClusterUpgradeCadenceWaveZero ClusterUpgradeCadence = "Wave0" +) + +func PossibleValuesForClusterUpgradeCadence() []string { + return []string{ + string(ClusterUpgradeCadenceWaveOne), + string(ClusterUpgradeCadenceWaveTwo), + string(ClusterUpgradeCadenceWaveZero), + } +} + +func (s *ClusterUpgradeCadence) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterUpgradeCadence(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterUpgradeCadence(input string) (*ClusterUpgradeCadence, error) { + vals := map[string]ClusterUpgradeCadence{ + "wave1": ClusterUpgradeCadenceWaveOne, + "wave2": ClusterUpgradeCadenceWaveTwo, + "wave0": ClusterUpgradeCadenceWaveZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterUpgradeCadence(input) + return &out, nil +} + +type ClusterUpgradeMode string + +const ( + ClusterUpgradeModeAutomatic ClusterUpgradeMode = "Automatic" + ClusterUpgradeModeManual ClusterUpgradeMode = "Manual" +) + +func PossibleValuesForClusterUpgradeMode() []string { + return []string{ + string(ClusterUpgradeModeAutomatic), + string(ClusterUpgradeModeManual), + } +} + +func (s *ClusterUpgradeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterUpgradeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterUpgradeMode(input string) (*ClusterUpgradeMode, error) { + vals := map[string]ClusterUpgradeMode{ + "automatic": ClusterUpgradeModeAutomatic, + "manual": ClusterUpgradeModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterUpgradeMode(input) + return &out, nil +} + +type Direction string + +const ( + DirectionInbound Direction = "inbound" + DirectionOutbound Direction = "outbound" +) + +func PossibleValuesForDirection() []string { + return []string{ + string(DirectionInbound), + string(DirectionOutbound), + } +} + +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDirection(input string) (*Direction, error) { + vals := map[string]Direction{ + "inbound": DirectionInbound, + "outbound": DirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Direction(input) + return &out, nil +} + +type ManagedClusterAddOnFeature string + +const ( + ManagedClusterAddOnFeatureBackupRestoreService ManagedClusterAddOnFeature = "BackupRestoreService" + ManagedClusterAddOnFeatureDnsService ManagedClusterAddOnFeature = "DnsService" + ManagedClusterAddOnFeatureResourceMonitorService ManagedClusterAddOnFeature = "ResourceMonitorService" +) + +func PossibleValuesForManagedClusterAddOnFeature() []string { + return []string{ + string(ManagedClusterAddOnFeatureBackupRestoreService), + string(ManagedClusterAddOnFeatureDnsService), + string(ManagedClusterAddOnFeatureResourceMonitorService), + } +} + +func (s *ManagedClusterAddOnFeature) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterAddOnFeature(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterAddOnFeature(input string) (*ManagedClusterAddOnFeature, error) { + vals := map[string]ManagedClusterAddOnFeature{ + "backuprestoreservice": ManagedClusterAddOnFeatureBackupRestoreService, + "dnsservice": ManagedClusterAddOnFeatureDnsService, + "resourcemonitorservice": ManagedClusterAddOnFeatureResourceMonitorService, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterAddOnFeature(input) + return &out, nil +} + +type ManagedResourceProvisioningState string + +const ( + ManagedResourceProvisioningStateCanceled ManagedResourceProvisioningState = "Canceled" + ManagedResourceProvisioningStateCreated ManagedResourceProvisioningState = "Created" + ManagedResourceProvisioningStateCreating ManagedResourceProvisioningState = "Creating" + ManagedResourceProvisioningStateDeleted ManagedResourceProvisioningState = "Deleted" + ManagedResourceProvisioningStateDeleting ManagedResourceProvisioningState = "Deleting" + ManagedResourceProvisioningStateFailed ManagedResourceProvisioningState = "Failed" + ManagedResourceProvisioningStateNone ManagedResourceProvisioningState = "None" + ManagedResourceProvisioningStateOther ManagedResourceProvisioningState = "Other" + ManagedResourceProvisioningStateSucceeded ManagedResourceProvisioningState = "Succeeded" + ManagedResourceProvisioningStateUpdating ManagedResourceProvisioningState = "Updating" +) + +func PossibleValuesForManagedResourceProvisioningState() []string { + return []string{ + string(ManagedResourceProvisioningStateCanceled), + string(ManagedResourceProvisioningStateCreated), + string(ManagedResourceProvisioningStateCreating), + string(ManagedResourceProvisioningStateDeleted), + string(ManagedResourceProvisioningStateDeleting), + string(ManagedResourceProvisioningStateFailed), + string(ManagedResourceProvisioningStateNone), + string(ManagedResourceProvisioningStateOther), + string(ManagedResourceProvisioningStateSucceeded), + string(ManagedResourceProvisioningStateUpdating), + } +} + +func (s *ManagedResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedResourceProvisioningState(input string) (*ManagedResourceProvisioningState, error) { + vals := map[string]ManagedResourceProvisioningState{ + "canceled": ManagedResourceProvisioningStateCanceled, + "created": ManagedResourceProvisioningStateCreated, + "creating": ManagedResourceProvisioningStateCreating, + "deleted": ManagedResourceProvisioningStateDeleted, + "deleting": ManagedResourceProvisioningStateDeleting, + "failed": ManagedResourceProvisioningStateFailed, + "none": ManagedResourceProvisioningStateNone, + "other": ManagedResourceProvisioningStateOther, + "succeeded": ManagedResourceProvisioningStateSucceeded, + "updating": ManagedResourceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedResourceProvisioningState(input) + return &out, nil +} + +type NsgProtocol string + +const ( + NsgProtocolAh NsgProtocol = "ah" + NsgProtocolEsp NsgProtocol = "esp" + NsgProtocolHTTP NsgProtocol = "http" + NsgProtocolHTTPS NsgProtocol = "https" + NsgProtocolIcmp NsgProtocol = "icmp" + NsgProtocolTcp NsgProtocol = "tcp" + NsgProtocolUdp NsgProtocol = "udp" +) + +func PossibleValuesForNsgProtocol() []string { + return []string{ + string(NsgProtocolAh), + string(NsgProtocolEsp), + string(NsgProtocolHTTP), + string(NsgProtocolHTTPS), + string(NsgProtocolIcmp), + string(NsgProtocolTcp), + string(NsgProtocolUdp), + } +} + +func (s *NsgProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNsgProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNsgProtocol(input string) (*NsgProtocol, error) { + vals := map[string]NsgProtocol{ + "ah": NsgProtocolAh, + "esp": NsgProtocolEsp, + "http": NsgProtocolHTTP, + "https": NsgProtocolHTTPS, + "icmp": NsgProtocolIcmp, + "tcp": NsgProtocolTcp, + "udp": NsgProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NsgProtocol(input) + return &out, nil +} + +type PrivateEndpointNetworkPolicies string + +const ( + PrivateEndpointNetworkPoliciesDisabled PrivateEndpointNetworkPolicies = "disabled" + PrivateEndpointNetworkPoliciesEnabled PrivateEndpointNetworkPolicies = "enabled" +) + +func PossibleValuesForPrivateEndpointNetworkPolicies() []string { + return []string{ + string(PrivateEndpointNetworkPoliciesDisabled), + string(PrivateEndpointNetworkPoliciesEnabled), + } +} + +func (s *PrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointNetworkPolicies(input string) (*PrivateEndpointNetworkPolicies, error) { + vals := map[string]PrivateEndpointNetworkPolicies{ + "disabled": PrivateEndpointNetworkPoliciesDisabled, + "enabled": PrivateEndpointNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type PrivateLinkServiceNetworkPolicies string + +const ( + PrivateLinkServiceNetworkPoliciesDisabled PrivateLinkServiceNetworkPolicies = "disabled" + PrivateLinkServiceNetworkPoliciesEnabled PrivateLinkServiceNetworkPolicies = "enabled" +) + +func PossibleValuesForPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(PrivateLinkServiceNetworkPoliciesDisabled), + string(PrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *PrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkServiceNetworkPolicies(input string) (*PrivateLinkServiceNetworkPolicies, error) { + vals := map[string]PrivateLinkServiceNetworkPolicies{ + "disabled": PrivateLinkServiceNetworkPoliciesDisabled, + "enabled": PrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkServiceNetworkPolicies(input) + return &out, nil +} + +type ProbeProtocol string + +const ( + ProbeProtocolHTTP ProbeProtocol = "http" + ProbeProtocolHTTPS ProbeProtocol = "https" + ProbeProtocolTcp ProbeProtocol = "tcp" +) + +func PossibleValuesForProbeProtocol() []string { + return []string{ + string(ProbeProtocolHTTP), + string(ProbeProtocolHTTPS), + string(ProbeProtocolTcp), + } +} + +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeProtocol(input string) (*ProbeProtocol, error) { + vals := map[string]ProbeProtocol{ + "http": ProbeProtocolHTTP, + "https": ProbeProtocolHTTPS, + "tcp": ProbeProtocolTcp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeProtocol(input) + return &out, nil +} + +type Protocol string + +const ( + ProtocolTcp Protocol = "tcp" + ProtocolUdp Protocol = "udp" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolTcp), + string(ProtocolUdp), + } +} + +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocol(input string) (*Protocol, error) { + vals := map[string]Protocol{ + "tcp": ProtocolTcp, + "udp": ProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Protocol(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "Basic" + SkuNameStandard SkuName = "Standard" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNameStandard), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "standard": SkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type ZonalUpdateMode string + +const ( + ZonalUpdateModeFast ZonalUpdateMode = "Fast" + ZonalUpdateModeStandard ZonalUpdateMode = "Standard" +) + +func PossibleValuesForZonalUpdateMode() []string { + return []string{ + string(ZonalUpdateModeFast), + string(ZonalUpdateModeStandard), + } +} + +func (s *ZonalUpdateMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseZonalUpdateMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseZonalUpdateMode(input string) (*ZonalUpdateMode, error) { + vals := map[string]ZonalUpdateMode{ + "fast": ZonalUpdateModeFast, + "standard": ZonalUpdateModeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ZonalUpdateMode(input) + return &out, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster.go new file mode 100644 index 00000000000..ff8dcd9645d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster.go @@ -0,0 +1,130 @@ +package managedcluster + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterId{} + +// ManagedClusterId is a struct representing the Resource ID for a Managed Cluster +type ManagedClusterId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string +} + +// NewManagedClusterID returns a new ManagedClusterId struct +func NewManagedClusterID(subscriptionId string, resourceGroupName string, managedClusterName string) ManagedClusterId { + return ManagedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + } +} + +// ParseManagedClusterID parses 'input' into a ManagedClusterId +func ParseManagedClusterID(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterIDInsensitively parses 'input' case-insensitively into a ManagedClusterId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterIDInsensitively(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + return nil +} + +// ValidateManagedClusterID checks that 'input' can be parsed as a Managed Cluster ID +func ValidateManagedClusterID(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 := ParseManagedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster ID +func (id ManagedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster ID +func (id ManagedClusterId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + } +} + +// String returns a human-readable description of this Managed Cluster ID +func (id ManagedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + } + return fmt.Sprintf("Managed Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster_test.go new file mode 100644 index 00000000000..faf96c3486e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/id_managedcluster_test.go @@ -0,0 +1,282 @@ +package managedcluster + +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 = &ManagedClusterId{} + +func TestNewManagedClusterID(t *testing.T) { + id := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } +} + +func TestFormatManagedClusterID(t *testing.T) { + actual := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestParseManagedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestSegmentsForManagedClusterId(t *testing.T) { + segments := ManagedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterId 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/servicefabricmanagedcluster/2024-04-01/managedcluster/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_createorupdate.go new file mode 100644 index 00000000000..95e9f5ad9fc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_createorupdate.go @@ -0,0 +1,75 @@ +package managedcluster + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCluster +} + +// CreateOrUpdate ... +func (c ManagedClusterClient) CreateOrUpdate(ctx context.Context, id ManagedClusterId, input ManagedCluster) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedClusterClient) CreateOrUpdateThenPoll(ctx context.Context, id ManagedClusterId, input ManagedCluster) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_delete.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_delete.go new file mode 100644 index 00000000000..dbcea342a30 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_delete.go @@ -0,0 +1,71 @@ +package managedcluster + +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 ManagedClusterClient) Delete(ctx context.Context, id ManagedClusterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ManagedClusterClient) DeleteThenPoll(ctx context.Context, id ManagedClusterId) 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/servicefabricmanagedcluster/2024-04-01/managedcluster/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_get.go new file mode 100644 index 00000000000..f7c939b1bfe --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_get.go @@ -0,0 +1,54 @@ +package managedcluster + +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 *ManagedCluster +} + +// Get ... +func (c ManagedClusterClient) Get(ctx context.Context, id ManagedClusterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedCluster + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbyresourcegroup.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbyresourcegroup.go new file mode 100644 index 00000000000..6fc2ff33bb8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package managedcluster + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// ListByResourceGroup ... +func (c ManagedClusterClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ServiceFabric/managedClusters", 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 *[]ManagedCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ManagedClusterClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbysubscription.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbysubscription.go new file mode 100644 index 00000000000..dff76cbe716 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_listbysubscription.go @@ -0,0 +1,92 @@ +package managedcluster + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedCluster +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// ListBySubscription ... +func (c ManagedClusterClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ServiceFabric/managedClusters", 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 *[]ManagedCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ManagedClusterClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_update.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_update.go new file mode 100644 index 00000000000..7b34690f35e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/method_update.go @@ -0,0 +1,58 @@ +package managedcluster + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCluster +} + +// Update ... +func (c ManagedClusterClient) Update(ctx context.Context, id ManagedClusterId, input ManagedClusterUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ManagedCluster + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_applicationtypeversionscleanuppolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_applicationtypeversionscleanuppolicy.go new file mode 100644 index 00000000000..c99ec72c444 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_applicationtypeversionscleanuppolicy.go @@ -0,0 +1,8 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationTypeVersionsCleanupPolicy struct { + MaxUnusedVersionsToKeep int64 `json:"maxUnusedVersionsToKeep"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_azureactivedirectory.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_azureactivedirectory.go new file mode 100644 index 00000000000..4652ddc32fc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_azureactivedirectory.go @@ -0,0 +1,10 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectory struct { + ClientApplication *string `json:"clientApplication,omitempty"` + ClusterApplication *string `json:"clusterApplication,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clientcertificate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clientcertificate.go new file mode 100644 index 00000000000..76ae210078d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clientcertificate.go @@ -0,0 +1,11 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientCertificate struct { + CommonName *string `json:"commonName,omitempty"` + IsAdmin bool `json:"isAdmin"` + IssuerThumbprint *string `json:"issuerThumbprint,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterhealthpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterhealthpolicy.go new file mode 100644 index 00000000000..d79053157a9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterhealthpolicy.go @@ -0,0 +1,9 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterHealthPolicy struct { + MaxPercentUnhealthyApplications int64 `json:"maxPercentUnhealthyApplications"` + MaxPercentUnhealthyNodes int64 `json:"maxPercentUnhealthyNodes"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clustermonitoringpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clustermonitoringpolicy.go new file mode 100644 index 00000000000..874cb685019 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clustermonitoringpolicy.go @@ -0,0 +1,12 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterMonitoringPolicy struct { + HealthCheckRetryTimeout string `json:"healthCheckRetryTimeout"` + HealthCheckStableDuration string `json:"healthCheckStableDuration"` + HealthCheckWaitDuration string `json:"healthCheckWaitDuration"` + UpgradeDomainTimeout string `json:"upgradeDomainTimeout"` + UpgradeTimeout string `json:"upgradeTimeout"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradedeltahealthpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradedeltahealthpolicy.go new file mode 100644 index 00000000000..75fce3c167b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradedeltahealthpolicy.go @@ -0,0 +1,10 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpgradeDeltaHealthPolicy struct { + MaxPercentDeltaUnhealthyApplications *int64 `json:"maxPercentDeltaUnhealthyApplications,omitempty"` + MaxPercentDeltaUnhealthyNodes int64 `json:"maxPercentDeltaUnhealthyNodes"` + MaxPercentUpgradeDomainDeltaUnhealthyNodes *int64 `json:"maxPercentUpgradeDomainDeltaUnhealthyNodes,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradepolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradepolicy.go new file mode 100644 index 00000000000..cd50368f79f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_clusterupgradepolicy.go @@ -0,0 +1,12 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpgradePolicy struct { + DeltaHealthPolicy *ClusterUpgradeDeltaHealthPolicy `json:"deltaHealthPolicy,omitempty"` + ForceRestart *bool `json:"forceRestart,omitempty"` + HealthPolicy *ClusterHealthPolicy `json:"healthPolicy,omitempty"` + MonitoringPolicy *ClusterMonitoringPolicy `json:"monitoringPolicy,omitempty"` + UpgradeReplicaSetCheckTimeout *string `json:"upgradeReplicaSetCheckTimeout,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_iptag.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_iptag.go new file mode 100644 index 00000000000..765b6bf62b8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_iptag.go @@ -0,0 +1,9 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType string `json:"ipTagType"` + Tag string `json:"tag"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_loadbalancingrule.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_loadbalancingrule.go new file mode 100644 index 00000000000..955ecc4cd48 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_loadbalancingrule.go @@ -0,0 +1,14 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancingRule struct { + BackendPort int64 `json:"backendPort"` + FrontendPort int64 `json:"frontendPort"` + LoadDistribution *string `json:"loadDistribution,omitempty"` + ProbePort *int64 `json:"probePort,omitempty"` + ProbeProtocol ProbeProtocol `json:"probeProtocol"` + ProbeRequestPath *string `json:"probeRequestPath,omitempty"` + Protocol Protocol `json:"protocol"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedcluster.go new file mode 100644 index 00000000000..4dd3061e645 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedcluster.go @@ -0,0 +1,16 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCluster struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedClusterProperties `json:"properties,omitempty"` + Sku Sku `json:"sku"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterproperties.go new file mode 100644 index 00000000000..65e38fdee14 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterproperties.go @@ -0,0 +1,46 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterProperties struct { + AddonFeatures *[]ManagedClusterAddOnFeature `json:"addonFeatures,omitempty"` + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUserName string `json:"adminUserName"` + AllowRdpAccess *bool `json:"allowRdpAccess,omitempty"` + ApplicationTypeVersionsCleanupPolicy *ApplicationTypeVersionsCleanupPolicy `json:"applicationTypeVersionsCleanupPolicy,omitempty"` + AuxiliarySubnets *[]Subnet `json:"auxiliarySubnets,omitempty"` + AzureActiveDirectory *AzureActiveDirectory `json:"azureActiveDirectory,omitempty"` + ClientConnectionPort *int64 `json:"clientConnectionPort,omitempty"` + Clients *[]ClientCertificate `json:"clients,omitempty"` + ClusterCertificateThumbprints *[]string `json:"clusterCertificateThumbprints,omitempty"` + ClusterCodeVersion *string `json:"clusterCodeVersion,omitempty"` + ClusterId *string `json:"clusterId,omitempty"` + ClusterState *ClusterState `json:"clusterState,omitempty"` + ClusterUpgradeCadence *ClusterUpgradeCadence `json:"clusterUpgradeCadence,omitempty"` + ClusterUpgradeMode *ClusterUpgradeMode `json:"clusterUpgradeMode,omitempty"` + DdosProtectionPlanId *string `json:"ddosProtectionPlanId,omitempty"` + DnsName string `json:"dnsName"` + EnableAutoOSUpgrade *bool `json:"enableAutoOSUpgrade,omitempty"` + EnableHTTPGatewayExclusiveAuthMode *bool `json:"enableHttpGatewayExclusiveAuthMode,omitempty"` + EnableIPv6 *bool `json:"enableIpv6,omitempty"` + EnableServicePublicIP *bool `json:"enableServicePublicIP,omitempty"` + FabricSettings *[]SettingsSectionDescription `json:"fabricSettings,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + HTTPGatewayConnectionPort *int64 `json:"httpGatewayConnectionPort,omitempty"` + HTTPGatewayTokenAuthConnectionPort *int64 `json:"httpGatewayTokenAuthConnectionPort,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IPv4Address *string `json:"ipv4Address,omitempty"` + IPv6Address *string `json:"ipv6Address,omitempty"` + LoadBalancingRules *[]LoadBalancingRule `json:"loadBalancingRules,omitempty"` + NetworkSecurityRules *[]NetworkSecurityRule `json:"networkSecurityRules,omitempty"` + ProvisioningState *ManagedResourceProvisioningState `json:"provisioningState,omitempty"` + PublicIPPrefixId *string `json:"publicIPPrefixId,omitempty"` + PublicIPv6PrefixId *string `json:"publicIPv6PrefixId,omitempty"` + ServiceEndpoints *[]ServiceEndpoint `json:"serviceEndpoints,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + UpgradeDescription *ClusterUpgradePolicy `json:"upgradeDescription,omitempty"` + UseCustomVnet *bool `json:"useCustomVnet,omitempty"` + ZonalResiliency *bool `json:"zonalResiliency,omitempty"` + ZonalUpdateMode *ZonalUpdateMode `json:"zonalUpdateMode,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterupdateparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterupdateparameters.go new file mode 100644 index 00000000000..1d326fe666e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_managedclusterupdateparameters.go @@ -0,0 +1,8 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterUpdateParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_networksecurityrule.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_networksecurityrule.go new file mode 100644 index 00000000000..bc022e06c8f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_networksecurityrule.go @@ -0,0 +1,21 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityRule struct { + Access Access `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction Direction `json:"direction"` + Name string `json:"name"` + Priority int64 `json:"priority"` + Protocol NsgProtocol `json:"protocol"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_serviceendpoint.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_serviceendpoint.go new file mode 100644 index 00000000000..23d01deeb06 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_serviceendpoint.go @@ -0,0 +1,9 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpoint struct { + Locations *[]string `json:"locations,omitempty"` + Service string `json:"service"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingsparameterdescription.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingsparameterdescription.go new file mode 100644 index 00000000000..0dc2d1760ae --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingsparameterdescription.go @@ -0,0 +1,9 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SettingsParameterDescription struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingssectiondescription.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingssectiondescription.go new file mode 100644 index 00000000000..6af0cbf636a --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_settingssectiondescription.go @@ -0,0 +1,9 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SettingsSectionDescription struct { + Name string `json:"name"` + Parameters []SettingsParameterDescription `json:"parameters"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_sku.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_sku.go new file mode 100644 index 00000000000..f92824762c9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_sku.go @@ -0,0 +1,8 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name SkuName `json:"name"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_subnet.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_subnet.go new file mode 100644 index 00000000000..054a92fe56e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_subnet.go @@ -0,0 +1,12 @@ +package managedcluster + +// 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 { + EnableIPv6 *bool `json:"enableIpv6,omitempty"` + Name string `json:"name"` + NetworkSecurityGroupId *string `json:"networkSecurityGroupId,omitempty"` + PrivateEndpointNetworkPolicies *PrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateLinkServiceNetworkPolicies *PrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_systemdata.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_systemdata.go new file mode 100644 index 00000000000..a7a0bde5974 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/model_systemdata.go @@ -0,0 +1,43 @@ +package managedcluster + +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 SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *string `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *string `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/predicates.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/predicates.go new file mode 100644 index 00000000000..26255b3e999 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/predicates.go @@ -0,0 +1,37 @@ +package managedcluster + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedClusterOperationPredicate) Matches(input ManagedCluster) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/version.go new file mode 100644 index 00000000000..103baccfc03 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedcluster/version.go @@ -0,0 +1,12 @@ +package managedcluster + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedcluster/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/README.md new file mode 100644 index 00000000000..b0389bf7e43 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/README.md @@ -0,0 +1,84 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion` Documentation + +The `managedclusterversion` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/managedclusterversion" +``` + + +### Client Initialization + +```go +client := managedclusterversion.NewManagedClusterVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedClusterVersionClient.Get` + +```go +ctx := context.TODO() +id := managedclusterversion.NewManagedClusterVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "managedClusterVersionValue") + +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: `ManagedClusterVersionClient.GetByEnvironment` + +```go +ctx := context.TODO() +id := managedclusterversion.NewEnvironmentManagedClusterVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "managedClusterVersionValue") + +read, err := client.GetByEnvironment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClusterVersionClient.List` + +```go +ctx := context.TODO() +id := managedclusterversion.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +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 +} +``` + + +### Example Usage: `ManagedClusterVersionClient.ListByEnvironment` + +```go +ctx := context.TODO() +id := managedclusterversion.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +read, err := client.ListByEnvironment(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/servicefabricmanagedcluster/2024-04-01/managedclusterversion/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/client.go new file mode 100644 index 00000000000..4221e0cb422 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/client.go @@ -0,0 +1,26 @@ +package managedclusterversion + +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 ManagedClusterVersionClient struct { + Client *resourcemanager.Client +} + +func NewManagedClusterVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClusterVersionClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedclusterversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClusterVersionClient: %+v", err) + } + + return &ManagedClusterVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/constants.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/constants.go new file mode 100644 index 00000000000..63f05d5112a --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/constants.go @@ -0,0 +1,48 @@ +package managedclusterversion + +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 OsType string + +const ( + OsTypeWindows OsType = "Windows" +) + +func PossibleValuesForOsType() []string { + return []string{ + string(OsTypeWindows), + } +} + +func (s *OsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOsType(input string) (*OsType, error) { + vals := map[string]OsType{ + "windows": OsTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OsType(input) + return &out, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion.go new file mode 100644 index 00000000000..2b18952e624 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion.go @@ -0,0 +1,132 @@ +package managedclusterversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&EnvironmentManagedClusterVersionId{}) +} + +var _ resourceids.ResourceId = &EnvironmentManagedClusterVersionId{} + +// EnvironmentManagedClusterVersionId is a struct representing the Resource ID for a Environment Managed Cluster Version +type EnvironmentManagedClusterVersionId struct { + SubscriptionId string + LocationName string + ManagedClusterVersionName string +} + +// NewEnvironmentManagedClusterVersionID returns a new EnvironmentManagedClusterVersionId struct +func NewEnvironmentManagedClusterVersionID(subscriptionId string, locationName string, managedClusterVersionName string) EnvironmentManagedClusterVersionId { + return EnvironmentManagedClusterVersionId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + ManagedClusterVersionName: managedClusterVersionName, + } +} + +// ParseEnvironmentManagedClusterVersionID parses 'input' into a EnvironmentManagedClusterVersionId +func ParseEnvironmentManagedClusterVersionID(input string) (*EnvironmentManagedClusterVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentManagedClusterVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentManagedClusterVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEnvironmentManagedClusterVersionIDInsensitively parses 'input' case-insensitively into a EnvironmentManagedClusterVersionId +// note: this method should only be used for API response data and not user input +func ParseEnvironmentManagedClusterVersionIDInsensitively(input string) (*EnvironmentManagedClusterVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentManagedClusterVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentManagedClusterVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EnvironmentManagedClusterVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.ManagedClusterVersionName, ok = input.Parsed["managedClusterVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterVersionName", input) + } + + return nil +} + +// ValidateEnvironmentManagedClusterVersionID checks that 'input' can be parsed as a Environment Managed Cluster Version ID +func ValidateEnvironmentManagedClusterVersionID(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 := ParseEnvironmentManagedClusterVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Environment Managed Cluster Version ID +func (id EnvironmentManagedClusterVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ServiceFabric/locations/%s/environments/Windows/managedClusterVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.ManagedClusterVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Environment Managed Cluster Version ID +func (id EnvironmentManagedClusterVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticEnvironments", "environments", "environments"), + resourceids.StaticSegment("environment", "Windows", "Windows"), + resourceids.StaticSegment("staticManagedClusterVersions", "managedClusterVersions", "managedClusterVersions"), + resourceids.UserSpecifiedSegment("managedClusterVersionName", "managedClusterVersionValue"), + } +} + +// String returns a human-readable description of this Environment Managed Cluster Version ID +func (id EnvironmentManagedClusterVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Managed Cluster Version Name: %q", id.ManagedClusterVersionName), + } + return fmt.Sprintf("Environment Managed Cluster Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion_test.go new file mode 100644 index 00000000000..efc4d59105d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_environmentmanagedclusterversion_test.go @@ -0,0 +1,312 @@ +package managedclusterversion + +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 = &EnvironmentManagedClusterVersionId{} + +func TestNewEnvironmentManagedClusterVersionID(t *testing.T) { + id := NewEnvironmentManagedClusterVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "managedClusterVersionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } + + if id.ManagedClusterVersionName != "managedClusterVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterVersionName'", id.ManagedClusterVersionName, "managedClusterVersionValue") + } +} + +func TestFormatEnvironmentManagedClusterVersionID(t *testing.T) { + actual := NewEnvironmentManagedClusterVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "managedClusterVersionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows/managedClusterVersions/managedClusterVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEnvironmentManagedClusterVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentManagedClusterVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows/managedClusterVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows/managedClusterVersions/managedClusterVersionValue", + Expected: &EnvironmentManagedClusterVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + ManagedClusterVersionName: "managedClusterVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows/managedClusterVersions/managedClusterVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentManagedClusterVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.ManagedClusterVersionName != v.Expected.ManagedClusterVersionName { + t.Fatalf("Expected %q but got %q for ManagedClusterVersionName", v.Expected.ManagedClusterVersionName, actual.ManagedClusterVersionName) + } + + } +} + +func TestParseEnvironmentManagedClusterVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentManagedClusterVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/eNvIrOnMeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/eNvIrOnMeNtS/wInDoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows/managedClusterVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/eNvIrOnMeNtS/wInDoWs/mAnAgEdClUsTeRvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows/managedClusterVersions/managedClusterVersionValue", + Expected: &EnvironmentManagedClusterVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + ManagedClusterVersionName: "managedClusterVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/environments/Windows/managedClusterVersions/managedClusterVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/eNvIrOnMeNtS/wInDoWs/mAnAgEdClUsTeRvErSiOnS/mAnAgEdClUsTeRvErSiOnVaLuE", + Expected: &EnvironmentManagedClusterVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + ManagedClusterVersionName: "mAnAgEdClUsTeRvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/eNvIrOnMeNtS/wInDoWs/mAnAgEdClUsTeRvErSiOnS/mAnAgEdClUsTeRvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentManagedClusterVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.ManagedClusterVersionName != v.Expected.ManagedClusterVersionName { + t.Fatalf("Expected %q but got %q for ManagedClusterVersionName", v.Expected.ManagedClusterVersionName, actual.ManagedClusterVersionName) + } + + } +} + +func TestSegmentsForEnvironmentManagedClusterVersionId(t *testing.T) { + segments := EnvironmentManagedClusterVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EnvironmentManagedClusterVersionId 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/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location.go new file mode 100644 index 00000000000..7255c7f6544 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location.go @@ -0,0 +1,121 @@ +package managedclusterversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ServiceFabric/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location_test.go new file mode 100644 index 00000000000..a5861bc3fad --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_location_test.go @@ -0,0 +1,237 @@ +package managedclusterversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion.go new file mode 100644 index 00000000000..8f0ba72ae5a --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion.go @@ -0,0 +1,130 @@ +package managedclusterversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterVersionId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterVersionId{} + +// ManagedClusterVersionId is a struct representing the Resource ID for a Managed Cluster Version +type ManagedClusterVersionId struct { + SubscriptionId string + LocationName string + ManagedClusterVersionName string +} + +// NewManagedClusterVersionID returns a new ManagedClusterVersionId struct +func NewManagedClusterVersionID(subscriptionId string, locationName string, managedClusterVersionName string) ManagedClusterVersionId { + return ManagedClusterVersionId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + ManagedClusterVersionName: managedClusterVersionName, + } +} + +// ParseManagedClusterVersionID parses 'input' into a ManagedClusterVersionId +func ParseManagedClusterVersionID(input string) (*ManagedClusterVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterVersionIDInsensitively parses 'input' case-insensitively into a ManagedClusterVersionId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterVersionIDInsensitively(input string) (*ManagedClusterVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.ManagedClusterVersionName, ok = input.Parsed["managedClusterVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterVersionName", input) + } + + return nil +} + +// ValidateManagedClusterVersionID checks that 'input' can be parsed as a Managed Cluster Version ID +func ValidateManagedClusterVersionID(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 := ParseManagedClusterVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster Version ID +func (id ManagedClusterVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ServiceFabric/locations/%s/managedClusterVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.ManagedClusterVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster Version ID +func (id ManagedClusterVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticManagedClusterVersions", "managedClusterVersions", "managedClusterVersions"), + resourceids.UserSpecifiedSegment("managedClusterVersionName", "managedClusterVersionValue"), + } +} + +// String returns a human-readable description of this Managed Cluster Version ID +func (id ManagedClusterVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Managed Cluster Version Name: %q", id.ManagedClusterVersionName), + } + return fmt.Sprintf("Managed Cluster Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion_test.go new file mode 100644 index 00000000000..46d0e725aa4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/id_managedclusterversion_test.go @@ -0,0 +1,282 @@ +package managedclusterversion + +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 = &ManagedClusterVersionId{} + +func TestNewManagedClusterVersionID(t *testing.T) { + id := NewManagedClusterVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "managedClusterVersionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } + + if id.ManagedClusterVersionName != "managedClusterVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterVersionName'", id.ManagedClusterVersionName, "managedClusterVersionValue") + } +} + +func TestFormatManagedClusterVersionID(t *testing.T) { + actual := NewManagedClusterVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "managedClusterVersionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedClusterVersions/managedClusterVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedClusterVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedClusterVersions/managedClusterVersionValue", + Expected: &ManagedClusterVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + ManagedClusterVersionName: "managedClusterVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedClusterVersions/managedClusterVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.ManagedClusterVersionName != v.Expected.ManagedClusterVersionName { + t.Fatalf("Expected %q but got %q for ManagedClusterVersionName", v.Expected.ManagedClusterVersionName, actual.ManagedClusterVersionName) + } + + } +} + +func TestParseManagedClusterVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedClusterVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/mAnAgEdClUsTeRvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedClusterVersions/managedClusterVersionValue", + Expected: &ManagedClusterVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + ManagedClusterVersionName: "managedClusterVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedClusterVersions/managedClusterVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/mAnAgEdClUsTeRvErSiOnS/mAnAgEdClUsTeRvErSiOnVaLuE", + Expected: &ManagedClusterVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + ManagedClusterVersionName: "mAnAgEdClUsTeRvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/mAnAgEdClUsTeRvErSiOnS/mAnAgEdClUsTeRvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.ManagedClusterVersionName != v.Expected.ManagedClusterVersionName { + t.Fatalf("Expected %q but got %q for ManagedClusterVersionName", v.Expected.ManagedClusterVersionName, actual.ManagedClusterVersionName) + } + + } +} + +func TestSegmentsForManagedClusterVersionId(t *testing.T) { + segments := ManagedClusterVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterVersionId 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/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_get.go new file mode 100644 index 00000000000..219e7a78f57 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_get.go @@ -0,0 +1,54 @@ +package managedclusterversion + +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 *ManagedClusterCodeVersionResult +} + +// Get ... +func (c ManagedClusterVersionClient) Get(ctx context.Context, id ManagedClusterVersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterCodeVersionResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_getbyenvironment.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_getbyenvironment.go new file mode 100644 index 00000000000..a22533b1b11 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_getbyenvironment.go @@ -0,0 +1,54 @@ +package managedclusterversion + +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 GetByEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterCodeVersionResult +} + +// GetByEnvironment ... +func (c ManagedClusterVersionClient) GetByEnvironment(ctx context.Context, id EnvironmentManagedClusterVersionId) (result GetByEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterCodeVersionResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_list.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_list.go new file mode 100644 index 00000000000..2074f6b62e2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_list.go @@ -0,0 +1,55 @@ +package managedclusterversion + +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 *[]ManagedClusterCodeVersionResult +} + +// List ... +func (c ManagedClusterVersionClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedClusterVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []ManagedClusterCodeVersionResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_listbyenvironment.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_listbyenvironment.go new file mode 100644 index 00000000000..116e3b58591 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/method_listbyenvironment.go @@ -0,0 +1,55 @@ +package managedclusterversion + +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 ListByEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedClusterCodeVersionResult +} + +// ListByEnvironment ... +func (c ManagedClusterVersionClient) ListByEnvironment(ctx context.Context, id LocationId) (result ListByEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/environments/Windows/managedClusterVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []ManagedClusterCodeVersionResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclustercodeversionresult.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclustercodeversionresult.go new file mode 100644 index 00000000000..520a3540789 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclustercodeversionresult.go @@ -0,0 +1,11 @@ +package managedclusterversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterCodeVersionResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedClusterVersionDetails `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclusterversiondetails.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclusterversiondetails.go new file mode 100644 index 00000000000..8f92e7594c7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/model_managedclusterversiondetails.go @@ -0,0 +1,10 @@ +package managedclusterversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterVersionDetails struct { + ClusterCodeVersion *string `json:"clusterCodeVersion,omitempty"` + OsType *OsType `json:"osType,omitempty"` + SupportExpiryUtc *string `json:"supportExpiryUtc,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/version.go new file mode 100644 index 00000000000..1de6921e5c8 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedclusterversion/version.go @@ -0,0 +1,12 @@ +package managedclusterversion + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedclusterversion/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/README.md new file mode 100644 index 00000000000..73d09bf47b4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus` Documentation + +The `managedmaintenancewindowstatus` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus" +``` + + +### Client Initialization + +```go +client := managedmaintenancewindowstatus.NewManagedMaintenanceWindowStatusClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedMaintenanceWindowStatusClient.Get` + +```go +ctx := context.TODO() +id := managedmaintenancewindowstatus.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/client.go new file mode 100644 index 00000000000..1a6ccbd8141 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/client.go @@ -0,0 +1,26 @@ +package managedmaintenancewindowstatus + +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 ManagedMaintenanceWindowStatusClient struct { + Client *resourcemanager.Client +} + +func NewManagedMaintenanceWindowStatusClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedMaintenanceWindowStatusClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedmaintenancewindowstatus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedMaintenanceWindowStatusClient: %+v", err) + } + + return &ManagedMaintenanceWindowStatusClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster.go new file mode 100644 index 00000000000..71faea8a8fa --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster.go @@ -0,0 +1,130 @@ +package managedmaintenancewindowstatus + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterId{} + +// ManagedClusterId is a struct representing the Resource ID for a Managed Cluster +type ManagedClusterId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string +} + +// NewManagedClusterID returns a new ManagedClusterId struct +func NewManagedClusterID(subscriptionId string, resourceGroupName string, managedClusterName string) ManagedClusterId { + return ManagedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + } +} + +// ParseManagedClusterID parses 'input' into a ManagedClusterId +func ParseManagedClusterID(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterIDInsensitively parses 'input' case-insensitively into a ManagedClusterId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterIDInsensitively(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + return nil +} + +// ValidateManagedClusterID checks that 'input' can be parsed as a Managed Cluster ID +func ValidateManagedClusterID(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 := ParseManagedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster ID +func (id ManagedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster ID +func (id ManagedClusterId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + } +} + +// String returns a human-readable description of this Managed Cluster ID +func (id ManagedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + } + return fmt.Sprintf("Managed Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster_test.go new file mode 100644 index 00000000000..dfd2c99f24b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/id_managedcluster_test.go @@ -0,0 +1,282 @@ +package managedmaintenancewindowstatus + +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 = &ManagedClusterId{} + +func TestNewManagedClusterID(t *testing.T) { + id := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } +} + +func TestFormatManagedClusterID(t *testing.T) { + actual := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestParseManagedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestSegmentsForManagedClusterId(t *testing.T) { + segments := ManagedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterId 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/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/method_get.go new file mode 100644 index 00000000000..7148c16d6e5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/method_get.go @@ -0,0 +1,55 @@ +package managedmaintenancewindowstatus + +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 *ManagedMaintenanceWindowStatus +} + +// Get ... +func (c ManagedMaintenanceWindowStatusClient) Get(ctx context.Context, id ManagedClusterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getMaintenanceWindowStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedMaintenanceWindowStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/model_managedmaintenancewindowstatus.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/model_managedmaintenancewindowstatus.go new file mode 100644 index 00000000000..c7ad148f658 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/model_managedmaintenancewindowstatus.go @@ -0,0 +1,56 @@ +package managedmaintenancewindowstatus + +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 ManagedMaintenanceWindowStatus struct { + CanApplyUpdates *bool `json:"canApplyUpdates,omitempty"` + IsRegionReady *bool `json:"isRegionReady,omitempty"` + IsWindowActive *bool `json:"isWindowActive,omitempty"` + IsWindowEnabled *bool `json:"isWindowEnabled,omitempty"` + LastWindowEndTimeUTC *string `json:"lastWindowEndTimeUTC,omitempty"` + LastWindowStartTimeUTC *string `json:"lastWindowStartTimeUTC,omitempty"` + LastWindowStatusUpdateAtUTC *string `json:"lastWindowStatusUpdateAtUTC,omitempty"` +} + +func (o *ManagedMaintenanceWindowStatus) GetLastWindowEndTimeUTCAsTime() (*time.Time, error) { + if o.LastWindowEndTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastWindowEndTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedMaintenanceWindowStatus) SetLastWindowEndTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastWindowEndTimeUTC = &formatted +} + +func (o *ManagedMaintenanceWindowStatus) GetLastWindowStartTimeUTCAsTime() (*time.Time, error) { + if o.LastWindowStartTimeUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastWindowStartTimeUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedMaintenanceWindowStatus) SetLastWindowStartTimeUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastWindowStartTimeUTC = &formatted +} + +func (o *ManagedMaintenanceWindowStatus) GetLastWindowStatusUpdateAtUTCAsTime() (*time.Time, error) { + if o.LastWindowStatusUpdateAtUTC == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastWindowStatusUpdateAtUTC, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedMaintenanceWindowStatus) SetLastWindowStatusUpdateAtUTCAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastWindowStatusUpdateAtUTC = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/version.go new file mode 100644 index 00000000000..78c93995013 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedmaintenancewindowstatus/version.go @@ -0,0 +1,12 @@ +package managedmaintenancewindowstatus + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedmaintenancewindowstatus/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/README.md new file mode 100644 index 00000000000..361c7014c0b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes` Documentation + +The `managedvmsizes` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/managedvmsizes" +``` + + +### Client Initialization + +```go +client := managedvmsizes.NewManagedVMSizesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedVMSizesClient.ManagedUnsupportedVMSizesGet` + +```go +ctx := context.TODO() +id := managedvmsizes.NewManagedUnsupportedVMSizeID("12345678-1234-9876-4563-123456789012", "locationValue", "managedUnsupportedVMSizeValue") + +read, err := client.ManagedUnsupportedVMSizesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedVMSizesClient.ManagedUnsupportedVMSizesList` + +```go +ctx := context.TODO() +id := managedvmsizes.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ManagedUnsupportedVMSizesList(ctx, id)` can be used to do batched pagination +items, err := client.ManagedUnsupportedVMSizesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/client.go new file mode 100644 index 00000000000..49278b9f927 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/client.go @@ -0,0 +1,26 @@ +package managedvmsizes + +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 ManagedVMSizesClient struct { + Client *resourcemanager.Client +} + +func NewManagedVMSizesClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedVMSizesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedvmsizes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedVMSizesClient: %+v", err) + } + + return &ManagedVMSizesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location.go new file mode 100644 index 00000000000..8be5965da8d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location.go @@ -0,0 +1,121 @@ +package managedvmsizes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ServiceFabric/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location_test.go new file mode 100644 index 00000000000..330af036a0b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_location_test.go @@ -0,0 +1,237 @@ +package managedvmsizes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize.go new file mode 100644 index 00000000000..c37db404db7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize.go @@ -0,0 +1,130 @@ +package managedvmsizes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedUnsupportedVMSizeId{}) +} + +var _ resourceids.ResourceId = &ManagedUnsupportedVMSizeId{} + +// ManagedUnsupportedVMSizeId is a struct representing the Resource ID for a Managed Unsupported V M Size +type ManagedUnsupportedVMSizeId struct { + SubscriptionId string + LocationName string + ManagedUnsupportedVMSizeName string +} + +// NewManagedUnsupportedVMSizeID returns a new ManagedUnsupportedVMSizeId struct +func NewManagedUnsupportedVMSizeID(subscriptionId string, locationName string, managedUnsupportedVMSizeName string) ManagedUnsupportedVMSizeId { + return ManagedUnsupportedVMSizeId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + ManagedUnsupportedVMSizeName: managedUnsupportedVMSizeName, + } +} + +// ParseManagedUnsupportedVMSizeID parses 'input' into a ManagedUnsupportedVMSizeId +func ParseManagedUnsupportedVMSizeID(input string) (*ManagedUnsupportedVMSizeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedUnsupportedVMSizeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedUnsupportedVMSizeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedUnsupportedVMSizeIDInsensitively parses 'input' case-insensitively into a ManagedUnsupportedVMSizeId +// note: this method should only be used for API response data and not user input +func ParseManagedUnsupportedVMSizeIDInsensitively(input string) (*ManagedUnsupportedVMSizeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedUnsupportedVMSizeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedUnsupportedVMSizeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedUnsupportedVMSizeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.ManagedUnsupportedVMSizeName, ok = input.Parsed["managedUnsupportedVMSizeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedUnsupportedVMSizeName", input) + } + + return nil +} + +// ValidateManagedUnsupportedVMSizeID checks that 'input' can be parsed as a Managed Unsupported V M Size ID +func ValidateManagedUnsupportedVMSizeID(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 := ParseManagedUnsupportedVMSizeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Unsupported V M Size ID +func (id ManagedUnsupportedVMSizeId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ServiceFabric/locations/%s/managedUnsupportedVMSizes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.ManagedUnsupportedVMSizeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Unsupported V M Size ID +func (id ManagedUnsupportedVMSizeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticManagedUnsupportedVMSizes", "managedUnsupportedVMSizes", "managedUnsupportedVMSizes"), + resourceids.UserSpecifiedSegment("managedUnsupportedVMSizeName", "managedUnsupportedVMSizeValue"), + } +} + +// String returns a human-readable description of this Managed Unsupported V M Size ID +func (id ManagedUnsupportedVMSizeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Managed Unsupported V M Size Name: %q", id.ManagedUnsupportedVMSizeName), + } + return fmt.Sprintf("Managed Unsupported V M Size (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize_test.go new file mode 100644 index 00000000000..fc1a7ac3dfb --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/id_managedunsupportedvmsize_test.go @@ -0,0 +1,282 @@ +package managedvmsizes + +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 = &ManagedUnsupportedVMSizeId{} + +func TestNewManagedUnsupportedVMSizeID(t *testing.T) { + id := NewManagedUnsupportedVMSizeID("12345678-1234-9876-4563-123456789012", "locationValue", "managedUnsupportedVMSizeValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } + + if id.ManagedUnsupportedVMSizeName != "managedUnsupportedVMSizeValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedUnsupportedVMSizeName'", id.ManagedUnsupportedVMSizeName, "managedUnsupportedVMSizeValue") + } +} + +func TestFormatManagedUnsupportedVMSizeID(t *testing.T) { + actual := NewManagedUnsupportedVMSizeID("12345678-1234-9876-4563-123456789012", "locationValue", "managedUnsupportedVMSizeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedUnsupportedVMSizes/managedUnsupportedVMSizeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedUnsupportedVMSizeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedUnsupportedVMSizeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedUnsupportedVMSizes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedUnsupportedVMSizes/managedUnsupportedVMSizeValue", + Expected: &ManagedUnsupportedVMSizeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + ManagedUnsupportedVMSizeName: "managedUnsupportedVMSizeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedUnsupportedVMSizes/managedUnsupportedVMSizeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedUnsupportedVMSizeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.ManagedUnsupportedVMSizeName != v.Expected.ManagedUnsupportedVMSizeName { + t.Fatalf("Expected %q but got %q for ManagedUnsupportedVMSizeName", v.Expected.ManagedUnsupportedVMSizeName, actual.ManagedUnsupportedVMSizeName) + } + + } +} + +func TestParseManagedUnsupportedVMSizeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedUnsupportedVMSizeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedUnsupportedVMSizes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/mAnAgEdUnSuPpOrTeDvMsIzEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedUnsupportedVMSizes/managedUnsupportedVMSizeValue", + Expected: &ManagedUnsupportedVMSizeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + ManagedUnsupportedVMSizeName: "managedUnsupportedVMSizeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ServiceFabric/locations/locationValue/managedUnsupportedVMSizes/managedUnsupportedVMSizeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/mAnAgEdUnSuPpOrTeDvMsIzEs/mAnAgEdUnSuPpOrTeDvMsIzEvAlUe", + Expected: &ManagedUnsupportedVMSizeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + ManagedUnsupportedVMSizeName: "mAnAgEdUnSuPpOrTeDvMsIzEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/lOcAtIoNs/lOcAtIoNvAlUe/mAnAgEdUnSuPpOrTeDvMsIzEs/mAnAgEdUnSuPpOrTeDvMsIzEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedUnsupportedVMSizeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.ManagedUnsupportedVMSizeName != v.Expected.ManagedUnsupportedVMSizeName { + t.Fatalf("Expected %q but got %q for ManagedUnsupportedVMSizeName", v.Expected.ManagedUnsupportedVMSizeName, actual.ManagedUnsupportedVMSizeName) + } + + } +} + +func TestSegmentsForManagedUnsupportedVMSizeId(t *testing.T) { + segments := ManagedUnsupportedVMSizeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedUnsupportedVMSizeId 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/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizesget.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizesget.go new file mode 100644 index 00000000000..8247d9a7856 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizesget.go @@ -0,0 +1,54 @@ +package managedvmsizes + +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 ManagedUnsupportedVMSizesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedVMSize +} + +// ManagedUnsupportedVMSizesGet ... +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesGet(ctx context.Context, id ManagedUnsupportedVMSizeId) (result ManagedUnsupportedVMSizesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedVMSize + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizeslist.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizeslist.go new file mode 100644 index 00000000000..3ce4a4d97c5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/method_managedunsupportedvmsizeslist.go @@ -0,0 +1,91 @@ +package managedvmsizes + +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 ManagedUnsupportedVMSizesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedVMSize +} + +type ManagedUnsupportedVMSizesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedVMSize +} + +// ManagedUnsupportedVMSizesList ... +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesList(ctx context.Context, id LocationId) (result ManagedUnsupportedVMSizesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/managedUnsupportedVMSizes", 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 *[]ManagedVMSize `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagedUnsupportedVMSizesListComplete retrieves all the results into a single object +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesListComplete(ctx context.Context, id LocationId) (ManagedUnsupportedVMSizesListCompleteResult, error) { + return c.ManagedUnsupportedVMSizesListCompleteMatchingPredicate(ctx, id, ManagedVMSizeOperationPredicate{}) +} + +// ManagedUnsupportedVMSizesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedVMSizesClient) ManagedUnsupportedVMSizesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate ManagedVMSizeOperationPredicate) (result ManagedUnsupportedVMSizesListCompleteResult, err error) { + items := make([]ManagedVMSize, 0) + + resp, err := c.ManagedUnsupportedVMSizesList(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 = ManagedUnsupportedVMSizesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_managedvmsize.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_managedvmsize.go new file mode 100644 index 00000000000..07f187e291a --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_managedvmsize.go @@ -0,0 +1,11 @@ +package managedvmsizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedVMSize struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VMSize `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_vmsize.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_vmsize.go new file mode 100644 index 00000000000..77063107811 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/model_vmsize.go @@ -0,0 +1,8 @@ +package managedvmsizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMSize struct { + Size *string `json:"size,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/predicates.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/predicates.go new file mode 100644 index 00000000000..9a2b31cab88 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/predicates.go @@ -0,0 +1,27 @@ +package managedvmsizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedVMSizeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ManagedVMSizeOperationPredicate) Matches(input ManagedVMSize) 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/servicefabricmanagedcluster/2024-04-01/managedvmsizes/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/version.go new file mode 100644 index 00000000000..02ff1f5d20c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/managedvmsizes/version.go @@ -0,0 +1,12 @@ +package managedvmsizes + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedvmsizes/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/README.md new file mode 100644 index 00000000000..d37f333946d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/README.md @@ -0,0 +1,171 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype` Documentation + +The `nodetype` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/nodetype" +``` + + +### Client Initialization + +```go +client := nodetype.NewNodeTypeClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NodeTypeClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +payload := nodetype.NodeType{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NodeTypeClient.Delete` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NodeTypeClient.DeleteNode` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +payload := nodetype.NodeTypeActionParameters{ + // ... +} + + +if err := client.DeleteNodeThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NodeTypeClient.Get` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +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: `NodeTypeClient.ListByManagedClusters` + +```go +ctx := context.TODO() +id := nodetype.NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// alternatively `client.ListByManagedClusters(ctx, id)` can be used to do batched pagination +items, err := client.ListByManagedClustersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NodeTypeClient.Reimage` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +payload := nodetype.NodeTypeActionParameters{ + // ... +} + + +if err := client.ReimageThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NodeTypeClient.Restart` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +payload := nodetype.NodeTypeActionParameters{ + // ... +} + + +if err := client.RestartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NodeTypeClient.SkusList` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +// alternatively `client.SkusList(ctx, id)` can be used to do batched pagination +items, err := client.SkusListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NodeTypeClient.Update` + +```go +ctx := context.TODO() +id := nodetype.NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + +payload := nodetype.NodeTypeUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/client.go new file mode 100644 index 00000000000..ae6880601d4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/client.go @@ -0,0 +1,26 @@ +package nodetype + +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 NodeTypeClient struct { + Client *resourcemanager.Client +} + +func NewNodeTypeClientWithBaseURI(sdkApi sdkEnv.Api) (*NodeTypeClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "nodetype", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NodeTypeClient: %+v", err) + } + + return &NodeTypeClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/constants.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/constants.go new file mode 100644 index 00000000000..e65ea3c72c9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/constants.go @@ -0,0 +1,626 @@ +package nodetype + +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 Access string + +const ( + AccessAllow Access = "allow" + AccessDeny Access = "deny" +) + +func PossibleValuesForAccess() []string { + return []string{ + string(AccessAllow), + string(AccessDeny), + } +} + +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccess(input string) (*Access, error) { + vals := map[string]Access{ + "allow": AccessAllow, + "deny": AccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Access(input) + return &out, nil +} + +type Direction string + +const ( + DirectionInbound Direction = "inbound" + DirectionOutbound Direction = "outbound" +) + +func PossibleValuesForDirection() []string { + return []string{ + string(DirectionInbound), + string(DirectionOutbound), + } +} + +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDirection(input string) (*Direction, error) { + vals := map[string]Direction{ + "inbound": DirectionInbound, + "outbound": DirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Direction(input) + return &out, nil +} + +type DiskType string + +const ( + DiskTypePremiumLRS DiskType = "Premium_LRS" + DiskTypeStandardLRS DiskType = "Standard_LRS" + DiskTypeStandardSSDLRS DiskType = "StandardSSD_LRS" +) + +func PossibleValuesForDiskType() []string { + return []string{ + string(DiskTypePremiumLRS), + string(DiskTypeStandardLRS), + string(DiskTypeStandardSSDLRS), + } +} + +func (s *DiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskType(input string) (*DiskType, error) { + vals := map[string]DiskType{ + "premium_lrs": DiskTypePremiumLRS, + "standard_lrs": DiskTypeStandardLRS, + "standardssd_lrs": DiskTypeStandardSSDLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskType(input) + return &out, nil +} + +type EvictionPolicyType string + +const ( + EvictionPolicyTypeDeallocate EvictionPolicyType = "Deallocate" + EvictionPolicyTypeDelete EvictionPolicyType = "Delete" +) + +func PossibleValuesForEvictionPolicyType() []string { + return []string{ + string(EvictionPolicyTypeDeallocate), + string(EvictionPolicyTypeDelete), + } +} + +func (s *EvictionPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEvictionPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEvictionPolicyType(input string) (*EvictionPolicyType, error) { + vals := map[string]EvictionPolicyType{ + "deallocate": EvictionPolicyTypeDeallocate, + "delete": EvictionPolicyTypeDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EvictionPolicyType(input) + return &out, nil +} + +type IPAddressType string + +const ( + IPAddressTypeIPvFour IPAddressType = "IPv4" + IPAddressTypeIPvSix IPAddressType = "IPv6" +) + +func PossibleValuesForIPAddressType() []string { + return []string{ + string(IPAddressTypeIPvFour), + string(IPAddressTypeIPvSix), + } +} + +func (s *IPAddressType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAddressType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAddressType(input string) (*IPAddressType, error) { + vals := map[string]IPAddressType{ + "ipv4": IPAddressTypeIPvFour, + "ipv6": IPAddressTypeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAddressType(input) + return &out, nil +} + +type ManagedResourceProvisioningState string + +const ( + ManagedResourceProvisioningStateCanceled ManagedResourceProvisioningState = "Canceled" + ManagedResourceProvisioningStateCreated ManagedResourceProvisioningState = "Created" + ManagedResourceProvisioningStateCreating ManagedResourceProvisioningState = "Creating" + ManagedResourceProvisioningStateDeleted ManagedResourceProvisioningState = "Deleted" + ManagedResourceProvisioningStateDeleting ManagedResourceProvisioningState = "Deleting" + ManagedResourceProvisioningStateFailed ManagedResourceProvisioningState = "Failed" + ManagedResourceProvisioningStateNone ManagedResourceProvisioningState = "None" + ManagedResourceProvisioningStateOther ManagedResourceProvisioningState = "Other" + ManagedResourceProvisioningStateSucceeded ManagedResourceProvisioningState = "Succeeded" + ManagedResourceProvisioningStateUpdating ManagedResourceProvisioningState = "Updating" +) + +func PossibleValuesForManagedResourceProvisioningState() []string { + return []string{ + string(ManagedResourceProvisioningStateCanceled), + string(ManagedResourceProvisioningStateCreated), + string(ManagedResourceProvisioningStateCreating), + string(ManagedResourceProvisioningStateDeleted), + string(ManagedResourceProvisioningStateDeleting), + string(ManagedResourceProvisioningStateFailed), + string(ManagedResourceProvisioningStateNone), + string(ManagedResourceProvisioningStateOther), + string(ManagedResourceProvisioningStateSucceeded), + string(ManagedResourceProvisioningStateUpdating), + } +} + +func (s *ManagedResourceProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedResourceProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedResourceProvisioningState(input string) (*ManagedResourceProvisioningState, error) { + vals := map[string]ManagedResourceProvisioningState{ + "canceled": ManagedResourceProvisioningStateCanceled, + "created": ManagedResourceProvisioningStateCreated, + "creating": ManagedResourceProvisioningStateCreating, + "deleted": ManagedResourceProvisioningStateDeleted, + "deleting": ManagedResourceProvisioningStateDeleting, + "failed": ManagedResourceProvisioningStateFailed, + "none": ManagedResourceProvisioningStateNone, + "other": ManagedResourceProvisioningStateOther, + "succeeded": ManagedResourceProvisioningStateSucceeded, + "updating": ManagedResourceProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedResourceProvisioningState(input) + return &out, nil +} + +type NodeTypeSkuScaleType string + +const ( + NodeTypeSkuScaleTypeAutomatic NodeTypeSkuScaleType = "Automatic" + NodeTypeSkuScaleTypeManual NodeTypeSkuScaleType = "Manual" + NodeTypeSkuScaleTypeNone NodeTypeSkuScaleType = "None" +) + +func PossibleValuesForNodeTypeSkuScaleType() []string { + return []string{ + string(NodeTypeSkuScaleTypeAutomatic), + string(NodeTypeSkuScaleTypeManual), + string(NodeTypeSkuScaleTypeNone), + } +} + +func (s *NodeTypeSkuScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeTypeSkuScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodeTypeSkuScaleType(input string) (*NodeTypeSkuScaleType, error) { + vals := map[string]NodeTypeSkuScaleType{ + "automatic": NodeTypeSkuScaleTypeAutomatic, + "manual": NodeTypeSkuScaleTypeManual, + "none": NodeTypeSkuScaleTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodeTypeSkuScaleType(input) + return &out, nil +} + +type NsgProtocol string + +const ( + NsgProtocolAh NsgProtocol = "ah" + NsgProtocolEsp NsgProtocol = "esp" + NsgProtocolHTTP NsgProtocol = "http" + NsgProtocolHTTPS NsgProtocol = "https" + NsgProtocolIcmp NsgProtocol = "icmp" + NsgProtocolTcp NsgProtocol = "tcp" + NsgProtocolUdp NsgProtocol = "udp" +) + +func PossibleValuesForNsgProtocol() []string { + return []string{ + string(NsgProtocolAh), + string(NsgProtocolEsp), + string(NsgProtocolHTTP), + string(NsgProtocolHTTPS), + string(NsgProtocolIcmp), + string(NsgProtocolTcp), + string(NsgProtocolUdp), + } +} + +func (s *NsgProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNsgProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNsgProtocol(input string) (*NsgProtocol, error) { + vals := map[string]NsgProtocol{ + "ah": NsgProtocolAh, + "esp": NsgProtocolEsp, + "http": NsgProtocolHTTP, + "https": NsgProtocolHTTPS, + "icmp": NsgProtocolIcmp, + "tcp": NsgProtocolTcp, + "udp": NsgProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NsgProtocol(input) + return &out, nil +} + +type PrivateIPAddressVersion string + +const ( + PrivateIPAddressVersionIPvFour PrivateIPAddressVersion = "IPv4" + PrivateIPAddressVersionIPvSix PrivateIPAddressVersion = "IPv6" +) + +func PossibleValuesForPrivateIPAddressVersion() []string { + return []string{ + string(PrivateIPAddressVersionIPvFour), + string(PrivateIPAddressVersionIPvSix), + } +} + +func (s *PrivateIPAddressVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateIPAddressVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateIPAddressVersion(input string) (*PrivateIPAddressVersion, error) { + vals := map[string]PrivateIPAddressVersion{ + "ipv4": PrivateIPAddressVersionIPvFour, + "ipv6": PrivateIPAddressVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateIPAddressVersion(input) + return &out, nil +} + +type PublicIPAddressVersion string + +const ( + PublicIPAddressVersionIPvFour PublicIPAddressVersion = "IPv4" + PublicIPAddressVersionIPvSix PublicIPAddressVersion = "IPv6" +) + +func PossibleValuesForPublicIPAddressVersion() []string { + return []string{ + string(PublicIPAddressVersionIPvFour), + string(PublicIPAddressVersionIPvSix), + } +} + +func (s *PublicIPAddressVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressVersion(input string) (*PublicIPAddressVersion, error) { + vals := map[string]PublicIPAddressVersion{ + "ipv4": PublicIPAddressVersionIPvFour, + "ipv6": PublicIPAddressVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressVersion(input) + return &out, nil +} + +type SecurityType string + +const ( + SecurityTypeStandard SecurityType = "Standard" + SecurityTypeTrustedLaunch SecurityType = "TrustedLaunch" +) + +func PossibleValuesForSecurityType() []string { + return []string{ + string(SecurityTypeStandard), + 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{ + "standard": SecurityTypeStandard, + "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 UpdateType string + +const ( + UpdateTypeByUpgradeDomain UpdateType = "ByUpgradeDomain" + UpdateTypeDefault UpdateType = "Default" +) + +func PossibleValuesForUpdateType() []string { + return []string{ + string(UpdateTypeByUpgradeDomain), + string(UpdateTypeDefault), + } +} + +func (s *UpdateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpdateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpdateType(input string) (*UpdateType, error) { + vals := map[string]UpdateType{ + "byupgradedomain": UpdateTypeByUpgradeDomain, + "default": UpdateTypeDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpdateType(input) + return &out, nil +} + +type VMSSExtensionSetupOrder string + +const ( + VMSSExtensionSetupOrderBeforeSFRuntime VMSSExtensionSetupOrder = "BeforeSFRuntime" +) + +func PossibleValuesForVMSSExtensionSetupOrder() []string { + return []string{ + string(VMSSExtensionSetupOrderBeforeSFRuntime), + } +} + +func (s *VMSSExtensionSetupOrder) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMSSExtensionSetupOrder(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMSSExtensionSetupOrder(input string) (*VMSSExtensionSetupOrder, error) { + vals := map[string]VMSSExtensionSetupOrder{ + "beforesfruntime": VMSSExtensionSetupOrderBeforeSFRuntime, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMSSExtensionSetupOrder(input) + return &out, nil +} + +type VMSetupAction string + +const ( + VMSetupActionEnableContainers VMSetupAction = "EnableContainers" + VMSetupActionEnableHyperV VMSetupAction = "EnableHyperV" +) + +func PossibleValuesForVMSetupAction() []string { + return []string{ + string(VMSetupActionEnableContainers), + string(VMSetupActionEnableHyperV), + } +} + +func (s *VMSetupAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMSetupAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMSetupAction(input string) (*VMSetupAction, error) { + vals := map[string]VMSetupAction{ + "enablecontainers": VMSetupActionEnableContainers, + "enablehyperv": VMSetupActionEnableHyperV, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMSetupAction(input) + return &out, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster.go new file mode 100644 index 00000000000..045b223bc19 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster.go @@ -0,0 +1,130 @@ +package nodetype + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterId{} + +// ManagedClusterId is a struct representing the Resource ID for a Managed Cluster +type ManagedClusterId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string +} + +// NewManagedClusterID returns a new ManagedClusterId struct +func NewManagedClusterID(subscriptionId string, resourceGroupName string, managedClusterName string) ManagedClusterId { + return ManagedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + } +} + +// ParseManagedClusterID parses 'input' into a ManagedClusterId +func ParseManagedClusterID(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterIDInsensitively parses 'input' case-insensitively into a ManagedClusterId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterIDInsensitively(input string) (*ManagedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + return nil +} + +// ValidateManagedClusterID checks that 'input' can be parsed as a Managed Cluster ID +func ValidateManagedClusterID(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 := ParseManagedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster ID +func (id ManagedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster ID +func (id ManagedClusterId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + } +} + +// String returns a human-readable description of this Managed Cluster ID +func (id ManagedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + } + return fmt.Sprintf("Managed Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster_test.go new file mode 100644 index 00000000000..119c2746c8e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_managedcluster_test.go @@ -0,0 +1,282 @@ +package nodetype + +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 = &ManagedClusterId{} + +func TestNewManagedClusterID(t *testing.T) { + id := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } +} + +func TestFormatManagedClusterID(t *testing.T) { + actual := NewManagedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestParseManagedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Expected: &ManagedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + } +} + +func TestSegmentsForManagedClusterId(t *testing.T) { + segments := ManagedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterId 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/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype.go new file mode 100644 index 00000000000..b6155dff9ad --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype.go @@ -0,0 +1,139 @@ +package nodetype + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NodeTypeId{}) +} + +var _ resourceids.ResourceId = &NodeTypeId{} + +// NodeTypeId is a struct representing the Resource ID for a Node Type +type NodeTypeId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + NodeTypeName string +} + +// NewNodeTypeID returns a new NodeTypeId struct +func NewNodeTypeID(subscriptionId string, resourceGroupName string, managedClusterName string, nodeTypeName string) NodeTypeId { + return NodeTypeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + NodeTypeName: nodeTypeName, + } +} + +// ParseNodeTypeID parses 'input' into a NodeTypeId +func ParseNodeTypeID(input string) (*NodeTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&NodeTypeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NodeTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNodeTypeIDInsensitively parses 'input' case-insensitively into a NodeTypeId +// note: this method should only be used for API response data and not user input +func ParseNodeTypeIDInsensitively(input string) (*NodeTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&NodeTypeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NodeTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NodeTypeId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.NodeTypeName, ok = input.Parsed["nodeTypeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "nodeTypeName", input) + } + + return nil +} + +// ValidateNodeTypeID checks that 'input' can be parsed as a Node Type ID +func ValidateNodeTypeID(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 := ParseNodeTypeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Node Type ID +func (id NodeTypeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/nodeTypes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.NodeTypeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Node Type ID +func (id NodeTypeId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticNodeTypes", "nodeTypes", "nodeTypes"), + resourceids.UserSpecifiedSegment("nodeTypeName", "nodeTypeValue"), + } +} + +// String returns a human-readable description of this Node Type ID +func (id NodeTypeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Node Type Name: %q", id.NodeTypeName), + } + return fmt.Sprintf("Node Type (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype_test.go new file mode 100644 index 00000000000..f4acab9843b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/id_nodetype_test.go @@ -0,0 +1,327 @@ +package nodetype + +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 = &NodeTypeId{} + +func TestNewNodeTypeID(t *testing.T) { + id := NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.NodeTypeName != "nodeTypeValue" { + t.Fatalf("Expected %q but got %q for Segment 'NodeTypeName'", id.NodeTypeName, "nodeTypeValue") + } +} + +func TestFormatNodeTypeID(t *testing.T) { + actual := NewNodeTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "nodeTypeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/nodeTypes/nodeTypeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNodeTypeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NodeTypeId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/nodeTypes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/nodeTypes/nodeTypeValue", + Expected: &NodeTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + NodeTypeName: "nodeTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/nodeTypes/nodeTypeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNodeTypeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.NodeTypeName != v.Expected.NodeTypeName { + t.Fatalf("Expected %q but got %q for NodeTypeName", v.Expected.NodeTypeName, actual.NodeTypeName) + } + + } +} + +func TestParseNodeTypeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NodeTypeId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/nodeTypes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/nOdEtYpEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/nodeTypes/nodeTypeValue", + Expected: &NodeTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + NodeTypeName: "nodeTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/nodeTypes/nodeTypeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/nOdEtYpEs/nOdEtYpEvAlUe", + Expected: &NodeTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + NodeTypeName: "nOdEtYpEvAlUe", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/nOdEtYpEs/nOdEtYpEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNodeTypeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.NodeTypeName != v.Expected.NodeTypeName { + t.Fatalf("Expected %q but got %q for NodeTypeName", v.Expected.NodeTypeName, actual.NodeTypeName) + } + + } +} + +func TestSegmentsForNodeTypeId(t *testing.T) { + segments := NodeTypeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NodeTypeId 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/servicefabricmanagedcluster/2024-04-01/nodetype/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_createorupdate.go new file mode 100644 index 00000000000..fa299533273 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_createorupdate.go @@ -0,0 +1,75 @@ +package nodetype + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NodeType +} + +// CreateOrUpdate ... +func (c NodeTypeClient) CreateOrUpdate(ctx context.Context, id NodeTypeId, input NodeType) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NodeTypeClient) CreateOrUpdateThenPoll(ctx context.Context, id NodeTypeId, input NodeType) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_delete.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_delete.go new file mode 100644 index 00000000000..028e962d71f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_delete.go @@ -0,0 +1,71 @@ +package nodetype + +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 NodeTypeClient) Delete(ctx context.Context, id NodeTypeId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 NodeTypeClient) DeleteThenPoll(ctx context.Context, id NodeTypeId) 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/servicefabricmanagedcluster/2024-04-01/nodetype/method_deletenode.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_deletenode.go new file mode 100644 index 00000000000..803466d737e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_deletenode.go @@ -0,0 +1,74 @@ +package nodetype + +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 DeleteNodeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteNode ... +func (c NodeTypeClient) DeleteNode(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result DeleteNodeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteNode", 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 +} + +// DeleteNodeThenPoll performs DeleteNode then polls until it's completed +func (c NodeTypeClient) DeleteNodeThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.DeleteNode(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteNode: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteNode: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_get.go new file mode 100644 index 00000000000..ce7c44fb0e1 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_get.go @@ -0,0 +1,54 @@ +package nodetype + +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 *NodeType +} + +// Get ... +func (c NodeTypeClient) Get(ctx context.Context, id NodeTypeId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NodeType + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_listbymanagedclusters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_listbymanagedclusters.go new file mode 100644 index 00000000000..1fb6fa2611f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_listbymanagedclusters.go @@ -0,0 +1,91 @@ +package nodetype + +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 ListByManagedClustersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NodeType +} + +type ListByManagedClustersCompleteResult struct { + LatestHttpResponse *http.Response + Items []NodeType +} + +// ListByManagedClusters ... +func (c NodeTypeClient) ListByManagedClusters(ctx context.Context, id ManagedClusterId) (result ListByManagedClustersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/nodeTypes", 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 *[]NodeType `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagedClustersComplete retrieves all the results into a single object +func (c NodeTypeClient) ListByManagedClustersComplete(ctx context.Context, id ManagedClusterId) (ListByManagedClustersCompleteResult, error) { + return c.ListByManagedClustersCompleteMatchingPredicate(ctx, id, NodeTypeOperationPredicate{}) +} + +// ListByManagedClustersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NodeTypeClient) ListByManagedClustersCompleteMatchingPredicate(ctx context.Context, id ManagedClusterId, predicate NodeTypeOperationPredicate) (result ListByManagedClustersCompleteResult, err error) { + items := make([]NodeType, 0) + + resp, err := c.ListByManagedClusters(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 = ListByManagedClustersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_reimage.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_reimage.go new file mode 100644 index 00000000000..00358aaa9f5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_reimage.go @@ -0,0 +1,74 @@ +package nodetype + +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 ReimageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Reimage ... +func (c NodeTypeClient) Reimage(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (result ReimageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reimage", 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 +} + +// ReimageThenPoll performs Reimage then polls until it's completed +func (c NodeTypeClient) ReimageThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.Reimage(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Reimage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reimage: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_restart.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_restart.go new file mode 100644 index 00000000000..69322966ede --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_restart.go @@ -0,0 +1,74 @@ +package nodetype + +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 +} + +// Restart ... +func (c NodeTypeClient) Restart(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) (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 + } + + 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 +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c NodeTypeClient) RestartThenPoll(ctx context.Context, id NodeTypeId, input NodeTypeActionParameters) error { + result, err := c.Restart(ctx, id, input) + 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/servicefabricmanagedcluster/2024-04-01/nodetype/method_skuslist.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_skuslist.go new file mode 100644 index 00000000000..5f59da9a6bc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_skuslist.go @@ -0,0 +1,91 @@ +package nodetype + +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 SkusListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NodeTypeAvailableSku +} + +type SkusListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NodeTypeAvailableSku +} + +// SkusList ... +func (c NodeTypeClient) SkusList(ctx context.Context, id NodeTypeId) (result SkusListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", 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 *[]NodeTypeAvailableSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// SkusListComplete retrieves all the results into a single object +func (c NodeTypeClient) SkusListComplete(ctx context.Context, id NodeTypeId) (SkusListCompleteResult, error) { + return c.SkusListCompleteMatchingPredicate(ctx, id, NodeTypeAvailableSkuOperationPredicate{}) +} + +// SkusListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NodeTypeClient) SkusListCompleteMatchingPredicate(ctx context.Context, id NodeTypeId, predicate NodeTypeAvailableSkuOperationPredicate) (result SkusListCompleteResult, err error) { + items := make([]NodeTypeAvailableSku, 0) + + resp, err := c.SkusList(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 = SkusListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_update.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_update.go new file mode 100644 index 00000000000..0b922d8e9e0 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/method_update.go @@ -0,0 +1,58 @@ +package nodetype + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NodeType +} + +// Update ... +func (c NodeTypeClient) Update(ctx context.Context, id NodeTypeId, input NodeTypeUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model NodeType + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_additionalnetworkinterfaceconfiguration.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_additionalnetworkinterfaceconfiguration.go new file mode 100644 index 00000000000..d86b29564de --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_additionalnetworkinterfaceconfiguration.go @@ -0,0 +1,11 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdditionalNetworkInterfaceConfiguration struct { + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + IPConfigurations []IPConfiguration `json:"ipConfigurations"` + Name string `json:"name"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_endpointrangedescription.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_endpointrangedescription.go new file mode 100644 index 00000000000..e7a7d9370b4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_endpointrangedescription.go @@ -0,0 +1,9 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointRangeDescription struct { + EndPort int64 `json:"endPort"` + StartPort int64 `json:"startPort"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_frontendconfiguration.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_frontendconfiguration.go new file mode 100644 index 00000000000..e1b3fbbdab1 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_frontendconfiguration.go @@ -0,0 +1,11 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendConfiguration struct { + ApplicationGatewayBackendAddressPoolId *string `json:"applicationGatewayBackendAddressPoolId,omitempty"` + IPAddressType *IPAddressType `json:"ipAddressType,omitempty"` + LoadBalancerBackendAddressPoolId *string `json:"loadBalancerBackendAddressPoolId,omitempty"` + LoadBalancerInboundNatPoolId *string `json:"loadBalancerInboundNatPoolId,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfiguration.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfiguration.go new file mode 100644 index 00000000000..c196bf3bfb7 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfiguration.go @@ -0,0 +1,14 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + ApplicationGatewayBackendAddressPools *[]SubResource `json:"applicationGatewayBackendAddressPools,omitempty"` + LoadBalancerBackendAddressPools *[]SubResource `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatPools *[]SubResource `json:"loadBalancerInboundNatPools,omitempty"` + Name string `json:"name"` + PrivateIPAddressVersion *PrivateIPAddressVersion `json:"privateIPAddressVersion,omitempty"` + PublicIPAddressConfiguration *IPConfigurationPublicIPAddressConfiguration `json:"publicIPAddressConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfigurationpublicipaddressconfiguration.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfigurationpublicipaddressconfiguration.go new file mode 100644 index 00000000000..18769be3291 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_ipconfigurationpublicipaddressconfiguration.go @@ -0,0 +1,10 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPublicIPAddressConfiguration struct { + IPTags *[]IPTag `json:"ipTags,omitempty"` + Name string `json:"name"` + PublicIPAddressVersion *PublicIPAddressVersion `json:"publicIPAddressVersion,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_iptag.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_iptag.go new file mode 100644 index 00000000000..af3fddb48ef --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_iptag.go @@ -0,0 +1,9 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType string `json:"ipTagType"` + Tag string `json:"tag"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_networksecurityrule.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_networksecurityrule.go new file mode 100644 index 00000000000..500f8dc1ef5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_networksecurityrule.go @@ -0,0 +1,21 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityRule struct { + Access Access `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction Direction `json:"direction"` + Name string `json:"name"` + Priority int64 `json:"priority"` + Protocol NsgProtocol `json:"protocol"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetype.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetype.go new file mode 100644 index 00000000000..85e54c58127 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetype.go @@ -0,0 +1,14 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeType struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NodeTypeProperties `json:"properties,omitempty"` + Sku *NodeTypeSku `json:"sku,omitempty"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeactionparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeactionparameters.go new file mode 100644 index 00000000000..5b7f6388584 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeactionparameters.go @@ -0,0 +1,10 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeActionParameters struct { + Force *bool `json:"force,omitempty"` + Nodes *[]string `json:"nodes,omitempty"` + UpdateType *UpdateType `json:"updateType,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeavailablesku.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeavailablesku.go new file mode 100644 index 00000000000..8ef475e78ee --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeavailablesku.go @@ -0,0 +1,10 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeAvailableSku struct { + Capacity *NodeTypeSkuCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *NodeTypeSupportedSku `json:"sku,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypenatconfig.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypenatconfig.go new file mode 100644 index 00000000000..255a243f639 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypenatconfig.go @@ -0,0 +1,10 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeNatConfig struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeproperties.go new file mode 100644 index 00000000000..20733157cfd --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeproperties.go @@ -0,0 +1,61 @@ +package nodetype + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeProperties struct { + AdditionalDataDisks *[]VMSSDataDisk `json:"additionalDataDisks,omitempty"` + AdditionalNetworkInterfaceConfigurations *[]AdditionalNetworkInterfaceConfiguration `json:"additionalNetworkInterfaceConfigurations,omitempty"` + ApplicationPorts *EndpointRangeDescription `json:"applicationPorts,omitempty"` + Capacities *map[string]string `json:"capacities,omitempty"` + ComputerNamePrefix *string `json:"computerNamePrefix,omitempty"` + DataDiskLetter *string `json:"dataDiskLetter,omitempty"` + DataDiskSizeGB *int64 `json:"dataDiskSizeGB,omitempty"` + DataDiskType *DiskType `json:"dataDiskType,omitempty"` + DscpConfigurationId *string `json:"dscpConfigurationId,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableEncryptionAtHost *bool `json:"enableEncryptionAtHost,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIP,omitempty"` + EnableNodePublicIPv6 *bool `json:"enableNodePublicIPv6,omitempty"` + EnableOverProvisioning *bool `json:"enableOverProvisioning,omitempty"` + EphemeralPorts *EndpointRangeDescription `json:"ephemeralPorts,omitempty"` + EvictionPolicy *EvictionPolicyType `json:"evictionPolicy,omitempty"` + FrontendConfigurations *[]FrontendConfiguration `json:"frontendConfigurations,omitempty"` + HostGroupId *string `json:"hostGroupId,omitempty"` + IsPrimary bool `json:"isPrimary"` + IsSpotVM *bool `json:"isSpotVM,omitempty"` + IsStateless *bool `json:"isStateless,omitempty"` + MultiplePlacementGroups *bool `json:"multiplePlacementGroups,omitempty"` + NatConfigurations *[]NodeTypeNatConfig `json:"natConfigurations,omitempty"` + NatGatewayId *string `json:"natGatewayId,omitempty"` + NetworkSecurityRules *[]NetworkSecurityRule `json:"networkSecurityRules,omitempty"` + PlacementProperties *map[string]string `json:"placementProperties,omitempty"` + ProvisioningState *ManagedResourceProvisioningState `json:"provisioningState,omitempty"` + SecureBootEnabled *bool `json:"secureBootEnabled,omitempty"` + SecurityType *SecurityType `json:"securityType,omitempty"` + ServiceArtifactReferenceId *string `json:"serviceArtifactReferenceId,omitempty"` + SpotRestoreTimeout *string `json:"spotRestoreTimeout,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` + UseDefaultPublicLoadBalancer *bool `json:"useDefaultPublicLoadBalancer,omitempty"` + UseEphemeralOSDisk *bool `json:"useEphemeralOSDisk,omitempty"` + UseTempDataDisk *bool `json:"useTempDataDisk,omitempty"` + VMExtensions *[]VMSSExtension `json:"vmExtensions,omitempty"` + VMImageOffer *string `json:"vmImageOffer,omitempty"` + VMImagePlan *VMImagePlan `json:"vmImagePlan,omitempty"` + VMImagePublisher *string `json:"vmImagePublisher,omitempty"` + VMImageResourceId *string `json:"vmImageResourceId,omitempty"` + VMImageSku *string `json:"vmImageSku,omitempty"` + VMImageVersion *string `json:"vmImageVersion,omitempty"` + VMInstanceCount int64 `json:"vmInstanceCount"` + VMManagedIdentity *identity.UserAssignedList `json:"vmManagedIdentity,omitempty"` + VMSecrets *[]VaultSecretGroup `json:"vmSecrets,omitempty"` + VMSetupActions *[]VMSetupAction `json:"vmSetupActions,omitempty"` + VMSharedGalleryImageId *string `json:"vmSharedGalleryImageId,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesku.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesku.go new file mode 100644 index 00000000000..f11d0df6224 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesku.go @@ -0,0 +1,10 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeSku struct { + Capacity int64 `json:"capacity"` + Name *string `json:"name,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeskucapacity.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeskucapacity.go new file mode 100644 index 00000000000..d483f7a215d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeskucapacity.go @@ -0,0 +1,11 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeSkuCapacity struct { + Default *int64 `json:"default,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *NodeTypeSkuScaleType `json:"scaleType,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesupportedsku.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesupportedsku.go new file mode 100644 index 00000000000..6a8485af8ca --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypesupportedsku.go @@ -0,0 +1,9 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeSupportedSku struct { + Name *string `json:"name,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeupdateparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeupdateparameters.go new file mode 100644 index 00000000000..682ba37bf90 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_nodetypeupdateparameters.go @@ -0,0 +1,9 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeUpdateParameters struct { + Sku *NodeTypeSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_subresource.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_subresource.go new file mode 100644 index 00000000000..0db3d206902 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_subresource.go @@ -0,0 +1,8 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_systemdata.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_systemdata.go new file mode 100644 index 00000000000..a09c384add5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_systemdata.go @@ -0,0 +1,43 @@ +package nodetype + +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 SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *string `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *string `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultcertificate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultcertificate.go new file mode 100644 index 00000000000..eff0354e640 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultcertificate.go @@ -0,0 +1,9 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultCertificate struct { + CertificateStore string `json:"certificateStore"` + CertificateUrl string `json:"certificateUrl"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultsecretgroup.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultsecretgroup.go new file mode 100644 index 00000000000..fc99643c0c1 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vaultsecretgroup.go @@ -0,0 +1,9 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VaultSecretGroup struct { + SourceVault SubResource `json:"sourceVault"` + VaultCertificates []VaultCertificate `json:"vaultCertificates"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmimageplan.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmimageplan.go new file mode 100644 index 00000000000..bc29e20b878 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmimageplan.go @@ -0,0 +1,11 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMImagePlan struct { + Name *string `json:"name,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher *string `json:"publisher,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssdatadisk.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssdatadisk.go new file mode 100644 index 00000000000..7b600129204 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssdatadisk.go @@ -0,0 +1,11 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMSSDataDisk struct { + DiskLetter string `json:"diskLetter"` + DiskSizeGB int64 `json:"diskSizeGB"` + DiskType DiskType `json:"diskType"` + Lun int64 `json:"lun"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextension.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextension.go new file mode 100644 index 00000000000..f63f087f1a0 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextension.go @@ -0,0 +1,9 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMSSExtension struct { + Name string `json:"name"` + Properties VMSSExtensionProperties `json:"properties"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextensionproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextensionproperties.go new file mode 100644 index 00000000000..c7f458e4bc9 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/model_vmssextensionproperties.go @@ -0,0 +1,18 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMSSExtensionProperties struct { + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + EnableAutomaticUpgrade *bool `json:"enableAutomaticUpgrade,omitempty"` + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + ProtectedSettings *interface{} `json:"protectedSettings,omitempty"` + ProvisionAfterExtensions *[]string `json:"provisionAfterExtensions,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Publisher string `json:"publisher"` + Settings *interface{} `json:"settings,omitempty"` + SetupOrder *[]VMSSExtensionSetupOrder `json:"setupOrder,omitempty"` + Type string `json:"type"` + TypeHandlerVersion string `json:"typeHandlerVersion"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/predicates.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/predicates.go new file mode 100644 index 00000000000..18091ff5ee6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/predicates.go @@ -0,0 +1,40 @@ +package nodetype + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeTypeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NodeTypeOperationPredicate) Matches(input NodeType) 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 +} + +type NodeTypeAvailableSkuOperationPredicate struct { + ResourceType *string +} + +func (p NodeTypeAvailableSkuOperationPredicate) Matches(input NodeTypeAvailableSku) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/version.go new file mode 100644 index 00000000000..93ad3206f3d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/nodetype/version.go @@ -0,0 +1,12 @@ +package nodetype + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/nodetype/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/README.md new file mode 100644 index 00000000000..f06a248596f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/service` Documentation + +The `service` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/service" +``` + + +### Client Initialization + +```go +client := service.NewServiceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServiceClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue") + +payload := service.ServiceResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceClient.Delete` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceClient.Get` + +```go +ctx := context.TODO() +id := service.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue") + +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: `ServiceClient.ListByApplications` + +```go +ctx := context.TODO() +id := service.NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + +// alternatively `client.ListByApplications(ctx, id)` can be used to do batched pagination +items, err := client.ListByApplicationsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/client.go new file mode 100644 index 00000000000..d0e66ae6f3f --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/client.go @@ -0,0 +1,26 @@ +package service + +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 ServiceClient struct { + Client *resourcemanager.Client +} + +func NewServiceClientWithBaseURI(sdkApi sdkEnv.Api) (*ServiceClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "service", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServiceClient: %+v", err) + } + + return &ServiceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/constants.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/constants.go new file mode 100644 index 00000000000..f07e70bf16a --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/constants.go @@ -0,0 +1,403 @@ +package service + +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 MoveCost string + +const ( + MoveCostHigh MoveCost = "High" + MoveCostLow MoveCost = "Low" + MoveCostMedium MoveCost = "Medium" + MoveCostZero MoveCost = "Zero" +) + +func PossibleValuesForMoveCost() []string { + return []string{ + string(MoveCostHigh), + string(MoveCostLow), + string(MoveCostMedium), + string(MoveCostZero), + } +} + +func (s *MoveCost) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMoveCost(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMoveCost(input string) (*MoveCost, error) { + vals := map[string]MoveCost{ + "high": MoveCostHigh, + "low": MoveCostLow, + "medium": MoveCostMedium, + "zero": MoveCostZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MoveCost(input) + return &out, nil +} + +type PartitionScheme string + +const ( + PartitionSchemeNamed PartitionScheme = "Named" + PartitionSchemeSingleton PartitionScheme = "Singleton" + PartitionSchemeUniformIntSixFourRange PartitionScheme = "UniformInt64Range" +) + +func PossibleValuesForPartitionScheme() []string { + return []string{ + string(PartitionSchemeNamed), + string(PartitionSchemeSingleton), + string(PartitionSchemeUniformIntSixFourRange), + } +} + +func (s *PartitionScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePartitionScheme(input string) (*PartitionScheme, error) { + vals := map[string]PartitionScheme{ + "named": PartitionSchemeNamed, + "singleton": PartitionSchemeSingleton, + "uniformint64range": PartitionSchemeUniformIntSixFourRange, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PartitionScheme(input) + return &out, nil +} + +type ServiceCorrelationScheme string + +const ( + ServiceCorrelationSchemeAlignedAffinity ServiceCorrelationScheme = "AlignedAffinity" + ServiceCorrelationSchemeNonAlignedAffinity ServiceCorrelationScheme = "NonAlignedAffinity" +) + +func PossibleValuesForServiceCorrelationScheme() []string { + return []string{ + string(ServiceCorrelationSchemeAlignedAffinity), + string(ServiceCorrelationSchemeNonAlignedAffinity), + } +} + +func (s *ServiceCorrelationScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceCorrelationScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceCorrelationScheme(input string) (*ServiceCorrelationScheme, error) { + vals := map[string]ServiceCorrelationScheme{ + "alignedaffinity": ServiceCorrelationSchemeAlignedAffinity, + "nonalignedaffinity": ServiceCorrelationSchemeNonAlignedAffinity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceCorrelationScheme(input) + return &out, nil +} + +type ServiceKind string + +const ( + ServiceKindStateful ServiceKind = "Stateful" + ServiceKindStateless ServiceKind = "Stateless" +) + +func PossibleValuesForServiceKind() []string { + return []string{ + string(ServiceKindStateful), + string(ServiceKindStateless), + } +} + +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceKind(input string) (*ServiceKind, error) { + vals := map[string]ServiceKind{ + "stateful": ServiceKindStateful, + "stateless": ServiceKindStateless, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceKind(input) + return &out, nil +} + +type ServiceLoadMetricWeight string + +const ( + ServiceLoadMetricWeightHigh ServiceLoadMetricWeight = "High" + ServiceLoadMetricWeightLow ServiceLoadMetricWeight = "Low" + ServiceLoadMetricWeightMedium ServiceLoadMetricWeight = "Medium" + ServiceLoadMetricWeightZero ServiceLoadMetricWeight = "Zero" +) + +func PossibleValuesForServiceLoadMetricWeight() []string { + return []string{ + string(ServiceLoadMetricWeightHigh), + string(ServiceLoadMetricWeightLow), + string(ServiceLoadMetricWeightMedium), + string(ServiceLoadMetricWeightZero), + } +} + +func (s *ServiceLoadMetricWeight) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLoadMetricWeight(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceLoadMetricWeight(input string) (*ServiceLoadMetricWeight, error) { + vals := map[string]ServiceLoadMetricWeight{ + "high": ServiceLoadMetricWeightHigh, + "low": ServiceLoadMetricWeightLow, + "medium": ServiceLoadMetricWeightMedium, + "zero": ServiceLoadMetricWeightZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceLoadMetricWeight(input) + return &out, nil +} + +type ServicePackageActivationMode string + +const ( + ServicePackageActivationModeExclusiveProcess ServicePackageActivationMode = "ExclusiveProcess" + ServicePackageActivationModeSharedProcess ServicePackageActivationMode = "SharedProcess" +) + +func PossibleValuesForServicePackageActivationMode() []string { + return []string{ + string(ServicePackageActivationModeExclusiveProcess), + string(ServicePackageActivationModeSharedProcess), + } +} + +func (s *ServicePackageActivationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePackageActivationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServicePackageActivationMode(input string) (*ServicePackageActivationMode, error) { + vals := map[string]ServicePackageActivationMode{ + "exclusiveprocess": ServicePackageActivationModeExclusiveProcess, + "sharedprocess": ServicePackageActivationModeSharedProcess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServicePackageActivationMode(input) + return &out, nil +} + +type ServicePlacementPolicyType string + +const ( + ServicePlacementPolicyTypeInvalidDomain ServicePlacementPolicyType = "InvalidDomain" + ServicePlacementPolicyTypeNonPartiallyPlaceService ServicePlacementPolicyType = "NonPartiallyPlaceService" + ServicePlacementPolicyTypePreferredPrimaryDomain ServicePlacementPolicyType = "PreferredPrimaryDomain" + ServicePlacementPolicyTypeRequiredDomain ServicePlacementPolicyType = "RequiredDomain" + ServicePlacementPolicyTypeRequiredDomainDistribution ServicePlacementPolicyType = "RequiredDomainDistribution" +) + +func PossibleValuesForServicePlacementPolicyType() []string { + return []string{ + string(ServicePlacementPolicyTypeInvalidDomain), + string(ServicePlacementPolicyTypeNonPartiallyPlaceService), + string(ServicePlacementPolicyTypePreferredPrimaryDomain), + string(ServicePlacementPolicyTypeRequiredDomain), + string(ServicePlacementPolicyTypeRequiredDomainDistribution), + } +} + +func (s *ServicePlacementPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePlacementPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServicePlacementPolicyType(input string) (*ServicePlacementPolicyType, error) { + vals := map[string]ServicePlacementPolicyType{ + "invaliddomain": ServicePlacementPolicyTypeInvalidDomain, + "nonpartiallyplaceservice": ServicePlacementPolicyTypeNonPartiallyPlaceService, + "preferredprimarydomain": ServicePlacementPolicyTypePreferredPrimaryDomain, + "requireddomain": ServicePlacementPolicyTypeRequiredDomain, + "requireddomaindistribution": ServicePlacementPolicyTypeRequiredDomainDistribution, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServicePlacementPolicyType(input) + return &out, nil +} + +type ServiceScalingMechanismKind string + +const ( + ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition ServiceScalingMechanismKind = "AddRemoveIncrementalNamedPartition" + ServiceScalingMechanismKindScalePartitionInstanceCount ServiceScalingMechanismKind = "ScalePartitionInstanceCount" +) + +func PossibleValuesForServiceScalingMechanismKind() []string { + return []string{ + string(ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition), + string(ServiceScalingMechanismKindScalePartitionInstanceCount), + } +} + +func (s *ServiceScalingMechanismKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingMechanismKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceScalingMechanismKind(input string) (*ServiceScalingMechanismKind, error) { + vals := map[string]ServiceScalingMechanismKind{ + "addremoveincrementalnamedpartition": ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition, + "scalepartitioninstancecount": ServiceScalingMechanismKindScalePartitionInstanceCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceScalingMechanismKind(input) + return &out, nil +} + +type ServiceScalingTriggerKind string + +const ( + ServiceScalingTriggerKindAveragePartitionLoadTrigger ServiceScalingTriggerKind = "AveragePartitionLoadTrigger" + ServiceScalingTriggerKindAverageServiceLoadTrigger ServiceScalingTriggerKind = "AverageServiceLoadTrigger" +) + +func PossibleValuesForServiceScalingTriggerKind() []string { + return []string{ + string(ServiceScalingTriggerKindAveragePartitionLoadTrigger), + string(ServiceScalingTriggerKindAverageServiceLoadTrigger), + } +} + +func (s *ServiceScalingTriggerKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingTriggerKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceScalingTriggerKind(input string) (*ServiceScalingTriggerKind, error) { + vals := map[string]ServiceScalingTriggerKind{ + "averagepartitionloadtrigger": ServiceScalingTriggerKindAveragePartitionLoadTrigger, + "averageserviceloadtrigger": ServiceScalingTriggerKindAverageServiceLoadTrigger, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceScalingTriggerKind(input) + return &out, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application.go new file mode 100644 index 00000000000..fdd8e3d27de --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application.go @@ -0,0 +1,139 @@ +package service + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationId{}) +} + +var _ resourceids.ResourceId = &ApplicationId{} + +// ApplicationId is a struct representing the Resource ID for a Application +type ApplicationId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + ApplicationName string +} + +// NewApplicationID returns a new ApplicationId struct +func NewApplicationID(subscriptionId string, resourceGroupName string, managedClusterName string, applicationName string) ApplicationId { + return ApplicationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + ApplicationName: applicationName, + } +} + +// ParseApplicationID parses 'input' into a ApplicationId +func ParseApplicationID(input string) (*ApplicationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationIDInsensitively parses 'input' case-insensitively into a ApplicationId +// note: this method should only be used for API response data and not user input +func ParseApplicationIDInsensitively(input string) (*ApplicationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.ApplicationName, ok = input.Parsed["applicationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationName", input) + } + + return nil +} + +// ValidateApplicationID checks that 'input' can be parsed as a Application ID +func ValidateApplicationID(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 := ParseApplicationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application ID +func (id ApplicationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/applications/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.ApplicationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application ID +func (id ApplicationId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticApplications", "applications", "applications"), + resourceids.UserSpecifiedSegment("applicationName", "applicationValue"), + } +} + +// String returns a human-readable description of this Application ID +func (id ApplicationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + } + return fmt.Sprintf("Application (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application_test.go new file mode 100644 index 00000000000..d39fa22d79c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_application_test.go @@ -0,0 +1,327 @@ +package service + +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 = &ApplicationId{} + +func TestNewApplicationID(t *testing.T) { + id := NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.ApplicationName != "applicationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationName'", id.ApplicationName, "applicationValue") + } +} + +func TestFormatApplicationID(t *testing.T) { + actual := NewApplicationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + } +} + +func TestParseApplicationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE", + Expected: &ApplicationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + ApplicationName: "aPpLiCaTiOnVaLuE", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + } +} + +func TestSegmentsForApplicationId(t *testing.T) { + segments := ApplicationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationId 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/servicefabricmanagedcluster/2024-04-01/service/id_service.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_service.go new file mode 100644 index 00000000000..511ab65f576 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_service.go @@ -0,0 +1,148 @@ +package service + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + ApplicationName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, managedClusterName string, applicationName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + ApplicationName: applicationName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.ApplicationName, ok = input.Parsed["applicationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(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 := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/applications/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.ApplicationName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticApplications", "applications", "applications"), + resourceids.UserSpecifiedSegment("applicationName", "applicationValue"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_service_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_service_test.go new file mode 100644 index 00000000000..6e0f62c688b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/id_service_test.go @@ -0,0 +1,372 @@ +package service + +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 = &ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.ApplicationName != "applicationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationName'", id.ApplicationName, "applicationValue") + } + + if id.ServiceName != "serviceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceName'", id.ServiceName, "serviceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + ServiceName: "serviceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + ServiceName: "serviceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/sErViCeS/sErViCeVaLuE", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + ApplicationName: "aPpLiCaTiOnVaLuE", + ServiceName: "sErViCeVaLuE", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/sErViCeS/sErViCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId 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/servicefabricmanagedcluster/2024-04-01/service/method_createorupdate.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_createorupdate.go new file mode 100644 index 00000000000..1c2db415434 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_createorupdate.go @@ -0,0 +1,75 @@ +package service + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// CreateOrUpdate ... +func (c ServiceClient) CreateOrUpdate(ctx context.Context, id ServiceId, input ServiceResource) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServiceClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceId, input ServiceResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_delete.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_delete.go new file mode 100644 index 00000000000..92913350903 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_delete.go @@ -0,0 +1,71 @@ +package service + +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 ServiceClient) Delete(ctx context.Context, id ServiceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ServiceClient) DeleteThenPoll(ctx context.Context, id ServiceId) 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/servicefabricmanagedcluster/2024-04-01/service/method_get.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_get.go new file mode 100644 index 00000000000..c1b6af71b21 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_get.go @@ -0,0 +1,54 @@ +package service + +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 *ServiceResource +} + +// Get ... +func (c ServiceClient) Get(ctx context.Context, id ServiceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ServiceResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_listbyapplications.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_listbyapplications.go new file mode 100644 index 00000000000..18aab2aedc2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/method_listbyapplications.go @@ -0,0 +1,91 @@ +package service + +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 ListByApplicationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceResource +} + +type ListByApplicationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceResource +} + +// ListByApplications ... +func (c ServiceClient) ListByApplications(ctx context.Context, id ApplicationId) (result ListByApplicationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/services", 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 *[]ServiceResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByApplicationsComplete retrieves all the results into a single object +func (c ServiceClient) ListByApplicationsComplete(ctx context.Context, id ApplicationId) (ListByApplicationsCompleteResult, error) { + return c.ListByApplicationsCompleteMatchingPredicate(ctx, id, ServiceResourceOperationPredicate{}) +} + +// ListByApplicationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServiceClient) ListByApplicationsCompleteMatchingPredicate(ctx context.Context, id ApplicationId, predicate ServiceResourceOperationPredicate) (result ListByApplicationsCompleteResult, err error) { + items := make([]ServiceResource, 0) + + resp, err := c.ListByApplications(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 = ListByApplicationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_addremoveincrementalnamedpartitionscalingmechanism.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_addremoveincrementalnamedpartitionscalingmechanism.go new file mode 100644 index 00000000000..05d633cb2d4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_addremoveincrementalnamedpartitionscalingmechanism.go @@ -0,0 +1,43 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingMechanism = AddRemoveIncrementalNamedPartitionScalingMechanism{} + +type AddRemoveIncrementalNamedPartitionScalingMechanism struct { + MaxPartitionCount int64 `json:"maxPartitionCount"` + MinPartitionCount int64 `json:"minPartitionCount"` + ScaleIncrement int64 `json:"scaleIncrement"` + + // Fields inherited from ScalingMechanism +} + +var _ json.Marshaler = AddRemoveIncrementalNamedPartitionScalingMechanism{} + +func (s AddRemoveIncrementalNamedPartitionScalingMechanism) MarshalJSON() ([]byte, error) { + type wrapper AddRemoveIncrementalNamedPartitionScalingMechanism + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + decoded["kind"] = "AddRemoveIncrementalNamedPartition" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averagepartitionloadscalingtrigger.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averagepartitionloadscalingtrigger.go new file mode 100644 index 00000000000..772f397c500 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averagepartitionloadscalingtrigger.go @@ -0,0 +1,44 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingTrigger = AveragePartitionLoadScalingTrigger{} + +type AveragePartitionLoadScalingTrigger struct { + LowerLoadThreshold float64 `json:"lowerLoadThreshold"` + MetricName string `json:"metricName"` + ScaleInterval string `json:"scaleInterval"` + UpperLoadThreshold float64 `json:"upperLoadThreshold"` + + // Fields inherited from ScalingTrigger +} + +var _ json.Marshaler = AveragePartitionLoadScalingTrigger{} + +func (s AveragePartitionLoadScalingTrigger) MarshalJSON() ([]byte, error) { + type wrapper AveragePartitionLoadScalingTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AveragePartitionLoadScalingTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AveragePartitionLoadScalingTrigger: %+v", err) + } + decoded["kind"] = "AveragePartitionLoadTrigger" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AveragePartitionLoadScalingTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averageserviceloadscalingtrigger.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averageserviceloadscalingtrigger.go new file mode 100644 index 00000000000..e811f2a7ca6 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_averageserviceloadscalingtrigger.go @@ -0,0 +1,45 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingTrigger = AverageServiceLoadScalingTrigger{} + +type AverageServiceLoadScalingTrigger struct { + LowerLoadThreshold float64 `json:"lowerLoadThreshold"` + MetricName string `json:"metricName"` + ScaleInterval string `json:"scaleInterval"` + UpperLoadThreshold float64 `json:"upperLoadThreshold"` + UseOnlyPrimaryLoad bool `json:"useOnlyPrimaryLoad"` + + // Fields inherited from ScalingTrigger +} + +var _ json.Marshaler = AverageServiceLoadScalingTrigger{} + +func (s AverageServiceLoadScalingTrigger) MarshalJSON() ([]byte, error) { + type wrapper AverageServiceLoadScalingTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AverageServiceLoadScalingTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AverageServiceLoadScalingTrigger: %+v", err) + } + decoded["kind"] = "AverageServiceLoadTrigger" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AverageServiceLoadScalingTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_namedpartitionscheme.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_namedpartitionscheme.go new file mode 100644 index 00000000000..f8190557f3d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_namedpartitionscheme.go @@ -0,0 +1,41 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Partition = NamedPartitionScheme{} + +type NamedPartitionScheme struct { + Names []string `json:"names"` + + // Fields inherited from Partition +} + +var _ json.Marshaler = NamedPartitionScheme{} + +func (s NamedPartitionScheme) MarshalJSON() ([]byte, error) { + type wrapper NamedPartitionScheme + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NamedPartitionScheme: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NamedPartitionScheme: %+v", err) + } + decoded["partitionScheme"] = "Named" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NamedPartitionScheme: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partition.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partition.go new file mode 100644 index 00000000000..4ef9596a357 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partition.go @@ -0,0 +1,69 @@ +package service + +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 Partition interface { +} + +// RawPartitionImpl 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 RawPartitionImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalPartitionImplementation(input []byte) (Partition, 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 Partition into map[string]interface: %+v", err) + } + + value, ok := temp["partitionScheme"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Named") { + var out NamedPartitionScheme + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NamedPartitionScheme: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Singleton") { + var out SingletonPartitionScheme + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingletonPartitionScheme: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UniformInt64Range") { + var out UniformInt64RangePartitionScheme + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UniformInt64RangePartitionScheme: %+v", err) + } + return out, nil + } + + out := RawPartitionImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partitioninstancecountscalemechanism.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partitioninstancecountscalemechanism.go new file mode 100644 index 00000000000..9b9ddde17bf --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_partitioninstancecountscalemechanism.go @@ -0,0 +1,43 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingMechanism = PartitionInstanceCountScaleMechanism{} + +type PartitionInstanceCountScaleMechanism struct { + MaxInstanceCount int64 `json:"maxInstanceCount"` + MinInstanceCount int64 `json:"minInstanceCount"` + ScaleIncrement int64 `json:"scaleIncrement"` + + // Fields inherited from ScalingMechanism +} + +var _ json.Marshaler = PartitionInstanceCountScaleMechanism{} + +func (s PartitionInstanceCountScaleMechanism) MarshalJSON() ([]byte, error) { + type wrapper PartitionInstanceCountScaleMechanism + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PartitionInstanceCountScaleMechanism: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PartitionInstanceCountScaleMechanism: %+v", err) + } + decoded["kind"] = "ScalePartitionInstanceCount" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PartitionInstanceCountScaleMechanism: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingmechanism.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingmechanism.go new file mode 100644 index 00000000000..19b84f9e2f3 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingmechanism.go @@ -0,0 +1,61 @@ +package service + +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 ScalingMechanism interface { +} + +// RawScalingMechanismImpl 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 RawScalingMechanismImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalScalingMechanismImplementation(input []byte) (ScalingMechanism, 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 ScalingMechanism into map[string]interface: %+v", err) + } + + value, ok := temp["kind"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AddRemoveIncrementalNamedPartition") { + var out AddRemoveIncrementalNamedPartitionScalingMechanism + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScalePartitionInstanceCount") { + var out PartitionInstanceCountScaleMechanism + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PartitionInstanceCountScaleMechanism: %+v", err) + } + return out, nil + } + + out := RawScalingMechanismImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingpolicy.go new file mode 100644 index 00000000000..c507f71e65c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingpolicy.go @@ -0,0 +1,41 @@ +package service + +import ( + "encoding/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 ScalingPolicy struct { + ScalingMechanism ScalingMechanism `json:"scalingMechanism"` + ScalingTrigger ScalingTrigger `json:"scalingTrigger"` +} + +var _ json.Unmarshaler = &ScalingPolicy{} + +func (s *ScalingPolicy) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ScalingPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["scalingMechanism"]; ok { + impl, err := unmarshalScalingMechanismImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ScalingMechanism' for 'ScalingPolicy': %+v", err) + } + s.ScalingMechanism = impl + } + + if v, ok := temp["scalingTrigger"]; ok { + impl, err := unmarshalScalingTriggerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ScalingTrigger' for 'ScalingPolicy': %+v", err) + } + s.ScalingTrigger = impl + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingtrigger.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingtrigger.go new file mode 100644 index 00000000000..84a29169ef3 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_scalingtrigger.go @@ -0,0 +1,61 @@ +package service + +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 ScalingTrigger interface { +} + +// RawScalingTriggerImpl 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 RawScalingTriggerImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalScalingTriggerImplementation(input []byte) (ScalingTrigger, 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 ScalingTrigger into map[string]interface: %+v", err) + } + + value, ok := temp["kind"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AveragePartitionLoadTrigger") { + var out AveragePartitionLoadScalingTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AveragePartitionLoadScalingTrigger: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AverageServiceLoadTrigger") { + var out AverageServiceLoadScalingTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AverageServiceLoadScalingTrigger: %+v", err) + } + return out, nil + } + + out := RawScalingTriggerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_servicecorrelation.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_servicecorrelation.go new file mode 100644 index 00000000000..ae65318851b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_servicecorrelation.go @@ -0,0 +1,9 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceCorrelation struct { + Scheme ServiceCorrelationScheme `json:"scheme"` + ServiceName string `json:"serviceName"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceloadmetric.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceloadmetric.go new file mode 100644 index 00000000000..98219e4582c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceloadmetric.go @@ -0,0 +1,12 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceLoadMetric struct { + DefaultLoad *int64 `json:"defaultLoad,omitempty"` + Name string `json:"name"` + PrimaryDefaultLoad *int64 `json:"primaryDefaultLoad,omitempty"` + SecondaryDefaultLoad *int64 `json:"secondaryDefaultLoad,omitempty"` + Weight *ServiceLoadMetricWeight `json:"weight,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementinvaliddomainpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementinvaliddomainpolicy.go new file mode 100644 index 00000000000..ed256b68ab2 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementinvaliddomainpolicy.go @@ -0,0 +1,41 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementInvalidDomainPolicy{} + +type ServicePlacementInvalidDomainPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementInvalidDomainPolicy{} + +func (s ServicePlacementInvalidDomainPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementInvalidDomainPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementInvalidDomainPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementInvalidDomainPolicy: %+v", err) + } + decoded["type"] = "InvalidDomain" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementInvalidDomainPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementnonpartiallyplaceservicepolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementnonpartiallyplaceservicepolicy.go new file mode 100644 index 00000000000..fd6ecbc222c --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementnonpartiallyplaceservicepolicy.go @@ -0,0 +1,40 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementNonPartiallyPlaceServicePolicy{} + +type ServicePlacementNonPartiallyPlaceServicePolicy struct { + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementNonPartiallyPlaceServicePolicy{} + +func (s ServicePlacementNonPartiallyPlaceServicePolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementNonPartiallyPlaceServicePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + decoded["type"] = "NonPartiallyPlaceService" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpolicy.go new file mode 100644 index 00000000000..0b0d9c8732e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpolicy.go @@ -0,0 +1,85 @@ +package service + +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 ServicePlacementPolicy interface { +} + +// RawServicePlacementPolicyImpl 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 RawServicePlacementPolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalServicePlacementPolicyImplementation(input []byte) (ServicePlacementPolicy, 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 ServicePlacementPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["type"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "InvalidDomain") { + var out ServicePlacementInvalidDomainPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementInvalidDomainPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "NonPartiallyPlaceService") { + var out ServicePlacementNonPartiallyPlaceServicePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PreferredPrimaryDomain") { + var out ServicePlacementPreferPrimaryDomainPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequiredDomainDistribution") { + var out ServicePlacementRequireDomainDistributionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequiredDomain") { + var out ServicePlacementRequiredDomainPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementRequiredDomainPolicy: %+v", err) + } + return out, nil + } + + out := RawServicePlacementPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpreferprimarydomainpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpreferprimarydomainpolicy.go new file mode 100644 index 00000000000..6df5a2f8689 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementpreferprimarydomainpolicy.go @@ -0,0 +1,41 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementPreferPrimaryDomainPolicy{} + +type ServicePlacementPreferPrimaryDomainPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementPreferPrimaryDomainPolicy{} + +func (s ServicePlacementPreferPrimaryDomainPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementPreferPrimaryDomainPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + decoded["type"] = "PreferredPrimaryDomain" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequireddomainpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequireddomainpolicy.go new file mode 100644 index 00000000000..d7acb1a7bbc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequireddomainpolicy.go @@ -0,0 +1,41 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementRequiredDomainPolicy{} + +type ServicePlacementRequiredDomainPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementRequiredDomainPolicy{} + +func (s ServicePlacementRequiredDomainPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementRequiredDomainPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementRequiredDomainPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementRequiredDomainPolicy: %+v", err) + } + decoded["type"] = "RequiredDomain" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementRequiredDomainPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequiredomaindistributionpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequiredomaindistributionpolicy.go new file mode 100644 index 00000000000..dbef3589507 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceplacementrequiredomaindistributionpolicy.go @@ -0,0 +1,41 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementRequireDomainDistributionPolicy{} + +type ServicePlacementRequireDomainDistributionPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementRequireDomainDistributionPolicy{} + +func (s ServicePlacementRequireDomainDistributionPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementRequireDomainDistributionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + decoded["type"] = "RequiredDomainDistribution" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresource.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresource.go new file mode 100644 index 00000000000..aaa2eacfa68 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresource.go @@ -0,0 +1,50 @@ +package service + +import ( + "encoding/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 ServiceResource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ServiceResourceProperties `json:"properties"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ServiceResource{} + +func (s *ServiceResource) UnmarshalJSON(bytes []byte) error { + type alias ServiceResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ServiceResource: %+v", err) + } + + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalServiceResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresourceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresourceproperties.go new file mode 100644 index 00000000000..7af97b98078 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_serviceresourceproperties.go @@ -0,0 +1,61 @@ +package service + +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 ServiceResourceProperties interface { +} + +// RawServiceResourcePropertiesImpl 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 RawServiceResourcePropertiesImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalServiceResourcePropertiesImplementation(input []byte) (ServiceResourceProperties, 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 ServiceResourceProperties into map[string]interface: %+v", err) + } + + value, ok := temp["serviceKind"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Stateful") { + var out StatefulServiceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into StatefulServiceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Stateless") { + var out StatelessServiceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into StatelessServiceProperties: %+v", err) + } + return out, nil + } + + out := RawServiceResourcePropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_singletonpartitionscheme.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_singletonpartitionscheme.go new file mode 100644 index 00000000000..733fa123a97 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_singletonpartitionscheme.go @@ -0,0 +1,40 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Partition = SingletonPartitionScheme{} + +type SingletonPartitionScheme struct { + + // Fields inherited from Partition +} + +var _ json.Marshaler = SingletonPartitionScheme{} + +func (s SingletonPartitionScheme) MarshalJSON() ([]byte, error) { + type wrapper SingletonPartitionScheme + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingletonPartitionScheme: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingletonPartitionScheme: %+v", err) + } + decoded["partitionScheme"] = "Singleton" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingletonPartitionScheme: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statefulserviceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statefulserviceproperties.go new file mode 100644 index 00000000000..8103ee306eb --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statefulserviceproperties.go @@ -0,0 +1,116 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceProperties = StatefulServiceProperties{} + +type StatefulServiceProperties struct { + HasPersistedState *bool `json:"hasPersistedState,omitempty"` + MinReplicaSetSize *int64 `json:"minReplicaSetSize,omitempty"` + QuorumLossWaitDuration *string `json:"quorumLossWaitDuration,omitempty"` + ReplicaRestartWaitDuration *string `json:"replicaRestartWaitDuration,omitempty"` + ServicePlacementTimeLimit *string `json:"servicePlacementTimeLimit,omitempty"` + StandByReplicaKeepDuration *string `json:"standByReplicaKeepDuration,omitempty"` + TargetReplicaSetSize *int64 `json:"targetReplicaSetSize,omitempty"` + + // Fields inherited from ServiceResourceProperties + CorrelationScheme *[]ServiceCorrelation `json:"correlationScheme,omitempty"` + DefaultMoveCost *MoveCost `json:"defaultMoveCost,omitempty"` + PartitionDescription Partition `json:"partitionDescription"` + PlacementConstraints *string `json:"placementConstraints,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ScalingPolicies *[]ScalingPolicy `json:"scalingPolicies,omitempty"` + ServiceDnsName *string `json:"serviceDnsName,omitempty"` + ServiceLoadMetrics *[]ServiceLoadMetric `json:"serviceLoadMetrics,omitempty"` + ServicePackageActivationMode *ServicePackageActivationMode `json:"servicePackageActivationMode,omitempty"` + ServicePlacementPolicies *[]ServicePlacementPolicy `json:"servicePlacementPolicies,omitempty"` + ServiceTypeName string `json:"serviceTypeName"` +} + +var _ json.Marshaler = StatefulServiceProperties{} + +func (s StatefulServiceProperties) MarshalJSON() ([]byte, error) { + type wrapper StatefulServiceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling StatefulServiceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling StatefulServiceProperties: %+v", err) + } + decoded["serviceKind"] = "Stateful" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling StatefulServiceProperties: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &StatefulServiceProperties{} + +func (s *StatefulServiceProperties) UnmarshalJSON(bytes []byte) error { + type alias StatefulServiceProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into StatefulServiceProperties: %+v", err) + } + + s.CorrelationScheme = decoded.CorrelationScheme + s.DefaultMoveCost = decoded.DefaultMoveCost + s.HasPersistedState = decoded.HasPersistedState + s.MinReplicaSetSize = decoded.MinReplicaSetSize + s.PlacementConstraints = decoded.PlacementConstraints + s.ProvisioningState = decoded.ProvisioningState + s.QuorumLossWaitDuration = decoded.QuorumLossWaitDuration + s.ReplicaRestartWaitDuration = decoded.ReplicaRestartWaitDuration + s.ScalingPolicies = decoded.ScalingPolicies + s.ServiceDnsName = decoded.ServiceDnsName + s.ServiceLoadMetrics = decoded.ServiceLoadMetrics + s.ServicePackageActivationMode = decoded.ServicePackageActivationMode + s.ServicePlacementTimeLimit = decoded.ServicePlacementTimeLimit + s.ServiceTypeName = decoded.ServiceTypeName + s.StandByReplicaKeepDuration = decoded.StandByReplicaKeepDuration + s.TargetReplicaSetSize = decoded.TargetReplicaSetSize + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling StatefulServiceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["partitionDescription"]; ok { + impl, err := unmarshalPartitionImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PartitionDescription' for 'StatefulServiceProperties': %+v", err) + } + s.PartitionDescription = impl + } + + if v, ok := temp["servicePlacementPolicies"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ServicePlacementPolicies into list []json.RawMessage: %+v", err) + } + + output := make([]ServicePlacementPolicy, 0) + for i, val := range listTemp { + impl, err := unmarshalServicePlacementPolicyImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ServicePlacementPolicies' for 'StatefulServiceProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ServicePlacementPolicies = &output + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statelessserviceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statelessserviceproperties.go new file mode 100644 index 00000000000..498aa637547 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_statelessserviceproperties.go @@ -0,0 +1,108 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceProperties = StatelessServiceProperties{} + +type StatelessServiceProperties struct { + InstanceCount int64 `json:"instanceCount"` + MinInstanceCount *int64 `json:"minInstanceCount,omitempty"` + MinInstancePercentage *int64 `json:"minInstancePercentage,omitempty"` + + // Fields inherited from ServiceResourceProperties + CorrelationScheme *[]ServiceCorrelation `json:"correlationScheme,omitempty"` + DefaultMoveCost *MoveCost `json:"defaultMoveCost,omitempty"` + PartitionDescription Partition `json:"partitionDescription"` + PlacementConstraints *string `json:"placementConstraints,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ScalingPolicies *[]ScalingPolicy `json:"scalingPolicies,omitempty"` + ServiceDnsName *string `json:"serviceDnsName,omitempty"` + ServiceLoadMetrics *[]ServiceLoadMetric `json:"serviceLoadMetrics,omitempty"` + ServicePackageActivationMode *ServicePackageActivationMode `json:"servicePackageActivationMode,omitempty"` + ServicePlacementPolicies *[]ServicePlacementPolicy `json:"servicePlacementPolicies,omitempty"` + ServiceTypeName string `json:"serviceTypeName"` +} + +var _ json.Marshaler = StatelessServiceProperties{} + +func (s StatelessServiceProperties) MarshalJSON() ([]byte, error) { + type wrapper StatelessServiceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling StatelessServiceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling StatelessServiceProperties: %+v", err) + } + decoded["serviceKind"] = "Stateless" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling StatelessServiceProperties: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &StatelessServiceProperties{} + +func (s *StatelessServiceProperties) UnmarshalJSON(bytes []byte) error { + type alias StatelessServiceProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into StatelessServiceProperties: %+v", err) + } + + s.CorrelationScheme = decoded.CorrelationScheme + s.DefaultMoveCost = decoded.DefaultMoveCost + s.InstanceCount = decoded.InstanceCount + s.MinInstanceCount = decoded.MinInstanceCount + s.MinInstancePercentage = decoded.MinInstancePercentage + s.PlacementConstraints = decoded.PlacementConstraints + s.ProvisioningState = decoded.ProvisioningState + s.ScalingPolicies = decoded.ScalingPolicies + s.ServiceDnsName = decoded.ServiceDnsName + s.ServiceLoadMetrics = decoded.ServiceLoadMetrics + s.ServicePackageActivationMode = decoded.ServicePackageActivationMode + s.ServiceTypeName = decoded.ServiceTypeName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling StatelessServiceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["partitionDescription"]; ok { + impl, err := unmarshalPartitionImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PartitionDescription' for 'StatelessServiceProperties': %+v", err) + } + s.PartitionDescription = impl + } + + if v, ok := temp["servicePlacementPolicies"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ServicePlacementPolicies into list []json.RawMessage: %+v", err) + } + + output := make([]ServicePlacementPolicy, 0) + for i, val := range listTemp { + impl, err := unmarshalServicePlacementPolicyImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ServicePlacementPolicies' for 'StatelessServiceProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ServicePlacementPolicies = &output + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_systemdata.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_systemdata.go new file mode 100644 index 00000000000..7d65e92eed1 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_systemdata.go @@ -0,0 +1,43 @@ +package service + +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 SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *string `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *string `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_uniformint64rangepartitionscheme.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_uniformint64rangepartitionscheme.go new file mode 100644 index 00000000000..7dc8a57063d --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/model_uniformint64rangepartitionscheme.go @@ -0,0 +1,43 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Partition = UniformInt64RangePartitionScheme{} + +type UniformInt64RangePartitionScheme struct { + Count int64 `json:"count"` + HighKey int64 `json:"highKey"` + LowKey int64 `json:"lowKey"` + + // Fields inherited from Partition +} + +var _ json.Marshaler = UniformInt64RangePartitionScheme{} + +func (s UniformInt64RangePartitionScheme) MarshalJSON() ([]byte, error) { + type wrapper UniformInt64RangePartitionScheme + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UniformInt64RangePartitionScheme: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UniformInt64RangePartitionScheme: %+v", err) + } + decoded["partitionScheme"] = "UniformInt64Range" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UniformInt64RangePartitionScheme: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/service/predicates.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/predicates.go new file mode 100644 index 00000000000..a8b0ffd4cca --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/predicates.go @@ -0,0 +1,32 @@ +package service + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ServiceResourceOperationPredicate) Matches(input ServiceResource) 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/servicefabricmanagedcluster/2024-04-01/service/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/version.go new file mode 100644 index 00000000000..ccc96696bd5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/service/version.go @@ -0,0 +1,12 @@ +package service + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/service/%s", defaultApiVersion) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/README.md b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/README.md new file mode 100644 index 00000000000..bc200bd0e52 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/servicefabricmanagedcluster/2024-04-01/services` Documentation + +The `services` SDK allows for interaction with the Azure Resource Manager Service `servicefabricmanagedcluster` (API Version `2024-04-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/servicefabricmanagedcluster/2024-04-01/services" +``` + + +### Client Initialization + +```go +client := services.NewServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServicesClient.Update` + +```go +ctx := context.TODO() +id := services.NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue") + +payload := services.ServiceUpdateParameters{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/client.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/client.go new file mode 100644 index 00000000000..dc4a72c1ff4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/client.go @@ -0,0 +1,26 @@ +package services + +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 ServicesClient struct { + Client *resourcemanager.Client +} + +func NewServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServicesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "services", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServicesClient: %+v", err) + } + + return &ServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/constants.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/constants.go new file mode 100644 index 00000000000..d63db0a55d5 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/constants.go @@ -0,0 +1,403 @@ +package services + +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 MoveCost string + +const ( + MoveCostHigh MoveCost = "High" + MoveCostLow MoveCost = "Low" + MoveCostMedium MoveCost = "Medium" + MoveCostZero MoveCost = "Zero" +) + +func PossibleValuesForMoveCost() []string { + return []string{ + string(MoveCostHigh), + string(MoveCostLow), + string(MoveCostMedium), + string(MoveCostZero), + } +} + +func (s *MoveCost) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMoveCost(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMoveCost(input string) (*MoveCost, error) { + vals := map[string]MoveCost{ + "high": MoveCostHigh, + "low": MoveCostLow, + "medium": MoveCostMedium, + "zero": MoveCostZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MoveCost(input) + return &out, nil +} + +type PartitionScheme string + +const ( + PartitionSchemeNamed PartitionScheme = "Named" + PartitionSchemeSingleton PartitionScheme = "Singleton" + PartitionSchemeUniformIntSixFourRange PartitionScheme = "UniformInt64Range" +) + +func PossibleValuesForPartitionScheme() []string { + return []string{ + string(PartitionSchemeNamed), + string(PartitionSchemeSingleton), + string(PartitionSchemeUniformIntSixFourRange), + } +} + +func (s *PartitionScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePartitionScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePartitionScheme(input string) (*PartitionScheme, error) { + vals := map[string]PartitionScheme{ + "named": PartitionSchemeNamed, + "singleton": PartitionSchemeSingleton, + "uniformint64range": PartitionSchemeUniformIntSixFourRange, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PartitionScheme(input) + return &out, nil +} + +type ServiceCorrelationScheme string + +const ( + ServiceCorrelationSchemeAlignedAffinity ServiceCorrelationScheme = "AlignedAffinity" + ServiceCorrelationSchemeNonAlignedAffinity ServiceCorrelationScheme = "NonAlignedAffinity" +) + +func PossibleValuesForServiceCorrelationScheme() []string { + return []string{ + string(ServiceCorrelationSchemeAlignedAffinity), + string(ServiceCorrelationSchemeNonAlignedAffinity), + } +} + +func (s *ServiceCorrelationScheme) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceCorrelationScheme(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceCorrelationScheme(input string) (*ServiceCorrelationScheme, error) { + vals := map[string]ServiceCorrelationScheme{ + "alignedaffinity": ServiceCorrelationSchemeAlignedAffinity, + "nonalignedaffinity": ServiceCorrelationSchemeNonAlignedAffinity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceCorrelationScheme(input) + return &out, nil +} + +type ServiceKind string + +const ( + ServiceKindStateful ServiceKind = "Stateful" + ServiceKindStateless ServiceKind = "Stateless" +) + +func PossibleValuesForServiceKind() []string { + return []string{ + string(ServiceKindStateful), + string(ServiceKindStateless), + } +} + +func (s *ServiceKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceKind(input string) (*ServiceKind, error) { + vals := map[string]ServiceKind{ + "stateful": ServiceKindStateful, + "stateless": ServiceKindStateless, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceKind(input) + return &out, nil +} + +type ServiceLoadMetricWeight string + +const ( + ServiceLoadMetricWeightHigh ServiceLoadMetricWeight = "High" + ServiceLoadMetricWeightLow ServiceLoadMetricWeight = "Low" + ServiceLoadMetricWeightMedium ServiceLoadMetricWeight = "Medium" + ServiceLoadMetricWeightZero ServiceLoadMetricWeight = "Zero" +) + +func PossibleValuesForServiceLoadMetricWeight() []string { + return []string{ + string(ServiceLoadMetricWeightHigh), + string(ServiceLoadMetricWeightLow), + string(ServiceLoadMetricWeightMedium), + string(ServiceLoadMetricWeightZero), + } +} + +func (s *ServiceLoadMetricWeight) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceLoadMetricWeight(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceLoadMetricWeight(input string) (*ServiceLoadMetricWeight, error) { + vals := map[string]ServiceLoadMetricWeight{ + "high": ServiceLoadMetricWeightHigh, + "low": ServiceLoadMetricWeightLow, + "medium": ServiceLoadMetricWeightMedium, + "zero": ServiceLoadMetricWeightZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceLoadMetricWeight(input) + return &out, nil +} + +type ServicePackageActivationMode string + +const ( + ServicePackageActivationModeExclusiveProcess ServicePackageActivationMode = "ExclusiveProcess" + ServicePackageActivationModeSharedProcess ServicePackageActivationMode = "SharedProcess" +) + +func PossibleValuesForServicePackageActivationMode() []string { + return []string{ + string(ServicePackageActivationModeExclusiveProcess), + string(ServicePackageActivationModeSharedProcess), + } +} + +func (s *ServicePackageActivationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePackageActivationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServicePackageActivationMode(input string) (*ServicePackageActivationMode, error) { + vals := map[string]ServicePackageActivationMode{ + "exclusiveprocess": ServicePackageActivationModeExclusiveProcess, + "sharedprocess": ServicePackageActivationModeSharedProcess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServicePackageActivationMode(input) + return &out, nil +} + +type ServicePlacementPolicyType string + +const ( + ServicePlacementPolicyTypeInvalidDomain ServicePlacementPolicyType = "InvalidDomain" + ServicePlacementPolicyTypeNonPartiallyPlaceService ServicePlacementPolicyType = "NonPartiallyPlaceService" + ServicePlacementPolicyTypePreferredPrimaryDomain ServicePlacementPolicyType = "PreferredPrimaryDomain" + ServicePlacementPolicyTypeRequiredDomain ServicePlacementPolicyType = "RequiredDomain" + ServicePlacementPolicyTypeRequiredDomainDistribution ServicePlacementPolicyType = "RequiredDomainDistribution" +) + +func PossibleValuesForServicePlacementPolicyType() []string { + return []string{ + string(ServicePlacementPolicyTypeInvalidDomain), + string(ServicePlacementPolicyTypeNonPartiallyPlaceService), + string(ServicePlacementPolicyTypePreferredPrimaryDomain), + string(ServicePlacementPolicyTypeRequiredDomain), + string(ServicePlacementPolicyTypeRequiredDomainDistribution), + } +} + +func (s *ServicePlacementPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServicePlacementPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServicePlacementPolicyType(input string) (*ServicePlacementPolicyType, error) { + vals := map[string]ServicePlacementPolicyType{ + "invaliddomain": ServicePlacementPolicyTypeInvalidDomain, + "nonpartiallyplaceservice": ServicePlacementPolicyTypeNonPartiallyPlaceService, + "preferredprimarydomain": ServicePlacementPolicyTypePreferredPrimaryDomain, + "requireddomain": ServicePlacementPolicyTypeRequiredDomain, + "requireddomaindistribution": ServicePlacementPolicyTypeRequiredDomainDistribution, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServicePlacementPolicyType(input) + return &out, nil +} + +type ServiceScalingMechanismKind string + +const ( + ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition ServiceScalingMechanismKind = "AddRemoveIncrementalNamedPartition" + ServiceScalingMechanismKindScalePartitionInstanceCount ServiceScalingMechanismKind = "ScalePartitionInstanceCount" +) + +func PossibleValuesForServiceScalingMechanismKind() []string { + return []string{ + string(ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition), + string(ServiceScalingMechanismKindScalePartitionInstanceCount), + } +} + +func (s *ServiceScalingMechanismKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingMechanismKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceScalingMechanismKind(input string) (*ServiceScalingMechanismKind, error) { + vals := map[string]ServiceScalingMechanismKind{ + "addremoveincrementalnamedpartition": ServiceScalingMechanismKindAddRemoveIncrementalNamedPartition, + "scalepartitioninstancecount": ServiceScalingMechanismKindScalePartitionInstanceCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceScalingMechanismKind(input) + return &out, nil +} + +type ServiceScalingTriggerKind string + +const ( + ServiceScalingTriggerKindAveragePartitionLoadTrigger ServiceScalingTriggerKind = "AveragePartitionLoadTrigger" + ServiceScalingTriggerKindAverageServiceLoadTrigger ServiceScalingTriggerKind = "AverageServiceLoadTrigger" +) + +func PossibleValuesForServiceScalingTriggerKind() []string { + return []string{ + string(ServiceScalingTriggerKindAveragePartitionLoadTrigger), + string(ServiceScalingTriggerKindAverageServiceLoadTrigger), + } +} + +func (s *ServiceScalingTriggerKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceScalingTriggerKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceScalingTriggerKind(input string) (*ServiceScalingTriggerKind, error) { + vals := map[string]ServiceScalingTriggerKind{ + "averagepartitionloadtrigger": ServiceScalingTriggerKindAveragePartitionLoadTrigger, + "averageserviceloadtrigger": ServiceScalingTriggerKindAverageServiceLoadTrigger, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceScalingTriggerKind(input) + return &out, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service.go new file mode 100644 index 00000000000..880fd20f767 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service.go @@ -0,0 +1,148 @@ +package services + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServiceId{}) +} + +var _ resourceids.ResourceId = &ServiceId{} + +// ServiceId is a struct representing the Resource ID for a Service +type ServiceId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + ApplicationName string + ServiceName string +} + +// NewServiceID returns a new ServiceId struct +func NewServiceID(subscriptionId string, resourceGroupName string, managedClusterName string, applicationName string, serviceName string) ServiceId { + return ServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + ApplicationName: applicationName, + ServiceName: serviceName, + } +} + +// ParseServiceID parses 'input' into a ServiceId +func ParseServiceID(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceIDInsensitively parses 'input' case-insensitively into a ServiceId +// note: this method should only be used for API response data and not user input +func ParseServiceIDInsensitively(input string) (*ServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceId) 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.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.ApplicationName, ok = input.Parsed["applicationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationName", input) + } + + if id.ServiceName, ok = input.Parsed["serviceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceName", input) + } + + return nil +} + +// ValidateServiceID checks that 'input' can be parsed as a Service ID +func ValidateServiceID(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 := ParseServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service ID +func (id ServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceFabric/managedClusters/%s/applications/%s/services/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.ApplicationName, id.ServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service ID +func (id ServiceId) 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("staticMicrosoftServiceFabric", "Microsoft.ServiceFabric", "Microsoft.ServiceFabric"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticApplications", "applications", "applications"), + resourceids.UserSpecifiedSegment("applicationName", "applicationValue"), + resourceids.StaticSegment("staticServices", "services", "services"), + resourceids.UserSpecifiedSegment("serviceName", "serviceValue"), + } +} + +// String returns a human-readable description of this Service ID +func (id ServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Application Name: %q", id.ApplicationName), + fmt.Sprintf("Service Name: %q", id.ServiceName), + } + return fmt.Sprintf("Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service_test.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service_test.go new file mode 100644 index 00000000000..ca4f808a223 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/id_service_test.go @@ -0,0 +1,372 @@ +package services + +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 = &ServiceId{} + +func TestNewServiceID(t *testing.T) { + id := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue") + + 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.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.ApplicationName != "applicationValue" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationName'", id.ApplicationName, "applicationValue") + } + + if id.ServiceName != "serviceValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceName'", id.ServiceName, "serviceValue") + } +} + +func TestFormatServiceID(t *testing.T) { + actual := NewServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "applicationValue", "serviceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + ServiceName: "serviceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestParseServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceId + }{ + { + // 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.ServiceFabric", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/sErViCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + ApplicationName: "applicationValue", + ServiceName: "serviceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ServiceFabric/managedClusters/managedClusterValue/applications/applicationValue/services/serviceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/sErViCeS/sErViCeVaLuE", + Expected: &ServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + ApplicationName: "aPpLiCaTiOnVaLuE", + ServiceName: "sErViCeVaLuE", + }, + }, + { + // 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.sErViCeFaBrIc/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aPpLiCaTiOnS/aPpLiCaTiOnVaLuE/sErViCeS/sErViCeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.ApplicationName != v.Expected.ApplicationName { + t.Fatalf("Expected %q but got %q for ApplicationName", v.Expected.ApplicationName, actual.ApplicationName) + } + + if actual.ServiceName != v.Expected.ServiceName { + t.Fatalf("Expected %q but got %q for ServiceName", v.Expected.ServiceName, actual.ServiceName) + } + + } +} + +func TestSegmentsForServiceId(t *testing.T) { + segments := ServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceId 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/servicefabricmanagedcluster/2024-04-01/services/method_update.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/method_update.go new file mode 100644 index 00000000000..6568dd496b4 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/method_update.go @@ -0,0 +1,58 @@ +package services + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceResource +} + +// Update ... +func (c ServicesClient) Update(ctx context.Context, id ServiceId, input ServiceUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model ServiceResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_addremoveincrementalnamedpartitionscalingmechanism.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_addremoveincrementalnamedpartitionscalingmechanism.go new file mode 100644 index 00000000000..1f1338f342e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_addremoveincrementalnamedpartitionscalingmechanism.go @@ -0,0 +1,43 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingMechanism = AddRemoveIncrementalNamedPartitionScalingMechanism{} + +type AddRemoveIncrementalNamedPartitionScalingMechanism struct { + MaxPartitionCount int64 `json:"maxPartitionCount"` + MinPartitionCount int64 `json:"minPartitionCount"` + ScaleIncrement int64 `json:"scaleIncrement"` + + // Fields inherited from ScalingMechanism +} + +var _ json.Marshaler = AddRemoveIncrementalNamedPartitionScalingMechanism{} + +func (s AddRemoveIncrementalNamedPartitionScalingMechanism) MarshalJSON() ([]byte, error) { + type wrapper AddRemoveIncrementalNamedPartitionScalingMechanism + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + decoded["kind"] = "AddRemoveIncrementalNamedPartition" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averagepartitionloadscalingtrigger.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averagepartitionloadscalingtrigger.go new file mode 100644 index 00000000000..723b0ba3d81 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averagepartitionloadscalingtrigger.go @@ -0,0 +1,44 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingTrigger = AveragePartitionLoadScalingTrigger{} + +type AveragePartitionLoadScalingTrigger struct { + LowerLoadThreshold float64 `json:"lowerLoadThreshold"` + MetricName string `json:"metricName"` + ScaleInterval string `json:"scaleInterval"` + UpperLoadThreshold float64 `json:"upperLoadThreshold"` + + // Fields inherited from ScalingTrigger +} + +var _ json.Marshaler = AveragePartitionLoadScalingTrigger{} + +func (s AveragePartitionLoadScalingTrigger) MarshalJSON() ([]byte, error) { + type wrapper AveragePartitionLoadScalingTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AveragePartitionLoadScalingTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AveragePartitionLoadScalingTrigger: %+v", err) + } + decoded["kind"] = "AveragePartitionLoadTrigger" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AveragePartitionLoadScalingTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averageserviceloadscalingtrigger.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averageserviceloadscalingtrigger.go new file mode 100644 index 00000000000..4600d2f3f69 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_averageserviceloadscalingtrigger.go @@ -0,0 +1,45 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingTrigger = AverageServiceLoadScalingTrigger{} + +type AverageServiceLoadScalingTrigger struct { + LowerLoadThreshold float64 `json:"lowerLoadThreshold"` + MetricName string `json:"metricName"` + ScaleInterval string `json:"scaleInterval"` + UpperLoadThreshold float64 `json:"upperLoadThreshold"` + UseOnlyPrimaryLoad bool `json:"useOnlyPrimaryLoad"` + + // Fields inherited from ScalingTrigger +} + +var _ json.Marshaler = AverageServiceLoadScalingTrigger{} + +func (s AverageServiceLoadScalingTrigger) MarshalJSON() ([]byte, error) { + type wrapper AverageServiceLoadScalingTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AverageServiceLoadScalingTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AverageServiceLoadScalingTrigger: %+v", err) + } + decoded["kind"] = "AverageServiceLoadTrigger" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AverageServiceLoadScalingTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_namedpartitionscheme.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_namedpartitionscheme.go new file mode 100644 index 00000000000..a915dbaa91e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_namedpartitionscheme.go @@ -0,0 +1,41 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Partition = NamedPartitionScheme{} + +type NamedPartitionScheme struct { + Names []string `json:"names"` + + // Fields inherited from Partition +} + +var _ json.Marshaler = NamedPartitionScheme{} + +func (s NamedPartitionScheme) MarshalJSON() ([]byte, error) { + type wrapper NamedPartitionScheme + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NamedPartitionScheme: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NamedPartitionScheme: %+v", err) + } + decoded["partitionScheme"] = "Named" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NamedPartitionScheme: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partition.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partition.go new file mode 100644 index 00000000000..364ee85f2ec --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partition.go @@ -0,0 +1,69 @@ +package services + +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 Partition interface { +} + +// RawPartitionImpl 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 RawPartitionImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalPartitionImplementation(input []byte) (Partition, 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 Partition into map[string]interface: %+v", err) + } + + value, ok := temp["partitionScheme"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Named") { + var out NamedPartitionScheme + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NamedPartitionScheme: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Singleton") { + var out SingletonPartitionScheme + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SingletonPartitionScheme: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UniformInt64Range") { + var out UniformInt64RangePartitionScheme + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UniformInt64RangePartitionScheme: %+v", err) + } + return out, nil + } + + out := RawPartitionImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partitioninstancecountscalemechanism.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partitioninstancecountscalemechanism.go new file mode 100644 index 00000000000..53db82dd0b3 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_partitioninstancecountscalemechanism.go @@ -0,0 +1,43 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScalingMechanism = PartitionInstanceCountScaleMechanism{} + +type PartitionInstanceCountScaleMechanism struct { + MaxInstanceCount int64 `json:"maxInstanceCount"` + MinInstanceCount int64 `json:"minInstanceCount"` + ScaleIncrement int64 `json:"scaleIncrement"` + + // Fields inherited from ScalingMechanism +} + +var _ json.Marshaler = PartitionInstanceCountScaleMechanism{} + +func (s PartitionInstanceCountScaleMechanism) MarshalJSON() ([]byte, error) { + type wrapper PartitionInstanceCountScaleMechanism + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PartitionInstanceCountScaleMechanism: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PartitionInstanceCountScaleMechanism: %+v", err) + } + decoded["kind"] = "ScalePartitionInstanceCount" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PartitionInstanceCountScaleMechanism: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingmechanism.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingmechanism.go new file mode 100644 index 00000000000..5b2b35b971b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingmechanism.go @@ -0,0 +1,61 @@ +package services + +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 ScalingMechanism interface { +} + +// RawScalingMechanismImpl 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 RawScalingMechanismImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalScalingMechanismImplementation(input []byte) (ScalingMechanism, 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 ScalingMechanism into map[string]interface: %+v", err) + } + + value, ok := temp["kind"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AddRemoveIncrementalNamedPartition") { + var out AddRemoveIncrementalNamedPartitionScalingMechanism + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AddRemoveIncrementalNamedPartitionScalingMechanism: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ScalePartitionInstanceCount") { + var out PartitionInstanceCountScaleMechanism + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PartitionInstanceCountScaleMechanism: %+v", err) + } + return out, nil + } + + out := RawScalingMechanismImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingpolicy.go new file mode 100644 index 00000000000..801d6b13753 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingpolicy.go @@ -0,0 +1,41 @@ +package services + +import ( + "encoding/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 ScalingPolicy struct { + ScalingMechanism ScalingMechanism `json:"scalingMechanism"` + ScalingTrigger ScalingTrigger `json:"scalingTrigger"` +} + +var _ json.Unmarshaler = &ScalingPolicy{} + +func (s *ScalingPolicy) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ScalingPolicy into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["scalingMechanism"]; ok { + impl, err := unmarshalScalingMechanismImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ScalingMechanism' for 'ScalingPolicy': %+v", err) + } + s.ScalingMechanism = impl + } + + if v, ok := temp["scalingTrigger"]; ok { + impl, err := unmarshalScalingTriggerImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ScalingTrigger' for 'ScalingPolicy': %+v", err) + } + s.ScalingTrigger = impl + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingtrigger.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingtrigger.go new file mode 100644 index 00000000000..c555bee6d53 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_scalingtrigger.go @@ -0,0 +1,61 @@ +package services + +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 ScalingTrigger interface { +} + +// RawScalingTriggerImpl 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 RawScalingTriggerImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalScalingTriggerImplementation(input []byte) (ScalingTrigger, 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 ScalingTrigger into map[string]interface: %+v", err) + } + + value, ok := temp["kind"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "AveragePartitionLoadTrigger") { + var out AveragePartitionLoadScalingTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AveragePartitionLoadScalingTrigger: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AverageServiceLoadTrigger") { + var out AverageServiceLoadScalingTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AverageServiceLoadScalingTrigger: %+v", err) + } + return out, nil + } + + out := RawScalingTriggerImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_servicecorrelation.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_servicecorrelation.go new file mode 100644 index 00000000000..e286d365dae --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_servicecorrelation.go @@ -0,0 +1,9 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceCorrelation struct { + Scheme ServiceCorrelationScheme `json:"scheme"` + ServiceName string `json:"serviceName"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceloadmetric.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceloadmetric.go new file mode 100644 index 00000000000..f67f664f8ae --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceloadmetric.go @@ -0,0 +1,12 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceLoadMetric struct { + DefaultLoad *int64 `json:"defaultLoad,omitempty"` + Name string `json:"name"` + PrimaryDefaultLoad *int64 `json:"primaryDefaultLoad,omitempty"` + SecondaryDefaultLoad *int64 `json:"secondaryDefaultLoad,omitempty"` + Weight *ServiceLoadMetricWeight `json:"weight,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementinvaliddomainpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementinvaliddomainpolicy.go new file mode 100644 index 00000000000..cbe686c0670 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementinvaliddomainpolicy.go @@ -0,0 +1,41 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementInvalidDomainPolicy{} + +type ServicePlacementInvalidDomainPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementInvalidDomainPolicy{} + +func (s ServicePlacementInvalidDomainPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementInvalidDomainPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementInvalidDomainPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementInvalidDomainPolicy: %+v", err) + } + decoded["type"] = "InvalidDomain" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementInvalidDomainPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementnonpartiallyplaceservicepolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementnonpartiallyplaceservicepolicy.go new file mode 100644 index 00000000000..5f377149c98 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementnonpartiallyplaceservicepolicy.go @@ -0,0 +1,40 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementNonPartiallyPlaceServicePolicy{} + +type ServicePlacementNonPartiallyPlaceServicePolicy struct { + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementNonPartiallyPlaceServicePolicy{} + +func (s ServicePlacementNonPartiallyPlaceServicePolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementNonPartiallyPlaceServicePolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + decoded["type"] = "NonPartiallyPlaceService" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpolicy.go new file mode 100644 index 00000000000..819b7ae2dbc --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpolicy.go @@ -0,0 +1,85 @@ +package services + +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 ServicePlacementPolicy interface { +} + +// RawServicePlacementPolicyImpl 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 RawServicePlacementPolicyImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalServicePlacementPolicyImplementation(input []byte) (ServicePlacementPolicy, 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 ServicePlacementPolicy into map[string]interface: %+v", err) + } + + value, ok := temp["type"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "InvalidDomain") { + var out ServicePlacementInvalidDomainPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementInvalidDomainPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "NonPartiallyPlaceService") { + var out ServicePlacementNonPartiallyPlaceServicePolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementNonPartiallyPlaceServicePolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PreferredPrimaryDomain") { + var out ServicePlacementPreferPrimaryDomainPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequiredDomainDistribution") { + var out ServicePlacementRequireDomainDistributionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "RequiredDomain") { + var out ServicePlacementRequiredDomainPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePlacementRequiredDomainPolicy: %+v", err) + } + return out, nil + } + + out := RawServicePlacementPolicyImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpreferprimarydomainpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpreferprimarydomainpolicy.go new file mode 100644 index 00000000000..c1036554340 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementpreferprimarydomainpolicy.go @@ -0,0 +1,41 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementPreferPrimaryDomainPolicy{} + +type ServicePlacementPreferPrimaryDomainPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementPreferPrimaryDomainPolicy{} + +func (s ServicePlacementPreferPrimaryDomainPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementPreferPrimaryDomainPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + decoded["type"] = "PreferredPrimaryDomain" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementPreferPrimaryDomainPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequireddomainpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequireddomainpolicy.go new file mode 100644 index 00000000000..30f269c6387 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequireddomainpolicy.go @@ -0,0 +1,41 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementRequiredDomainPolicy{} + +type ServicePlacementRequiredDomainPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementRequiredDomainPolicy{} + +func (s ServicePlacementRequiredDomainPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementRequiredDomainPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementRequiredDomainPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementRequiredDomainPolicy: %+v", err) + } + decoded["type"] = "RequiredDomain" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementRequiredDomainPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequiredomaindistributionpolicy.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequiredomaindistributionpolicy.go new file mode 100644 index 00000000000..43ea090c44e --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceplacementrequiredomaindistributionpolicy.go @@ -0,0 +1,41 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServicePlacementPolicy = ServicePlacementRequireDomainDistributionPolicy{} + +type ServicePlacementRequireDomainDistributionPolicy struct { + DomainName string `json:"domainName"` + + // Fields inherited from ServicePlacementPolicy +} + +var _ json.Marshaler = ServicePlacementRequireDomainDistributionPolicy{} + +func (s ServicePlacementRequireDomainDistributionPolicy) MarshalJSON() ([]byte, error) { + type wrapper ServicePlacementRequireDomainDistributionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + decoded["type"] = "RequiredDomainDistribution" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePlacementRequireDomainDistributionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresource.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresource.go new file mode 100644 index 00000000000..fdc4df6adfb --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresource.go @@ -0,0 +1,50 @@ +package services + +import ( + "encoding/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 ServiceResource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties ServiceResourceProperties `json:"properties"` + SystemData *SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ServiceResource{} + +func (s *ServiceResource) UnmarshalJSON(bytes []byte) error { + type alias ServiceResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into ServiceResource: %+v", err) + } + + s.Id = decoded.Id + s.Location = decoded.Location + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ServiceResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := unmarshalServiceResourcePropertiesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ServiceResource': %+v", err) + } + s.Properties = impl + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresourceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresourceproperties.go new file mode 100644 index 00000000000..f26311c14ee --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceresourceproperties.go @@ -0,0 +1,61 @@ +package services + +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 ServiceResourceProperties interface { +} + +// RawServiceResourcePropertiesImpl 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 RawServiceResourcePropertiesImpl struct { + Type string + Values map[string]interface{} +} + +func unmarshalServiceResourcePropertiesImplementation(input []byte) (ServiceResourceProperties, 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 ServiceResourceProperties into map[string]interface: %+v", err) + } + + value, ok := temp["serviceKind"].(string) + if !ok { + return nil, nil + } + + if strings.EqualFold(value, "Stateful") { + var out StatefulServiceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into StatefulServiceProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Stateless") { + var out StatelessServiceProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into StatelessServiceProperties: %+v", err) + } + return out, nil + } + + out := RawServiceResourcePropertiesImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceupdateparameters.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceupdateparameters.go new file mode 100644 index 00000000000..663e1b7dd08 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_serviceupdateparameters.go @@ -0,0 +1,8 @@ +package services + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceUpdateParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_singletonpartitionscheme.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_singletonpartitionscheme.go new file mode 100644 index 00000000000..4f463746341 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_singletonpartitionscheme.go @@ -0,0 +1,40 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Partition = SingletonPartitionScheme{} + +type SingletonPartitionScheme struct { + + // Fields inherited from Partition +} + +var _ json.Marshaler = SingletonPartitionScheme{} + +func (s SingletonPartitionScheme) MarshalJSON() ([]byte, error) { + type wrapper SingletonPartitionScheme + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SingletonPartitionScheme: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SingletonPartitionScheme: %+v", err) + } + decoded["partitionScheme"] = "Singleton" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SingletonPartitionScheme: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statefulserviceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statefulserviceproperties.go new file mode 100644 index 00000000000..29565f55c24 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statefulserviceproperties.go @@ -0,0 +1,116 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceProperties = StatefulServiceProperties{} + +type StatefulServiceProperties struct { + HasPersistedState *bool `json:"hasPersistedState,omitempty"` + MinReplicaSetSize *int64 `json:"minReplicaSetSize,omitempty"` + QuorumLossWaitDuration *string `json:"quorumLossWaitDuration,omitempty"` + ReplicaRestartWaitDuration *string `json:"replicaRestartWaitDuration,omitempty"` + ServicePlacementTimeLimit *string `json:"servicePlacementTimeLimit,omitempty"` + StandByReplicaKeepDuration *string `json:"standByReplicaKeepDuration,omitempty"` + TargetReplicaSetSize *int64 `json:"targetReplicaSetSize,omitempty"` + + // Fields inherited from ServiceResourceProperties + CorrelationScheme *[]ServiceCorrelation `json:"correlationScheme,omitempty"` + DefaultMoveCost *MoveCost `json:"defaultMoveCost,omitempty"` + PartitionDescription Partition `json:"partitionDescription"` + PlacementConstraints *string `json:"placementConstraints,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ScalingPolicies *[]ScalingPolicy `json:"scalingPolicies,omitempty"` + ServiceDnsName *string `json:"serviceDnsName,omitempty"` + ServiceLoadMetrics *[]ServiceLoadMetric `json:"serviceLoadMetrics,omitempty"` + ServicePackageActivationMode *ServicePackageActivationMode `json:"servicePackageActivationMode,omitempty"` + ServicePlacementPolicies *[]ServicePlacementPolicy `json:"servicePlacementPolicies,omitempty"` + ServiceTypeName string `json:"serviceTypeName"` +} + +var _ json.Marshaler = StatefulServiceProperties{} + +func (s StatefulServiceProperties) MarshalJSON() ([]byte, error) { + type wrapper StatefulServiceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling StatefulServiceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling StatefulServiceProperties: %+v", err) + } + decoded["serviceKind"] = "Stateful" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling StatefulServiceProperties: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &StatefulServiceProperties{} + +func (s *StatefulServiceProperties) UnmarshalJSON(bytes []byte) error { + type alias StatefulServiceProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into StatefulServiceProperties: %+v", err) + } + + s.CorrelationScheme = decoded.CorrelationScheme + s.DefaultMoveCost = decoded.DefaultMoveCost + s.HasPersistedState = decoded.HasPersistedState + s.MinReplicaSetSize = decoded.MinReplicaSetSize + s.PlacementConstraints = decoded.PlacementConstraints + s.ProvisioningState = decoded.ProvisioningState + s.QuorumLossWaitDuration = decoded.QuorumLossWaitDuration + s.ReplicaRestartWaitDuration = decoded.ReplicaRestartWaitDuration + s.ScalingPolicies = decoded.ScalingPolicies + s.ServiceDnsName = decoded.ServiceDnsName + s.ServiceLoadMetrics = decoded.ServiceLoadMetrics + s.ServicePackageActivationMode = decoded.ServicePackageActivationMode + s.ServicePlacementTimeLimit = decoded.ServicePlacementTimeLimit + s.ServiceTypeName = decoded.ServiceTypeName + s.StandByReplicaKeepDuration = decoded.StandByReplicaKeepDuration + s.TargetReplicaSetSize = decoded.TargetReplicaSetSize + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling StatefulServiceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["partitionDescription"]; ok { + impl, err := unmarshalPartitionImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PartitionDescription' for 'StatefulServiceProperties': %+v", err) + } + s.PartitionDescription = impl + } + + if v, ok := temp["servicePlacementPolicies"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ServicePlacementPolicies into list []json.RawMessage: %+v", err) + } + + output := make([]ServicePlacementPolicy, 0) + for i, val := range listTemp { + impl, err := unmarshalServicePlacementPolicyImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ServicePlacementPolicies' for 'StatefulServiceProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ServicePlacementPolicies = &output + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statelessserviceproperties.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statelessserviceproperties.go new file mode 100644 index 00000000000..ee4c4700a7b --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_statelessserviceproperties.go @@ -0,0 +1,108 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ServiceResourceProperties = StatelessServiceProperties{} + +type StatelessServiceProperties struct { + InstanceCount int64 `json:"instanceCount"` + MinInstanceCount *int64 `json:"minInstanceCount,omitempty"` + MinInstancePercentage *int64 `json:"minInstancePercentage,omitempty"` + + // Fields inherited from ServiceResourceProperties + CorrelationScheme *[]ServiceCorrelation `json:"correlationScheme,omitempty"` + DefaultMoveCost *MoveCost `json:"defaultMoveCost,omitempty"` + PartitionDescription Partition `json:"partitionDescription"` + PlacementConstraints *string `json:"placementConstraints,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ScalingPolicies *[]ScalingPolicy `json:"scalingPolicies,omitempty"` + ServiceDnsName *string `json:"serviceDnsName,omitempty"` + ServiceLoadMetrics *[]ServiceLoadMetric `json:"serviceLoadMetrics,omitempty"` + ServicePackageActivationMode *ServicePackageActivationMode `json:"servicePackageActivationMode,omitempty"` + ServicePlacementPolicies *[]ServicePlacementPolicy `json:"servicePlacementPolicies,omitempty"` + ServiceTypeName string `json:"serviceTypeName"` +} + +var _ json.Marshaler = StatelessServiceProperties{} + +func (s StatelessServiceProperties) MarshalJSON() ([]byte, error) { + type wrapper StatelessServiceProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling StatelessServiceProperties: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling StatelessServiceProperties: %+v", err) + } + decoded["serviceKind"] = "Stateless" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling StatelessServiceProperties: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &StatelessServiceProperties{} + +func (s *StatelessServiceProperties) UnmarshalJSON(bytes []byte) error { + type alias StatelessServiceProperties + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into StatelessServiceProperties: %+v", err) + } + + s.CorrelationScheme = decoded.CorrelationScheme + s.DefaultMoveCost = decoded.DefaultMoveCost + s.InstanceCount = decoded.InstanceCount + s.MinInstanceCount = decoded.MinInstanceCount + s.MinInstancePercentage = decoded.MinInstancePercentage + s.PlacementConstraints = decoded.PlacementConstraints + s.ProvisioningState = decoded.ProvisioningState + s.ScalingPolicies = decoded.ScalingPolicies + s.ServiceDnsName = decoded.ServiceDnsName + s.ServiceLoadMetrics = decoded.ServiceLoadMetrics + s.ServicePackageActivationMode = decoded.ServicePackageActivationMode + s.ServiceTypeName = decoded.ServiceTypeName + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling StatelessServiceProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["partitionDescription"]; ok { + impl, err := unmarshalPartitionImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'PartitionDescription' for 'StatelessServiceProperties': %+v", err) + } + s.PartitionDescription = impl + } + + if v, ok := temp["servicePlacementPolicies"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ServicePlacementPolicies into list []json.RawMessage: %+v", err) + } + + output := make([]ServicePlacementPolicy, 0) + for i, val := range listTemp { + impl, err := unmarshalServicePlacementPolicyImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ServicePlacementPolicies' for 'StatelessServiceProperties': %+v", i, err) + } + output = append(output, impl) + } + s.ServicePlacementPolicies = &output + } + return nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_systemdata.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_systemdata.go new file mode 100644 index 00000000000..f49e3d97445 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_systemdata.go @@ -0,0 +1,43 @@ +package services + +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 SystemData struct { + CreatedAt *string `json:"createdAt,omitempty"` + CreatedBy *string `json:"createdBy,omitempty"` + CreatedByType *string `json:"createdByType,omitempty"` + LastModifiedAt *string `json:"lastModifiedAt,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedByType *string `json:"lastModifiedByType,omitempty"` +} + +func (o *SystemData) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *SystemData) GetLastModifiedAtAsTime() (*time.Time, error) { + if o.LastModifiedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *SystemData) SetLastModifiedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedAt = &formatted +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_uniformint64rangepartitionscheme.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_uniformint64rangepartitionscheme.go new file mode 100644 index 00000000000..573d905f9be --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/model_uniformint64rangepartitionscheme.go @@ -0,0 +1,43 @@ +package services + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Partition = UniformInt64RangePartitionScheme{} + +type UniformInt64RangePartitionScheme struct { + Count int64 `json:"count"` + HighKey int64 `json:"highKey"` + LowKey int64 `json:"lowKey"` + + // Fields inherited from Partition +} + +var _ json.Marshaler = UniformInt64RangePartitionScheme{} + +func (s UniformInt64RangePartitionScheme) MarshalJSON() ([]byte, error) { + type wrapper UniformInt64RangePartitionScheme + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UniformInt64RangePartitionScheme: %+v", err) + } + + var decoded map[string]interface{} + if err := json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UniformInt64RangePartitionScheme: %+v", err) + } + decoded["partitionScheme"] = "UniformInt64Range" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UniformInt64RangePartitionScheme: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/servicefabricmanagedcluster/2024-04-01/services/version.go b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/version.go new file mode 100644 index 00000000000..a4433d1c2c1 --- /dev/null +++ b/resource-manager/servicefabricmanagedcluster/2024-04-01/services/version.go @@ -0,0 +1,12 @@ +package services + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/services/%s", defaultApiVersion) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/README.md b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/README.md new file mode 100644 index 00000000000..7fdf992168d --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners` Documentation + +The `availabilitygrouplisteners` SDK allows for interaction with the Azure Resource Manager Service `sqlvirtualmachine` (API Version `2023-10-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners" +``` + + +### Client Initialization + +```go +client := availabilitygrouplisteners.NewAvailabilityGroupListenersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AvailabilityGroupListenersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := availabilitygrouplisteners.NewAvailabilityGroupListenerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue", "availabilityGroupListenerValue") + +payload := availabilitygrouplisteners.AvailabilityGroupListener{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AvailabilityGroupListenersClient.Delete` + +```go +ctx := context.TODO() +id := availabilitygrouplisteners.NewAvailabilityGroupListenerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue", "availabilityGroupListenerValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AvailabilityGroupListenersClient.Get` + +```go +ctx := context.TODO() +id := availabilitygrouplisteners.NewAvailabilityGroupListenerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue", "availabilityGroupListenerValue") + +read, err := client.Get(ctx, id, availabilitygrouplisteners.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AvailabilityGroupListenersClient.ListByGroup` + +```go +ctx := context.TODO() +id := availabilitygrouplisteners.NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + +// alternatively `client.ListByGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/client.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/client.go new file mode 100644 index 00000000000..dd5ea297a04 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/client.go @@ -0,0 +1,26 @@ +package availabilitygrouplisteners + +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 AvailabilityGroupListenersClient struct { + Client *resourcemanager.Client +} + +func NewAvailabilityGroupListenersClientWithBaseURI(sdkApi sdkEnv.Api) (*AvailabilityGroupListenersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "availabilitygrouplisteners", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AvailabilityGroupListenersClient: %+v", err) + } + + return &AvailabilityGroupListenersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/constants.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/constants.go new file mode 100644 index 00000000000..0a44c460cc5 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/constants.go @@ -0,0 +1,177 @@ +package availabilitygrouplisteners + +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 Commit string + +const ( + CommitAsynchronousCommit Commit = "Asynchronous_Commit" + CommitSynchronousCommit Commit = "Synchronous_Commit" +) + +func PossibleValuesForCommit() []string { + return []string{ + string(CommitAsynchronousCommit), + string(CommitSynchronousCommit), + } +} + +func (s *Commit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCommit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCommit(input string) (*Commit, error) { + vals := map[string]Commit{ + "asynchronous_commit": CommitAsynchronousCommit, + "synchronous_commit": CommitSynchronousCommit, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Commit(input) + return &out, nil +} + +type Failover string + +const ( + FailoverAutomatic Failover = "Automatic" + FailoverManual Failover = "Manual" +) + +func PossibleValuesForFailover() []string { + return []string{ + string(FailoverAutomatic), + string(FailoverManual), + } +} + +func (s *Failover) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailover(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailover(input string) (*Failover, error) { + vals := map[string]Failover{ + "automatic": FailoverAutomatic, + "manual": FailoverManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Failover(input) + return &out, nil +} + +type ReadableSecondary string + +const ( + ReadableSecondaryAll ReadableSecondary = "All" + ReadableSecondaryNo ReadableSecondary = "No" + ReadableSecondaryReadOnly ReadableSecondary = "Read_Only" +) + +func PossibleValuesForReadableSecondary() []string { + return []string{ + string(ReadableSecondaryAll), + string(ReadableSecondaryNo), + string(ReadableSecondaryReadOnly), + } +} + +func (s *ReadableSecondary) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReadableSecondary(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReadableSecondary(input string) (*ReadableSecondary, error) { + vals := map[string]ReadableSecondary{ + "all": ReadableSecondaryAll, + "no": ReadableSecondaryNo, + "read_only": ReadableSecondaryReadOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReadableSecondary(input) + return &out, nil +} + +type Role string + +const ( + RolePrimary Role = "Primary" + RoleSecondary Role = "Secondary" +) + +func PossibleValuesForRole() []string { + return []string{ + string(RolePrimary), + string(RoleSecondary), + } +} + +func (s *Role) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRole(input string) (*Role, error) { + vals := map[string]Role{ + "primary": RolePrimary, + "secondary": RoleSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Role(input) + return &out, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener.go new file mode 100644 index 00000000000..a98aa636876 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener.go @@ -0,0 +1,139 @@ +package availabilitygrouplisteners + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AvailabilityGroupListenerId{}) +} + +var _ resourceids.ResourceId = &AvailabilityGroupListenerId{} + +// AvailabilityGroupListenerId is a struct representing the Resource ID for a Availability Group Listener +type AvailabilityGroupListenerId struct { + SubscriptionId string + ResourceGroupName string + SqlVirtualMachineGroupName string + AvailabilityGroupListenerName string +} + +// NewAvailabilityGroupListenerID returns a new AvailabilityGroupListenerId struct +func NewAvailabilityGroupListenerID(subscriptionId string, resourceGroupName string, sqlVirtualMachineGroupName string, availabilityGroupListenerName string) AvailabilityGroupListenerId { + return AvailabilityGroupListenerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SqlVirtualMachineGroupName: sqlVirtualMachineGroupName, + AvailabilityGroupListenerName: availabilityGroupListenerName, + } +} + +// ParseAvailabilityGroupListenerID parses 'input' into a AvailabilityGroupListenerId +func ParseAvailabilityGroupListenerID(input string) (*AvailabilityGroupListenerId, error) { + parser := resourceids.NewParserFromResourceIdType(&AvailabilityGroupListenerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AvailabilityGroupListenerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAvailabilityGroupListenerIDInsensitively parses 'input' case-insensitively into a AvailabilityGroupListenerId +// note: this method should only be used for API response data and not user input +func ParseAvailabilityGroupListenerIDInsensitively(input string) (*AvailabilityGroupListenerId, error) { + parser := resourceids.NewParserFromResourceIdType(&AvailabilityGroupListenerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AvailabilityGroupListenerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AvailabilityGroupListenerId) 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.SqlVirtualMachineGroupName, ok = input.Parsed["sqlVirtualMachineGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlVirtualMachineGroupName", input) + } + + if id.AvailabilityGroupListenerName, ok = input.Parsed["availabilityGroupListenerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "availabilityGroupListenerName", input) + } + + return nil +} + +// ValidateAvailabilityGroupListenerID checks that 'input' can be parsed as a Availability Group Listener ID +func ValidateAvailabilityGroupListenerID(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 := ParseAvailabilityGroupListenerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Availability Group Listener ID +func (id AvailabilityGroupListenerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/%s/availabilityGroupListeners/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SqlVirtualMachineGroupName, id.AvailabilityGroupListenerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Availability Group Listener ID +func (id AvailabilityGroupListenerId) 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("staticMicrosoftSqlVirtualMachine", "Microsoft.SqlVirtualMachine", "Microsoft.SqlVirtualMachine"), + resourceids.StaticSegment("staticSqlVirtualMachineGroups", "sqlVirtualMachineGroups", "sqlVirtualMachineGroups"), + resourceids.UserSpecifiedSegment("sqlVirtualMachineGroupName", "sqlVirtualMachineGroupValue"), + resourceids.StaticSegment("staticAvailabilityGroupListeners", "availabilityGroupListeners", "availabilityGroupListeners"), + resourceids.UserSpecifiedSegment("availabilityGroupListenerName", "availabilityGroupListenerValue"), + } +} + +// String returns a human-readable description of this Availability Group Listener ID +func (id AvailabilityGroupListenerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sql Virtual Machine Group Name: %q", id.SqlVirtualMachineGroupName), + fmt.Sprintf("Availability Group Listener Name: %q", id.AvailabilityGroupListenerName), + } + return fmt.Sprintf("Availability Group Listener (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener_test.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener_test.go new file mode 100644 index 00000000000..196529c564b --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_availabilitygrouplistener_test.go @@ -0,0 +1,327 @@ +package availabilitygrouplisteners + +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 = &AvailabilityGroupListenerId{} + +func TestNewAvailabilityGroupListenerID(t *testing.T) { + id := NewAvailabilityGroupListenerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue", "availabilityGroupListenerValue") + + 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.SqlVirtualMachineGroupName != "sqlVirtualMachineGroupValue" { + t.Fatalf("Expected %q but got %q for Segment 'SqlVirtualMachineGroupName'", id.SqlVirtualMachineGroupName, "sqlVirtualMachineGroupValue") + } + + if id.AvailabilityGroupListenerName != "availabilityGroupListenerValue" { + t.Fatalf("Expected %q but got %q for Segment 'AvailabilityGroupListenerName'", id.AvailabilityGroupListenerName, "availabilityGroupListenerValue") + } +} + +func TestFormatAvailabilityGroupListenerID(t *testing.T) { + actual := NewAvailabilityGroupListenerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue", "availabilityGroupListenerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/availabilityGroupListeners/availabilityGroupListenerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAvailabilityGroupListenerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AvailabilityGroupListenerId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/availabilityGroupListeners", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/availabilityGroupListeners/availabilityGroupListenerValue", + Expected: &AvailabilityGroupListenerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + AvailabilityGroupListenerName: "availabilityGroupListenerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/availabilityGroupListeners/availabilityGroupListenerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAvailabilityGroupListenerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + if actual.AvailabilityGroupListenerName != v.Expected.AvailabilityGroupListenerName { + t.Fatalf("Expected %q but got %q for AvailabilityGroupListenerName", v.Expected.AvailabilityGroupListenerName, actual.AvailabilityGroupListenerName) + } + + } +} + +func TestParseAvailabilityGroupListenerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AvailabilityGroupListenerId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/availabilityGroupListeners", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe/aVaIlAbIlItYgRoUpLiStEnErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/availabilityGroupListeners/availabilityGroupListenerValue", + Expected: &AvailabilityGroupListenerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + AvailabilityGroupListenerName: "availabilityGroupListenerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/availabilityGroupListeners/availabilityGroupListenerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe/aVaIlAbIlItYgRoUpLiStEnErS/aVaIlAbIlItYgRoUpLiStEnErVaLuE", + Expected: &AvailabilityGroupListenerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SqlVirtualMachineGroupName: "sQlViRtUaLmAcHiNeGrOuPvAlUe", + AvailabilityGroupListenerName: "aVaIlAbIlItYgRoUpLiStEnErVaLuE", + }, + }, + { + // 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.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe/aVaIlAbIlItYgRoUpLiStEnErS/aVaIlAbIlItYgRoUpLiStEnErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAvailabilityGroupListenerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + if actual.AvailabilityGroupListenerName != v.Expected.AvailabilityGroupListenerName { + t.Fatalf("Expected %q but got %q for AvailabilityGroupListenerName", v.Expected.AvailabilityGroupListenerName, actual.AvailabilityGroupListenerName) + } + + } +} + +func TestSegmentsForAvailabilityGroupListenerId(t *testing.T) { + segments := AvailabilityGroupListenerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AvailabilityGroupListenerId 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/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup.go new file mode 100644 index 00000000000..d8653552093 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup.go @@ -0,0 +1,130 @@ +package availabilitygrouplisteners + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SqlVirtualMachineGroupId{}) +} + +var _ resourceids.ResourceId = &SqlVirtualMachineGroupId{} + +// SqlVirtualMachineGroupId is a struct representing the Resource ID for a Sql Virtual Machine Group +type SqlVirtualMachineGroupId struct { + SubscriptionId string + ResourceGroupName string + SqlVirtualMachineGroupName string +} + +// NewSqlVirtualMachineGroupID returns a new SqlVirtualMachineGroupId struct +func NewSqlVirtualMachineGroupID(subscriptionId string, resourceGroupName string, sqlVirtualMachineGroupName string) SqlVirtualMachineGroupId { + return SqlVirtualMachineGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SqlVirtualMachineGroupName: sqlVirtualMachineGroupName, + } +} + +// ParseSqlVirtualMachineGroupID parses 'input' into a SqlVirtualMachineGroupId +func ParseSqlVirtualMachineGroupID(input string) (*SqlVirtualMachineGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSqlVirtualMachineGroupIDInsensitively parses 'input' case-insensitively into a SqlVirtualMachineGroupId +// note: this method should only be used for API response data and not user input +func ParseSqlVirtualMachineGroupIDInsensitively(input string) (*SqlVirtualMachineGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SqlVirtualMachineGroupId) 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.SqlVirtualMachineGroupName, ok = input.Parsed["sqlVirtualMachineGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlVirtualMachineGroupName", input) + } + + return nil +} + +// ValidateSqlVirtualMachineGroupID checks that 'input' can be parsed as a Sql Virtual Machine Group ID +func ValidateSqlVirtualMachineGroupID(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 := ParseSqlVirtualMachineGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SqlVirtualMachineGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) 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("staticMicrosoftSqlVirtualMachine", "Microsoft.SqlVirtualMachine", "Microsoft.SqlVirtualMachine"), + resourceids.StaticSegment("staticSqlVirtualMachineGroups", "sqlVirtualMachineGroups", "sqlVirtualMachineGroups"), + resourceids.UserSpecifiedSegment("sqlVirtualMachineGroupName", "sqlVirtualMachineGroupValue"), + } +} + +// String returns a human-readable description of this Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sql Virtual Machine Group Name: %q", id.SqlVirtualMachineGroupName), + } + return fmt.Sprintf("Sql Virtual Machine Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup_test.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup_test.go new file mode 100644 index 00000000000..1943052e6bb --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/id_sqlvirtualmachinegroup_test.go @@ -0,0 +1,282 @@ +package availabilitygrouplisteners + +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 = &SqlVirtualMachineGroupId{} + +func TestNewSqlVirtualMachineGroupID(t *testing.T) { + id := NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + + 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.SqlVirtualMachineGroupName != "sqlVirtualMachineGroupValue" { + t.Fatalf("Expected %q but got %q for Segment 'SqlVirtualMachineGroupName'", id.SqlVirtualMachineGroupName, "sqlVirtualMachineGroupValue") + } +} + +func TestFormatSqlVirtualMachineGroupID(t *testing.T) { + actual := NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSqlVirtualMachineGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineGroupId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + } +} + +func TestParseSqlVirtualMachineGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineGroupId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SqlVirtualMachineGroupName: "sQlViRtUaLmAcHiNeGrOuPvAlUe", + }, + }, + { + // 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.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + } +} + +func TestSegmentsForSqlVirtualMachineGroupId(t *testing.T) { + segments := SqlVirtualMachineGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SqlVirtualMachineGroupId 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/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_createorupdate.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_createorupdate.go new file mode 100644 index 00000000000..e93dd63c0d4 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_createorupdate.go @@ -0,0 +1,75 @@ +package availabilitygrouplisteners + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AvailabilityGroupListener +} + +// CreateOrUpdate ... +func (c AvailabilityGroupListenersClient) CreateOrUpdate(ctx context.Context, id AvailabilityGroupListenerId, input AvailabilityGroupListener) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AvailabilityGroupListenersClient) CreateOrUpdateThenPoll(ctx context.Context, id AvailabilityGroupListenerId, input AvailabilityGroupListener) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_delete.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_delete.go new file mode 100644 index 00000000000..bf3e8a5fc47 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_delete.go @@ -0,0 +1,71 @@ +package availabilitygrouplisteners + +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 AvailabilityGroupListenersClient) Delete(ctx context.Context, id AvailabilityGroupListenerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 AvailabilityGroupListenersClient) DeleteThenPoll(ctx context.Context, id AvailabilityGroupListenerId) 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/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_get.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_get.go new file mode 100644 index 00000000000..cb0cb022f07 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_get.go @@ -0,0 +1,83 @@ +package availabilitygrouplisteners + +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 *AvailabilityGroupListener +} + +type GetOperationOptions struct { + Expand *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.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c AvailabilityGroupListenersClient) Get(ctx context.Context, id AvailabilityGroupListenerId, 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 + } + + var model AvailabilityGroupListener + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_listbygroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_listbygroup.go new file mode 100644 index 00000000000..29571bc627a --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/method_listbygroup.go @@ -0,0 +1,91 @@ +package availabilitygrouplisteners + +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 ListByGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailabilityGroupListener +} + +type ListByGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailabilityGroupListener +} + +// ListByGroup ... +func (c AvailabilityGroupListenersClient) ListByGroup(ctx context.Context, id SqlVirtualMachineGroupId) (result ListByGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/availabilityGroupListeners", 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 *[]AvailabilityGroupListener `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByGroupComplete retrieves all the results into a single object +func (c AvailabilityGroupListenersClient) ListByGroupComplete(ctx context.Context, id SqlVirtualMachineGroupId) (ListByGroupCompleteResult, error) { + return c.ListByGroupCompleteMatchingPredicate(ctx, id, AvailabilityGroupListenerOperationPredicate{}) +} + +// ListByGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AvailabilityGroupListenersClient) ListByGroupCompleteMatchingPredicate(ctx context.Context, id SqlVirtualMachineGroupId, predicate AvailabilityGroupListenerOperationPredicate) (result ListByGroupCompleteResult, err error) { + items := make([]AvailabilityGroupListener, 0) + + resp, err := c.ListByGroup(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 = ListByGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agconfiguration.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agconfiguration.go new file mode 100644 index 00000000000..37fc1b348a7 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agconfiguration.go @@ -0,0 +1,8 @@ +package availabilitygrouplisteners + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgConfiguration struct { + Replicas *[]AgReplica `json:"replicas,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agreplica.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agreplica.go new file mode 100644 index 00000000000..87cf65e24bf --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_agreplica.go @@ -0,0 +1,12 @@ +package availabilitygrouplisteners + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgReplica struct { + Commit *Commit `json:"commit,omitempty"` + Failover *Failover `json:"failover,omitempty"` + ReadableSecondary *ReadableSecondary `json:"readableSecondary,omitempty"` + Role *Role `json:"role,omitempty"` + SqlVirtualMachineInstanceId *string `json:"sqlVirtualMachineInstanceId,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistener.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistener.go new file mode 100644 index 00000000000..7ae4bce4583 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistener.go @@ -0,0 +1,16 @@ +package availabilitygrouplisteners + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailabilityGroupListener struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AvailabilityGroupListenerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistenerproperties.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistenerproperties.go new file mode 100644 index 00000000000..47e2e39aeef --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_availabilitygrouplistenerproperties.go @@ -0,0 +1,14 @@ +package availabilitygrouplisteners + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailabilityGroupListenerProperties struct { + AvailabilityGroupConfiguration *AgConfiguration `json:"availabilityGroupConfiguration,omitempty"` + AvailabilityGroupName *string `json:"availabilityGroupName,omitempty"` + CreateDefaultAvailabilityGroupIfNotExist *bool `json:"createDefaultAvailabilityGroupIfNotExist,omitempty"` + LoadBalancerConfigurations *[]LoadBalancerConfiguration `json:"loadBalancerConfigurations,omitempty"` + MultiSubnetIPConfigurations *[]MultiSubnetIPConfiguration `json:"multiSubnetIpConfigurations,omitempty"` + Port *int64 `json:"port,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_loadbalancerconfiguration.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_loadbalancerconfiguration.go new file mode 100644 index 00000000000..ec6af3aca89 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_loadbalancerconfiguration.go @@ -0,0 +1,12 @@ +package availabilitygrouplisteners + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerConfiguration struct { + LoadBalancerResourceId *string `json:"loadBalancerResourceId,omitempty"` + PrivateIPAddress *PrivateIPAddress `json:"privateIpAddress,omitempty"` + ProbePort *int64 `json:"probePort,omitempty"` + PublicIPAddressResourceId *string `json:"publicIpAddressResourceId,omitempty"` + SqlVirtualMachineInstances *[]string `json:"sqlVirtualMachineInstances,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_multisubnetipconfiguration.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_multisubnetipconfiguration.go new file mode 100644 index 00000000000..357fd454948 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_multisubnetipconfiguration.go @@ -0,0 +1,9 @@ +package availabilitygrouplisteners + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MultiSubnetIPConfiguration struct { + PrivateIPAddress PrivateIPAddress `json:"privateIpAddress"` + SqlVirtualMachineInstance string `json:"sqlVirtualMachineInstance"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_privateipaddress.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_privateipaddress.go new file mode 100644 index 00000000000..3fbf130a221 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/model_privateipaddress.go @@ -0,0 +1,9 @@ +package availabilitygrouplisteners + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateIPAddress struct { + IPAddress *string `json:"ipAddress,omitempty"` + SubnetResourceId *string `json:"subnetResourceId,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/predicates.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/predicates.go new file mode 100644 index 00000000000..fff382e98c7 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/predicates.go @@ -0,0 +1,27 @@ +package availabilitygrouplisteners + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailabilityGroupListenerOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AvailabilityGroupListenerOperationPredicate) Matches(input AvailabilityGroupListener) 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/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/version.go b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/version.go new file mode 100644 index 00000000000..c237d268700 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners/version.go @@ -0,0 +1,12 @@ +package availabilitygrouplisteners + +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-10-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/availabilitygrouplisteners/%s", defaultApiVersion) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/client.go b/resource-manager/sqlvirtualmachine/2023-10-01/client.go new file mode 100644 index 00000000000..58c44d303ba --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/client.go @@ -0,0 +1,55 @@ +package v2023_10_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/availabilitygrouplisteners" + "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines" + "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AvailabilityGroupListeners *availabilitygrouplisteners.AvailabilityGroupListenersClient + SqlVirtualMachineGroups *sqlvirtualmachinegroups.SqlVirtualMachineGroupsClient + SqlVirtualMachineTroubleshoot *sqlvirtualmachinetroubleshoot.SqlVirtualMachineTroubleshootClient + SqlVirtualMachines *sqlvirtualmachines.SqlVirtualMachinesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + availabilityGroupListenersClient, err := availabilitygrouplisteners.NewAvailabilityGroupListenersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AvailabilityGroupListeners client: %+v", err) + } + configureFunc(availabilityGroupListenersClient.Client) + + sqlVirtualMachineGroupsClient, err := sqlvirtualmachinegroups.NewSqlVirtualMachineGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SqlVirtualMachineGroups client: %+v", err) + } + configureFunc(sqlVirtualMachineGroupsClient.Client) + + sqlVirtualMachineTroubleshootClient, err := sqlvirtualmachinetroubleshoot.NewSqlVirtualMachineTroubleshootClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SqlVirtualMachineTroubleshoot client: %+v", err) + } + configureFunc(sqlVirtualMachineTroubleshootClient.Client) + + sqlVirtualMachinesClient, err := sqlvirtualmachines.NewSqlVirtualMachinesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SqlVirtualMachines client: %+v", err) + } + configureFunc(sqlVirtualMachinesClient.Client) + + return &Client{ + AvailabilityGroupListeners: availabilityGroupListenersClient, + SqlVirtualMachineGroups: sqlVirtualMachineGroupsClient, + SqlVirtualMachineTroubleshoot: sqlVirtualMachineTroubleshootClient, + SqlVirtualMachines: sqlVirtualMachinesClient, + }, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/README.md b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/README.md new file mode 100644 index 00000000000..b1a6248c5d7 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/README.md @@ -0,0 +1,117 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups` Documentation + +The `sqlvirtualmachinegroups` SDK allows for interaction with the Azure Resource Manager Service `sqlvirtualmachine` (API Version `2023-10-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups" +``` + + +### Client Initialization + +```go +client := sqlvirtualmachinegroups.NewSqlVirtualMachineGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SqlVirtualMachineGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sqlvirtualmachinegroups.NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + +payload := sqlvirtualmachinegroups.SqlVirtualMachineGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlVirtualMachineGroupsClient.Delete` + +```go +ctx := context.TODO() +id := sqlvirtualmachinegroups.NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlVirtualMachineGroupsClient.Get` + +```go +ctx := context.TODO() +id := sqlvirtualmachinegroups.NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + +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: `SqlVirtualMachineGroupsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `SqlVirtualMachineGroupsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SqlVirtualMachineGroupsClient.Update` + +```go +ctx := context.TODO() +id := sqlvirtualmachinegroups.NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + +payload := sqlvirtualmachinegroups.SqlVirtualMachineGroupUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/client.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/client.go new file mode 100644 index 00000000000..1bf6a0b88a7 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/client.go @@ -0,0 +1,26 @@ +package sqlvirtualmachinegroups + +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 SqlVirtualMachineGroupsClient struct { + Client *resourcemanager.Client +} + +func NewSqlVirtualMachineGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*SqlVirtualMachineGroupsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "sqlvirtualmachinegroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SqlVirtualMachineGroupsClient: %+v", err) + } + + return &SqlVirtualMachineGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/constants.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/constants.go new file mode 100644 index 00000000000..71b3473b0a0 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/constants.go @@ -0,0 +1,206 @@ +package sqlvirtualmachinegroups + +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 ClusterConfiguration string + +const ( + ClusterConfigurationDomainful ClusterConfiguration = "Domainful" +) + +func PossibleValuesForClusterConfiguration() []string { + return []string{ + string(ClusterConfigurationDomainful), + } +} + +func (s *ClusterConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterConfiguration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterConfiguration(input string) (*ClusterConfiguration, error) { + vals := map[string]ClusterConfiguration{ + "domainful": ClusterConfigurationDomainful, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterConfiguration(input) + return &out, nil +} + +type ClusterManagerType string + +const ( + ClusterManagerTypeWSFC ClusterManagerType = "WSFC" +) + +func PossibleValuesForClusterManagerType() []string { + return []string{ + string(ClusterManagerTypeWSFC), + } +} + +func (s *ClusterManagerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterManagerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterManagerType(input string) (*ClusterManagerType, error) { + vals := map[string]ClusterManagerType{ + "wsfc": ClusterManagerTypeWSFC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterManagerType(input) + return &out, nil +} + +type ClusterSubnetType string + +const ( + ClusterSubnetTypeMultiSubnet ClusterSubnetType = "MultiSubnet" + ClusterSubnetTypeSingleSubnet ClusterSubnetType = "SingleSubnet" +) + +func PossibleValuesForClusterSubnetType() []string { + return []string{ + string(ClusterSubnetTypeMultiSubnet), + string(ClusterSubnetTypeSingleSubnet), + } +} + +func (s *ClusterSubnetType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterSubnetType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterSubnetType(input string) (*ClusterSubnetType, error) { + vals := map[string]ClusterSubnetType{ + "multisubnet": ClusterSubnetTypeMultiSubnet, + "singlesubnet": ClusterSubnetTypeSingleSubnet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterSubnetType(input) + return &out, nil +} + +type ScaleType string + +const ( + ScaleTypeHA ScaleType = "HA" +) + +func PossibleValuesForScaleType() []string { + return []string{ + string(ScaleTypeHA), + } +} + +func (s *ScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleType(input string) (*ScaleType, error) { + vals := map[string]ScaleType{ + "ha": ScaleTypeHA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleType(input) + return &out, nil +} + +type SqlVMGroupImageSku string + +const ( + SqlVMGroupImageSkuDeveloper SqlVMGroupImageSku = "Developer" + SqlVMGroupImageSkuEnterprise SqlVMGroupImageSku = "Enterprise" +) + +func PossibleValuesForSqlVMGroupImageSku() []string { + return []string{ + string(SqlVMGroupImageSkuDeveloper), + string(SqlVMGroupImageSkuEnterprise), + } +} + +func (s *SqlVMGroupImageSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlVMGroupImageSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlVMGroupImageSku(input string) (*SqlVMGroupImageSku, error) { + vals := map[string]SqlVMGroupImageSku{ + "developer": SqlVMGroupImageSkuDeveloper, + "enterprise": SqlVMGroupImageSkuEnterprise, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlVMGroupImageSku(input) + return &out, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup.go new file mode 100644 index 00000000000..ad826656b97 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup.go @@ -0,0 +1,130 @@ +package sqlvirtualmachinegroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SqlVirtualMachineGroupId{}) +} + +var _ resourceids.ResourceId = &SqlVirtualMachineGroupId{} + +// SqlVirtualMachineGroupId is a struct representing the Resource ID for a Sql Virtual Machine Group +type SqlVirtualMachineGroupId struct { + SubscriptionId string + ResourceGroupName string + SqlVirtualMachineGroupName string +} + +// NewSqlVirtualMachineGroupID returns a new SqlVirtualMachineGroupId struct +func NewSqlVirtualMachineGroupID(subscriptionId string, resourceGroupName string, sqlVirtualMachineGroupName string) SqlVirtualMachineGroupId { + return SqlVirtualMachineGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SqlVirtualMachineGroupName: sqlVirtualMachineGroupName, + } +} + +// ParseSqlVirtualMachineGroupID parses 'input' into a SqlVirtualMachineGroupId +func ParseSqlVirtualMachineGroupID(input string) (*SqlVirtualMachineGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSqlVirtualMachineGroupIDInsensitively parses 'input' case-insensitively into a SqlVirtualMachineGroupId +// note: this method should only be used for API response data and not user input +func ParseSqlVirtualMachineGroupIDInsensitively(input string) (*SqlVirtualMachineGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SqlVirtualMachineGroupId) 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.SqlVirtualMachineGroupName, ok = input.Parsed["sqlVirtualMachineGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlVirtualMachineGroupName", input) + } + + return nil +} + +// ValidateSqlVirtualMachineGroupID checks that 'input' can be parsed as a Sql Virtual Machine Group ID +func ValidateSqlVirtualMachineGroupID(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 := ParseSqlVirtualMachineGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SqlVirtualMachineGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) 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("staticMicrosoftSqlVirtualMachine", "Microsoft.SqlVirtualMachine", "Microsoft.SqlVirtualMachine"), + resourceids.StaticSegment("staticSqlVirtualMachineGroups", "sqlVirtualMachineGroups", "sqlVirtualMachineGroups"), + resourceids.UserSpecifiedSegment("sqlVirtualMachineGroupName", "sqlVirtualMachineGroupValue"), + } +} + +// String returns a human-readable description of this Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sql Virtual Machine Group Name: %q", id.SqlVirtualMachineGroupName), + } + return fmt.Sprintf("Sql Virtual Machine Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup_test.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup_test.go new file mode 100644 index 00000000000..773648f715c --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/id_sqlvirtualmachinegroup_test.go @@ -0,0 +1,282 @@ +package sqlvirtualmachinegroups + +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 = &SqlVirtualMachineGroupId{} + +func TestNewSqlVirtualMachineGroupID(t *testing.T) { + id := NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + + 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.SqlVirtualMachineGroupName != "sqlVirtualMachineGroupValue" { + t.Fatalf("Expected %q but got %q for Segment 'SqlVirtualMachineGroupName'", id.SqlVirtualMachineGroupName, "sqlVirtualMachineGroupValue") + } +} + +func TestFormatSqlVirtualMachineGroupID(t *testing.T) { + actual := NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSqlVirtualMachineGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineGroupId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + } +} + +func TestParseSqlVirtualMachineGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineGroupId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SqlVirtualMachineGroupName: "sQlViRtUaLmAcHiNeGrOuPvAlUe", + }, + }, + { + // 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.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + } +} + +func TestSegmentsForSqlVirtualMachineGroupId(t *testing.T) { + segments := SqlVirtualMachineGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SqlVirtualMachineGroupId 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_createorupdate.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_createorupdate.go new file mode 100644 index 00000000000..dd280e37f5e --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_createorupdate.go @@ -0,0 +1,75 @@ +package sqlvirtualmachinegroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlVirtualMachineGroup +} + +// CreateOrUpdate ... +func (c SqlVirtualMachineGroupsClient) CreateOrUpdate(ctx context.Context, id SqlVirtualMachineGroupId, input SqlVirtualMachineGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SqlVirtualMachineGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id SqlVirtualMachineGroupId, input SqlVirtualMachineGroup) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_delete.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_delete.go new file mode 100644 index 00000000000..e1b974dd763 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_delete.go @@ -0,0 +1,71 @@ +package sqlvirtualmachinegroups + +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 SqlVirtualMachineGroupsClient) Delete(ctx context.Context, id SqlVirtualMachineGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 SqlVirtualMachineGroupsClient) DeleteThenPoll(ctx context.Context, id SqlVirtualMachineGroupId) 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_get.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_get.go new file mode 100644 index 00000000000..211cb57a905 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_get.go @@ -0,0 +1,54 @@ +package sqlvirtualmachinegroups + +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 *SqlVirtualMachineGroup +} + +// Get ... +func (c SqlVirtualMachineGroupsClient) Get(ctx context.Context, id SqlVirtualMachineGroupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SqlVirtualMachineGroup + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_list.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_list.go new file mode 100644 index 00000000000..82ea19db0e0 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_list.go @@ -0,0 +1,92 @@ +package sqlvirtualmachinegroups + +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 *[]SqlVirtualMachineGroup +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SqlVirtualMachineGroup +} + +// List ... +func (c SqlVirtualMachineGroupsClient) List(ctx context.Context, id commonids.SubscriptionId) (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.SqlVirtualMachine/sqlVirtualMachineGroups", 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 *[]SqlVirtualMachineGroup `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 SqlVirtualMachineGroupsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SqlVirtualMachineGroupOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SqlVirtualMachineGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SqlVirtualMachineGroupOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SqlVirtualMachineGroup, 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_listbyresourcegroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_listbyresourcegroup.go new file mode 100644 index 00000000000..07d0cdfd384 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package sqlvirtualmachinegroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SqlVirtualMachineGroup +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SqlVirtualMachineGroup +} + +// ListByResourceGroup ... +func (c SqlVirtualMachineGroupsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", 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 *[]SqlVirtualMachineGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SqlVirtualMachineGroupsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SqlVirtualMachineGroupOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SqlVirtualMachineGroupsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SqlVirtualMachineGroupOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SqlVirtualMachineGroup, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_update.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_update.go new file mode 100644 index 00000000000..6567ee1e501 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/method_update.go @@ -0,0 +1,74 @@ +package sqlvirtualmachinegroups + +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 *SqlVirtualMachineGroup +} + +// Update ... +func (c SqlVirtualMachineGroupsClient) Update(ctx context.Context, id SqlVirtualMachineGroupId, input SqlVirtualMachineGroupUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 SqlVirtualMachineGroupsClient) UpdateThenPoll(ctx context.Context, id SqlVirtualMachineGroupId, input SqlVirtualMachineGroupUpdate) 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroup.go new file mode 100644 index 00000000000..10657a2ebef --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroup.go @@ -0,0 +1,18 @@ +package sqlvirtualmachinegroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachineGroup struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SqlVirtualMachineGroupProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupproperties.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupproperties.go new file mode 100644 index 00000000000..ad803278894 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupproperties.go @@ -0,0 +1,14 @@ +package sqlvirtualmachinegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachineGroupProperties struct { + ClusterConfiguration *ClusterConfiguration `json:"clusterConfiguration,omitempty"` + ClusterManagerType *ClusterManagerType `json:"clusterManagerType,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ScaleType *ScaleType `json:"scaleType,omitempty"` + SqlImageOffer *string `json:"sqlImageOffer,omitempty"` + SqlImageSku *SqlVMGroupImageSku `json:"sqlImageSku,omitempty"` + WsfcDomainProfile *WsfcDomainProfile `json:"wsfcDomainProfile,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupupdate.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupupdate.go new file mode 100644 index 00000000000..25f4e3c5ec7 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_sqlvirtualmachinegroupupdate.go @@ -0,0 +1,8 @@ +package sqlvirtualmachinegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachineGroupUpdate struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_wsfcdomainprofile.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_wsfcdomainprofile.go new file mode 100644 index 00000000000..bc07f543659 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/model_wsfcdomainprofile.go @@ -0,0 +1,17 @@ +package sqlvirtualmachinegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WsfcDomainProfile struct { + ClusterBootstrapAccount *string `json:"clusterBootstrapAccount,omitempty"` + ClusterOperatorAccount *string `json:"clusterOperatorAccount,omitempty"` + ClusterSubnetType *ClusterSubnetType `json:"clusterSubnetType,omitempty"` + DomainFqdn *string `json:"domainFqdn,omitempty"` + FileShareWitnessPath *string `json:"fileShareWitnessPath,omitempty"` + IsSqlServiceAccountGmsa *bool `json:"isSqlServiceAccountGmsa,omitempty"` + OuPath *string `json:"ouPath,omitempty"` + SqlServiceAccount *string `json:"sqlServiceAccount,omitempty"` + StorageAccountPrimaryKey *string `json:"storageAccountPrimaryKey,omitempty"` + StorageAccountUrl *string `json:"storageAccountUrl,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/predicates.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/predicates.go new file mode 100644 index 00000000000..d3878f312b5 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/predicates.go @@ -0,0 +1,32 @@ +package sqlvirtualmachinegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachineGroupOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SqlVirtualMachineGroupOperationPredicate) Matches(input SqlVirtualMachineGroup) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/version.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/version.go new file mode 100644 index 00000000000..ae2caae5adf --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinegroups/version.go @@ -0,0 +1,12 @@ +package sqlvirtualmachinegroups + +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-10-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/sqlvirtualmachinegroups/%s", defaultApiVersion) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/README.md b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/README.md new file mode 100644 index 00000000000..4b92ac3cf14 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/README.md @@ -0,0 +1,175 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines` Documentation + +The `sqlvirtualmachines` SDK allows for interaction with the Azure Resource Manager Service `sqlvirtualmachine` (API Version `2023-10-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines" +``` + + +### Client Initialization + +```go +client := sqlvirtualmachines.NewSqlVirtualMachinesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SqlVirtualMachinesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +payload := sqlvirtualmachines.SqlVirtualMachine{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.Delete` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.FetchDCAssessment` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +payload := sqlvirtualmachines.DiskConfigAssessmentRequest{ + // ... +} + + +if err := client.FetchDCAssessmentThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.Get` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +read, err := client.Get(ctx, id, sqlvirtualmachines.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `SqlVirtualMachinesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.ListBySqlVMGroup` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + +// alternatively `client.ListBySqlVMGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListBySqlVMGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.Redeploy` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +if err := client.RedeployThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.StartAssessment` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +if err := client.StartAssessmentThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SqlVirtualMachinesClient.Update` + +```go +ctx := context.TODO() +id := sqlvirtualmachines.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +payload := sqlvirtualmachines.SqlVirtualMachineUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/client.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/client.go new file mode 100644 index 00000000000..d3578ee4c55 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/client.go @@ -0,0 +1,26 @@ +package sqlvirtualmachines + +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 SqlVirtualMachinesClient struct { + Client *resourcemanager.Client +} + +func NewSqlVirtualMachinesClientWithBaseURI(sdkApi sdkEnv.Api) (*SqlVirtualMachinesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "sqlvirtualmachines", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SqlVirtualMachinesClient: %+v", err) + } + + return &SqlVirtualMachinesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/constants.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/constants.go new file mode 100644 index 00000000000..c441b22203e --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/constants.go @@ -0,0 +1,873 @@ +package sqlvirtualmachines + +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 AdditionalOsPatch string + +const ( + AdditionalOsPatchWSUS AdditionalOsPatch = "WSUS" + AdditionalOsPatchWU AdditionalOsPatch = "WU" + AdditionalOsPatchWUMU AdditionalOsPatch = "WUMU" +) + +func PossibleValuesForAdditionalOsPatch() []string { + return []string{ + string(AdditionalOsPatchWSUS), + string(AdditionalOsPatchWU), + string(AdditionalOsPatchWUMU), + } +} + +func (s *AdditionalOsPatch) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdditionalOsPatch(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdditionalOsPatch(input string) (*AdditionalOsPatch, error) { + vals := map[string]AdditionalOsPatch{ + "wsus": AdditionalOsPatchWSUS, + "wu": AdditionalOsPatchWU, + "wumu": AdditionalOsPatchWUMU, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdditionalOsPatch(input) + return &out, nil +} + +type AdditionalVMPatch string + +const ( + AdditionalVMPatchMicrosoftUpdate AdditionalVMPatch = "MicrosoftUpdate" + AdditionalVMPatchNotSet AdditionalVMPatch = "NotSet" +) + +func PossibleValuesForAdditionalVMPatch() []string { + return []string{ + string(AdditionalVMPatchMicrosoftUpdate), + string(AdditionalVMPatchNotSet), + } +} + +func (s *AdditionalVMPatch) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdditionalVMPatch(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdditionalVMPatch(input string) (*AdditionalVMPatch, error) { + vals := map[string]AdditionalVMPatch{ + "microsoftupdate": AdditionalVMPatchMicrosoftUpdate, + "notset": AdditionalVMPatchNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdditionalVMPatch(input) + return &out, nil +} + +type AssessmentDayOfWeek string + +const ( + AssessmentDayOfWeekFriday AssessmentDayOfWeek = "Friday" + AssessmentDayOfWeekMonday AssessmentDayOfWeek = "Monday" + AssessmentDayOfWeekSaturday AssessmentDayOfWeek = "Saturday" + AssessmentDayOfWeekSunday AssessmentDayOfWeek = "Sunday" + AssessmentDayOfWeekThursday AssessmentDayOfWeek = "Thursday" + AssessmentDayOfWeekTuesday AssessmentDayOfWeek = "Tuesday" + AssessmentDayOfWeekWednesday AssessmentDayOfWeek = "Wednesday" +) + +func PossibleValuesForAssessmentDayOfWeek() []string { + return []string{ + string(AssessmentDayOfWeekFriday), + string(AssessmentDayOfWeekMonday), + string(AssessmentDayOfWeekSaturday), + string(AssessmentDayOfWeekSunday), + string(AssessmentDayOfWeekThursday), + string(AssessmentDayOfWeekTuesday), + string(AssessmentDayOfWeekWednesday), + } +} + +func (s *AssessmentDayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssessmentDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssessmentDayOfWeek(input string) (*AssessmentDayOfWeek, error) { + vals := map[string]AssessmentDayOfWeek{ + "friday": AssessmentDayOfWeekFriday, + "monday": AssessmentDayOfWeekMonday, + "saturday": AssessmentDayOfWeekSaturday, + "sunday": AssessmentDayOfWeekSunday, + "thursday": AssessmentDayOfWeekThursday, + "tuesday": AssessmentDayOfWeekTuesday, + "wednesday": AssessmentDayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssessmentDayOfWeek(input) + return &out, nil +} + +type AutoBackupDaysOfWeek string + +const ( + AutoBackupDaysOfWeekFriday AutoBackupDaysOfWeek = "Friday" + AutoBackupDaysOfWeekMonday AutoBackupDaysOfWeek = "Monday" + AutoBackupDaysOfWeekSaturday AutoBackupDaysOfWeek = "Saturday" + AutoBackupDaysOfWeekSunday AutoBackupDaysOfWeek = "Sunday" + AutoBackupDaysOfWeekThursday AutoBackupDaysOfWeek = "Thursday" + AutoBackupDaysOfWeekTuesday AutoBackupDaysOfWeek = "Tuesday" + AutoBackupDaysOfWeekWednesday AutoBackupDaysOfWeek = "Wednesday" +) + +func PossibleValuesForAutoBackupDaysOfWeek() []string { + return []string{ + string(AutoBackupDaysOfWeekFriday), + string(AutoBackupDaysOfWeekMonday), + string(AutoBackupDaysOfWeekSaturday), + string(AutoBackupDaysOfWeekSunday), + string(AutoBackupDaysOfWeekThursday), + string(AutoBackupDaysOfWeekTuesday), + string(AutoBackupDaysOfWeekWednesday), + } +} + +func (s *AutoBackupDaysOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoBackupDaysOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoBackupDaysOfWeek(input string) (*AutoBackupDaysOfWeek, error) { + vals := map[string]AutoBackupDaysOfWeek{ + "friday": AutoBackupDaysOfWeekFriday, + "monday": AutoBackupDaysOfWeekMonday, + "saturday": AutoBackupDaysOfWeekSaturday, + "sunday": AutoBackupDaysOfWeekSunday, + "thursday": AutoBackupDaysOfWeekThursday, + "tuesday": AutoBackupDaysOfWeekTuesday, + "wednesday": AutoBackupDaysOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoBackupDaysOfWeek(input) + return &out, nil +} + +type BackupScheduleType string + +const ( + BackupScheduleTypeAutomated BackupScheduleType = "Automated" + BackupScheduleTypeManual BackupScheduleType = "Manual" +) + +func PossibleValuesForBackupScheduleType() []string { + return []string{ + string(BackupScheduleTypeAutomated), + string(BackupScheduleTypeManual), + } +} + +func (s *BackupScheduleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupScheduleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupScheduleType(input string) (*BackupScheduleType, error) { + vals := map[string]BackupScheduleType{ + "automated": BackupScheduleTypeAutomated, + "manual": BackupScheduleTypeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupScheduleType(input) + return &out, nil +} + +type ConnectivityType string + +const ( + ConnectivityTypeLOCAL ConnectivityType = "LOCAL" + ConnectivityTypePRIVATE ConnectivityType = "PRIVATE" + ConnectivityTypePUBLIC ConnectivityType = "PUBLIC" +) + +func PossibleValuesForConnectivityType() []string { + return []string{ + string(ConnectivityTypeLOCAL), + string(ConnectivityTypePRIVATE), + string(ConnectivityTypePUBLIC), + } +} + +func (s *ConnectivityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectivityType(input string) (*ConnectivityType, error) { + vals := map[string]ConnectivityType{ + "local": ConnectivityTypeLOCAL, + "private": ConnectivityTypePRIVATE, + "public": ConnectivityTypePUBLIC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectivityType(input) + return &out, nil +} + +type DayOfWeek string + +const ( + DayOfWeekEveryday DayOfWeek = "Everyday" + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekEveryday), + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "everyday": DayOfWeekEveryday, + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type DiskConfigurationType string + +const ( + DiskConfigurationTypeADD DiskConfigurationType = "ADD" + DiskConfigurationTypeEXTEND DiskConfigurationType = "EXTEND" + DiskConfigurationTypeNEW DiskConfigurationType = "NEW" +) + +func PossibleValuesForDiskConfigurationType() []string { + return []string{ + string(DiskConfigurationTypeADD), + string(DiskConfigurationTypeEXTEND), + string(DiskConfigurationTypeNEW), + } +} + +func (s *DiskConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiskConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiskConfigurationType(input string) (*DiskConfigurationType, error) { + vals := map[string]DiskConfigurationType{ + "add": DiskConfigurationTypeADD, + "extend": DiskConfigurationTypeEXTEND, + "new": DiskConfigurationTypeNEW, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiskConfigurationType(input) + return &out, nil +} + +type FullBackupFrequencyType string + +const ( + FullBackupFrequencyTypeDaily FullBackupFrequencyType = "Daily" + FullBackupFrequencyTypeWeekly FullBackupFrequencyType = "Weekly" +) + +func PossibleValuesForFullBackupFrequencyType() []string { + return []string{ + string(FullBackupFrequencyTypeDaily), + string(FullBackupFrequencyTypeWeekly), + } +} + +func (s *FullBackupFrequencyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFullBackupFrequencyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFullBackupFrequencyType(input string) (*FullBackupFrequencyType, error) { + vals := map[string]FullBackupFrequencyType{ + "daily": FullBackupFrequencyTypeDaily, + "weekly": FullBackupFrequencyTypeWeekly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FullBackupFrequencyType(input) + return &out, nil +} + +type IdentityType string + +const ( + IdentityTypeNone IdentityType = "None" + IdentityTypeSystemAssigned IdentityType = "SystemAssigned" + IdentityTypeSystemAssignedUserAssigned IdentityType = "SystemAssigned,UserAssigned" + IdentityTypeUserAssigned IdentityType = "UserAssigned" +) + +func PossibleValuesForIdentityType() []string { + return []string{ + string(IdentityTypeNone), + string(IdentityTypeSystemAssigned), + string(IdentityTypeSystemAssignedUserAssigned), + string(IdentityTypeUserAssigned), + } +} + +func (s *IdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIdentityType(input string) (*IdentityType, error) { + vals := map[string]IdentityType{ + "none": IdentityTypeNone, + "systemassigned": IdentityTypeSystemAssigned, + "systemassigned,userassigned": IdentityTypeSystemAssignedUserAssigned, + "userassigned": IdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IdentityType(input) + return &out, nil +} + +type LeastPrivilegeMode string + +const ( + LeastPrivilegeModeEnabled LeastPrivilegeMode = "Enabled" + LeastPrivilegeModeNotSet LeastPrivilegeMode = "NotSet" +) + +func PossibleValuesForLeastPrivilegeMode() []string { + return []string{ + string(LeastPrivilegeModeEnabled), + string(LeastPrivilegeModeNotSet), + } +} + +func (s *LeastPrivilegeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLeastPrivilegeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLeastPrivilegeMode(input string) (*LeastPrivilegeMode, error) { + vals := map[string]LeastPrivilegeMode{ + "enabled": LeastPrivilegeModeEnabled, + "notset": LeastPrivilegeModeNotSet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LeastPrivilegeMode(input) + return &out, nil +} + +type OsType string + +const ( + OsTypeLinux OsType = "Linux" + OsTypeWindows OsType = "Windows" +) + +func PossibleValuesForOsType() []string { + return []string{ + string(OsTypeLinux), + string(OsTypeWindows), + } +} + +func (s *OsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOsType(input string) (*OsType, error) { + vals := map[string]OsType{ + "linux": OsTypeLinux, + "windows": OsTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OsType(input) + return &out, nil +} + +type SqlImageSku string + +const ( + SqlImageSkuDeveloper SqlImageSku = "Developer" + SqlImageSkuEnterprise SqlImageSku = "Enterprise" + SqlImageSkuExpress SqlImageSku = "Express" + SqlImageSkuStandard SqlImageSku = "Standard" + SqlImageSkuWeb SqlImageSku = "Web" +) + +func PossibleValuesForSqlImageSku() []string { + return []string{ + string(SqlImageSkuDeveloper), + string(SqlImageSkuEnterprise), + string(SqlImageSkuExpress), + string(SqlImageSkuStandard), + string(SqlImageSkuWeb), + } +} + +func (s *SqlImageSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlImageSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlImageSku(input string) (*SqlImageSku, error) { + vals := map[string]SqlImageSku{ + "developer": SqlImageSkuDeveloper, + "enterprise": SqlImageSkuEnterprise, + "express": SqlImageSkuExpress, + "standard": SqlImageSkuStandard, + "web": SqlImageSkuWeb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlImageSku(input) + return &out, nil +} + +type SqlManagementMode string + +const ( + SqlManagementModeFull SqlManagementMode = "Full" + SqlManagementModeLightWeight SqlManagementMode = "LightWeight" + SqlManagementModeNoAgent SqlManagementMode = "NoAgent" +) + +func PossibleValuesForSqlManagementMode() []string { + return []string{ + string(SqlManagementModeFull), + string(SqlManagementModeLightWeight), + string(SqlManagementModeNoAgent), + } +} + +func (s *SqlManagementMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlManagementMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlManagementMode(input string) (*SqlManagementMode, error) { + vals := map[string]SqlManagementMode{ + "full": SqlManagementModeFull, + "lightweight": SqlManagementModeLightWeight, + "noagent": SqlManagementModeNoAgent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlManagementMode(input) + return &out, nil +} + +type SqlServerLicenseType string + +const ( + SqlServerLicenseTypeAHUB SqlServerLicenseType = "AHUB" + SqlServerLicenseTypeDR SqlServerLicenseType = "DR" + SqlServerLicenseTypePAYG SqlServerLicenseType = "PAYG" +) + +func PossibleValuesForSqlServerLicenseType() []string { + return []string{ + string(SqlServerLicenseTypeAHUB), + string(SqlServerLicenseTypeDR), + 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, + "dr": SqlServerLicenseTypeDR, + "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 SqlWorkloadType string + +const ( + SqlWorkloadTypeDW SqlWorkloadType = "DW" + SqlWorkloadTypeGENERAL SqlWorkloadType = "GENERAL" + SqlWorkloadTypeOLTP SqlWorkloadType = "OLTP" +) + +func PossibleValuesForSqlWorkloadType() []string { + return []string{ + string(SqlWorkloadTypeDW), + string(SqlWorkloadTypeGENERAL), + string(SqlWorkloadTypeOLTP), + } +} + +func (s *SqlWorkloadType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSqlWorkloadType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSqlWorkloadType(input string) (*SqlWorkloadType, error) { + vals := map[string]SqlWorkloadType{ + "dw": SqlWorkloadTypeDW, + "general": SqlWorkloadTypeGENERAL, + "oltp": SqlWorkloadTypeOLTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SqlWorkloadType(input) + return &out, nil +} + +type StorageWorkloadType string + +const ( + StorageWorkloadTypeDW StorageWorkloadType = "DW" + StorageWorkloadTypeGENERAL StorageWorkloadType = "GENERAL" + StorageWorkloadTypeOLTP StorageWorkloadType = "OLTP" +) + +func PossibleValuesForStorageWorkloadType() []string { + return []string{ + string(StorageWorkloadTypeDW), + string(StorageWorkloadTypeGENERAL), + string(StorageWorkloadTypeOLTP), + } +} + +func (s *StorageWorkloadType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageWorkloadType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageWorkloadType(input string) (*StorageWorkloadType, error) { + vals := map[string]StorageWorkloadType{ + "dw": StorageWorkloadTypeDW, + "general": StorageWorkloadTypeGENERAL, + "oltp": StorageWorkloadTypeOLTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageWorkloadType(input) + return &out, nil +} + +type TroubleshootingScenario string + +const ( + TroubleshootingScenarioUnhealthyReplica TroubleshootingScenario = "UnhealthyReplica" +) + +func PossibleValuesForTroubleshootingScenario() []string { + return []string{ + string(TroubleshootingScenarioUnhealthyReplica), + } +} + +func (s *TroubleshootingScenario) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTroubleshootingScenario(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTroubleshootingScenario(input string) (*TroubleshootingScenario, error) { + vals := map[string]TroubleshootingScenario{ + "unhealthyreplica": TroubleshootingScenarioUnhealthyReplica, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TroubleshootingScenario(input) + return &out, nil +} + +type VMIdentityType string + +const ( + VMIdentityTypeNone VMIdentityType = "None" + VMIdentityTypeSystemAssigned VMIdentityType = "SystemAssigned" + VMIdentityTypeUserAssigned VMIdentityType = "UserAssigned" +) + +func PossibleValuesForVMIdentityType() []string { + return []string{ + string(VMIdentityTypeNone), + string(VMIdentityTypeSystemAssigned), + string(VMIdentityTypeUserAssigned), + } +} + +func (s *VMIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMIdentityType(input string) (*VMIdentityType, error) { + vals := map[string]VMIdentityType{ + "none": VMIdentityTypeNone, + "systemassigned": VMIdentityTypeSystemAssigned, + "userassigned": VMIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMIdentityType(input) + return &out, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine.go new file mode 100644 index 00000000000..67c55ddda18 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine.go @@ -0,0 +1,130 @@ +package sqlvirtualmachines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SqlVirtualMachineId{}) +} + +var _ resourceids.ResourceId = &SqlVirtualMachineId{} + +// SqlVirtualMachineId is a struct representing the Resource ID for a Sql Virtual Machine +type SqlVirtualMachineId struct { + SubscriptionId string + ResourceGroupName string + SqlVirtualMachineName string +} + +// NewSqlVirtualMachineID returns a new SqlVirtualMachineId struct +func NewSqlVirtualMachineID(subscriptionId string, resourceGroupName string, sqlVirtualMachineName string) SqlVirtualMachineId { + return SqlVirtualMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SqlVirtualMachineName: sqlVirtualMachineName, + } +} + +// ParseSqlVirtualMachineID parses 'input' into a SqlVirtualMachineId +func ParseSqlVirtualMachineID(input string) (*SqlVirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSqlVirtualMachineIDInsensitively parses 'input' case-insensitively into a SqlVirtualMachineId +// note: this method should only be used for API response data and not user input +func ParseSqlVirtualMachineIDInsensitively(input string) (*SqlVirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SqlVirtualMachineId) 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.SqlVirtualMachineName, ok = input.Parsed["sqlVirtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlVirtualMachineName", input) + } + + return nil +} + +// ValidateSqlVirtualMachineID checks that 'input' can be parsed as a Sql Virtual Machine ID +func ValidateSqlVirtualMachineID(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 := ParseSqlVirtualMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sql Virtual Machine ID +func (id SqlVirtualMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SqlVirtualMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sql Virtual Machine ID +func (id SqlVirtualMachineId) 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("staticMicrosoftSqlVirtualMachine", "Microsoft.SqlVirtualMachine", "Microsoft.SqlVirtualMachine"), + resourceids.StaticSegment("staticSqlVirtualMachines", "sqlVirtualMachines", "sqlVirtualMachines"), + resourceids.UserSpecifiedSegment("sqlVirtualMachineName", "sqlVirtualMachineValue"), + } +} + +// String returns a human-readable description of this Sql Virtual Machine ID +func (id SqlVirtualMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sql Virtual Machine Name: %q", id.SqlVirtualMachineName), + } + return fmt.Sprintf("Sql Virtual Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine_test.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine_test.go new file mode 100644 index 00000000000..697b183af49 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachine_test.go @@ -0,0 +1,282 @@ +package sqlvirtualmachines + +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 = &SqlVirtualMachineId{} + +func TestNewSqlVirtualMachineID(t *testing.T) { + id := NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + + 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.SqlVirtualMachineName != "sqlVirtualMachineValue" { + t.Fatalf("Expected %q but got %q for Segment 'SqlVirtualMachineName'", id.SqlVirtualMachineName, "sqlVirtualMachineValue") + } +} + +func TestFormatSqlVirtualMachineID(t *testing.T) { + actual := NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSqlVirtualMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue", + Expected: &SqlVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineName: "sqlVirtualMachineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineName != v.Expected.SqlVirtualMachineName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineName", v.Expected.SqlVirtualMachineName, actual.SqlVirtualMachineName) + } + + } +} + +func TestParseSqlVirtualMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue", + Expected: &SqlVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineName: "sqlVirtualMachineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeS/sQlViRtUaLmAcHiNeVaLuE", + Expected: &SqlVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SqlVirtualMachineName: "sQlViRtUaLmAcHiNeVaLuE", + }, + }, + { + // 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.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeS/sQlViRtUaLmAcHiNeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineName != v.Expected.SqlVirtualMachineName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineName", v.Expected.SqlVirtualMachineName, actual.SqlVirtualMachineName) + } + + } +} + +func TestSegmentsForSqlVirtualMachineId(t *testing.T) { + segments := SqlVirtualMachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SqlVirtualMachineId 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup.go new file mode 100644 index 00000000000..5949af3d82c --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup.go @@ -0,0 +1,130 @@ +package sqlvirtualmachines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SqlVirtualMachineGroupId{}) +} + +var _ resourceids.ResourceId = &SqlVirtualMachineGroupId{} + +// SqlVirtualMachineGroupId is a struct representing the Resource ID for a Sql Virtual Machine Group +type SqlVirtualMachineGroupId struct { + SubscriptionId string + ResourceGroupName string + SqlVirtualMachineGroupName string +} + +// NewSqlVirtualMachineGroupID returns a new SqlVirtualMachineGroupId struct +func NewSqlVirtualMachineGroupID(subscriptionId string, resourceGroupName string, sqlVirtualMachineGroupName string) SqlVirtualMachineGroupId { + return SqlVirtualMachineGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SqlVirtualMachineGroupName: sqlVirtualMachineGroupName, + } +} + +// ParseSqlVirtualMachineGroupID parses 'input' into a SqlVirtualMachineGroupId +func ParseSqlVirtualMachineGroupID(input string) (*SqlVirtualMachineGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSqlVirtualMachineGroupIDInsensitively parses 'input' case-insensitively into a SqlVirtualMachineGroupId +// note: this method should only be used for API response data and not user input +func ParseSqlVirtualMachineGroupIDInsensitively(input string) (*SqlVirtualMachineGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineGroupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SqlVirtualMachineGroupId) 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.SqlVirtualMachineGroupName, ok = input.Parsed["sqlVirtualMachineGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlVirtualMachineGroupName", input) + } + + return nil +} + +// ValidateSqlVirtualMachineGroupID checks that 'input' can be parsed as a Sql Virtual Machine Group ID +func ValidateSqlVirtualMachineGroupID(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 := ParseSqlVirtualMachineGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SqlVirtualMachineGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) 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("staticMicrosoftSqlVirtualMachine", "Microsoft.SqlVirtualMachine", "Microsoft.SqlVirtualMachine"), + resourceids.StaticSegment("staticSqlVirtualMachineGroups", "sqlVirtualMachineGroups", "sqlVirtualMachineGroups"), + resourceids.UserSpecifiedSegment("sqlVirtualMachineGroupName", "sqlVirtualMachineGroupValue"), + } +} + +// String returns a human-readable description of this Sql Virtual Machine Group ID +func (id SqlVirtualMachineGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sql Virtual Machine Group Name: %q", id.SqlVirtualMachineGroupName), + } + return fmt.Sprintf("Sql Virtual Machine Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup_test.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup_test.go new file mode 100644 index 00000000000..875e0878324 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/id_sqlvirtualmachinegroup_test.go @@ -0,0 +1,282 @@ +package sqlvirtualmachines + +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 = &SqlVirtualMachineGroupId{} + +func TestNewSqlVirtualMachineGroupID(t *testing.T) { + id := NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue") + + 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.SqlVirtualMachineGroupName != "sqlVirtualMachineGroupValue" { + t.Fatalf("Expected %q but got %q for Segment 'SqlVirtualMachineGroupName'", id.SqlVirtualMachineGroupName, "sqlVirtualMachineGroupValue") + } +} + +func TestFormatSqlVirtualMachineGroupID(t *testing.T) { + actual := NewSqlVirtualMachineGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineGroupValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSqlVirtualMachineGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineGroupId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + } +} + +func TestParseSqlVirtualMachineGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineGroupId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineGroupName: "sqlVirtualMachineGroupValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/sqlVirtualMachineGroupValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe", + Expected: &SqlVirtualMachineGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SqlVirtualMachineGroupName: "sQlViRtUaLmAcHiNeGrOuPvAlUe", + }, + }, + { + // 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.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeGrOuPs/sQlViRtUaLmAcHiNeGrOuPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineGroupName != v.Expected.SqlVirtualMachineGroupName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineGroupName", v.Expected.SqlVirtualMachineGroupName, actual.SqlVirtualMachineGroupName) + } + + } +} + +func TestSegmentsForSqlVirtualMachineGroupId(t *testing.T) { + segments := SqlVirtualMachineGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SqlVirtualMachineGroupId 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_createorupdate.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_createorupdate.go new file mode 100644 index 00000000000..935e5a46777 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_createorupdate.go @@ -0,0 +1,75 @@ +package sqlvirtualmachines + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlVirtualMachine +} + +// CreateOrUpdate ... +func (c SqlVirtualMachinesClient) CreateOrUpdate(ctx context.Context, id SqlVirtualMachineId, input SqlVirtualMachine) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SqlVirtualMachinesClient) CreateOrUpdateThenPoll(ctx context.Context, id SqlVirtualMachineId, input SqlVirtualMachine) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_delete.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_delete.go new file mode 100644 index 00000000000..59cff7cdba6 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_delete.go @@ -0,0 +1,71 @@ +package sqlvirtualmachines + +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 SqlVirtualMachinesClient) Delete(ctx context.Context, id SqlVirtualMachineId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 SqlVirtualMachinesClient) DeleteThenPoll(ctx context.Context, id SqlVirtualMachineId) 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_fetchdcassessment.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_fetchdcassessment.go new file mode 100644 index 00000000000..9c965d5482e --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_fetchdcassessment.go @@ -0,0 +1,73 @@ +package sqlvirtualmachines + +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 FetchDCAssessmentOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// FetchDCAssessment ... +func (c SqlVirtualMachinesClient) FetchDCAssessment(ctx context.Context, id SqlVirtualMachineId, input DiskConfigAssessmentRequest) (result FetchDCAssessmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/fetchDCAssessment", 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 +} + +// FetchDCAssessmentThenPoll performs FetchDCAssessment then polls until it's completed +func (c SqlVirtualMachinesClient) FetchDCAssessmentThenPoll(ctx context.Context, id SqlVirtualMachineId, input DiskConfigAssessmentRequest) error { + result, err := c.FetchDCAssessment(ctx, id, input) + if err != nil { + return fmt.Errorf("performing FetchDCAssessment: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FetchDCAssessment: %+v", err) + } + + return nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_get.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_get.go new file mode 100644 index 00000000000..774f633c0db --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_get.go @@ -0,0 +1,83 @@ +package sqlvirtualmachines + +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 *SqlVirtualMachine +} + +type GetOperationOptions struct { + Expand *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.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c SqlVirtualMachinesClient) Get(ctx context.Context, id SqlVirtualMachineId, 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 + } + + var model SqlVirtualMachine + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_list.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_list.go new file mode 100644 index 00000000000..04b5e1f8ca0 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_list.go @@ -0,0 +1,92 @@ +package sqlvirtualmachines + +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 *[]SqlVirtualMachine +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SqlVirtualMachine +} + +// List ... +func (c SqlVirtualMachinesClient) List(ctx context.Context, id commonids.SubscriptionId) (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.SqlVirtualMachine/sqlVirtualMachines", 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 *[]SqlVirtualMachine `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 SqlVirtualMachinesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SqlVirtualMachineOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SqlVirtualMachinesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SqlVirtualMachineOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SqlVirtualMachine, 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbyresourcegroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbyresourcegroup.go new file mode 100644 index 00000000000..033be33aa2d --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package sqlvirtualmachines + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SqlVirtualMachine +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SqlVirtualMachine +} + +// ListByResourceGroup ... +func (c SqlVirtualMachinesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines", 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 *[]SqlVirtualMachine `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SqlVirtualMachinesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SqlVirtualMachineOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SqlVirtualMachinesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SqlVirtualMachineOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SqlVirtualMachine, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbysqlvmgroup.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbysqlvmgroup.go new file mode 100644 index 00000000000..c2f01089b12 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_listbysqlvmgroup.go @@ -0,0 +1,91 @@ +package sqlvirtualmachines + +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 ListBySqlVMGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SqlVirtualMachine +} + +type ListBySqlVMGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SqlVirtualMachine +} + +// ListBySqlVMGroup ... +func (c SqlVirtualMachinesClient) ListBySqlVMGroup(ctx context.Context, id SqlVirtualMachineGroupId) (result ListBySqlVMGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sqlVirtualMachines", 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 *[]SqlVirtualMachine `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySqlVMGroupComplete retrieves all the results into a single object +func (c SqlVirtualMachinesClient) ListBySqlVMGroupComplete(ctx context.Context, id SqlVirtualMachineGroupId) (ListBySqlVMGroupCompleteResult, error) { + return c.ListBySqlVMGroupCompleteMatchingPredicate(ctx, id, SqlVirtualMachineOperationPredicate{}) +} + +// ListBySqlVMGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SqlVirtualMachinesClient) ListBySqlVMGroupCompleteMatchingPredicate(ctx context.Context, id SqlVirtualMachineGroupId, predicate SqlVirtualMachineOperationPredicate) (result ListBySqlVMGroupCompleteResult, err error) { + items := make([]SqlVirtualMachine, 0) + + resp, err := c.ListBySqlVMGroup(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 = ListBySqlVMGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_redeploy.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_redeploy.go new file mode 100644 index 00000000000..2cc9791f9b3 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_redeploy.go @@ -0,0 +1,69 @@ +package sqlvirtualmachines + +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 RedeployOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Redeploy ... +func (c SqlVirtualMachinesClient) Redeploy(ctx context.Context, id SqlVirtualMachineId) (result RedeployOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/redeploy", 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 +} + +// RedeployThenPoll performs Redeploy then polls until it's completed +func (c SqlVirtualMachinesClient) RedeployThenPoll(ctx context.Context, id SqlVirtualMachineId) error { + result, err := c.Redeploy(ctx, id) + if err != nil { + return fmt.Errorf("performing Redeploy: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Redeploy: %+v", err) + } + + return nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_startassessment.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_startassessment.go new file mode 100644 index 00000000000..bb092ae3f02 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_startassessment.go @@ -0,0 +1,69 @@ +package sqlvirtualmachines + +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 StartAssessmentOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// StartAssessment ... +func (c SqlVirtualMachinesClient) StartAssessment(ctx context.Context, id SqlVirtualMachineId) (result StartAssessmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startAssessment", 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 +} + +// StartAssessmentThenPoll performs StartAssessment then polls until it's completed +func (c SqlVirtualMachinesClient) StartAssessmentThenPoll(ctx context.Context, id SqlVirtualMachineId) error { + result, err := c.StartAssessment(ctx, id) + if err != nil { + return fmt.Errorf("performing StartAssessment: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartAssessment: %+v", err) + } + + return nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_update.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_update.go new file mode 100644 index 00000000000..413762cb84c --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/method_update.go @@ -0,0 +1,74 @@ +package sqlvirtualmachines + +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 *SqlVirtualMachine +} + +// Update ... +func (c SqlVirtualMachinesClient) Update(ctx context.Context, id SqlVirtualMachineId, input SqlVirtualMachineUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 SqlVirtualMachinesClient) UpdateThenPoll(ctx context.Context, id SqlVirtualMachineId, input SqlVirtualMachineUpdate) 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_aadauthenticationsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_aadauthenticationsettings.go new file mode 100644 index 00000000000..f0f2a02729b --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_aadauthenticationsettings.go @@ -0,0 +1,8 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AADAuthenticationSettings struct { + ClientId *string `json:"clientId,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_additionalfeaturesserverconfigurations.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_additionalfeaturesserverconfigurations.go new file mode 100644 index 00000000000..8f469a40bda --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_additionalfeaturesserverconfigurations.go @@ -0,0 +1,8 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdditionalFeaturesServerConfigurations struct { + IsRServicesEnabled *bool `json:"isRServicesEnabled,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_assessmentsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_assessmentsettings.go new file mode 100644 index 00000000000..5f36ba97057 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_assessmentsettings.go @@ -0,0 +1,10 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssessmentSettings struct { + Enable *bool `json:"enable,omitempty"` + RunImmediately *bool `json:"runImmediately,omitempty"` + Schedule *Schedule `json:"schedule,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autobackupsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autobackupsettings.go new file mode 100644 index 00000000000..250c4f55347 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autobackupsettings.go @@ -0,0 +1,21 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoBackupSettings struct { + BackupScheduleType *BackupScheduleType `json:"backupScheduleType,omitempty"` + BackupSystemDbs *bool `json:"backupSystemDbs,omitempty"` + DaysOfWeek *[]AutoBackupDaysOfWeek `json:"daysOfWeek,omitempty"` + Enable *bool `json:"enable,omitempty"` + EnableEncryption *bool `json:"enableEncryption,omitempty"` + FullBackupFrequency *FullBackupFrequencyType `json:"fullBackupFrequency,omitempty"` + FullBackupStartTime *int64 `json:"fullBackupStartTime,omitempty"` + FullBackupWindowHours *int64 `json:"fullBackupWindowHours,omitempty"` + LogBackupFrequency *int64 `json:"logBackupFrequency,omitempty"` + Password *string `json:"password,omitempty"` + RetentionPeriod *int64 `json:"retentionPeriod,omitempty"` + StorageAccessKey *string `json:"storageAccessKey,omitempty"` + StorageAccountUrl *string `json:"storageAccountUrl,omitempty"` + StorageContainerName *string `json:"storageContainerName,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autopatchingsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autopatchingsettings.go new file mode 100644 index 00000000000..14a782b8445 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_autopatchingsettings.go @@ -0,0 +1,12 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoPatchingSettings struct { + AdditionalVMPatch *AdditionalVMPatch `json:"additionalVmPatch,omitempty"` + DayOfWeek *DayOfWeek `json:"dayOfWeek,omitempty"` + Enable *bool `json:"enable,omitempty"` + MaintenanceWindowDuration *int64 `json:"maintenanceWindowDuration,omitempty"` + MaintenanceWindowStartingHour *int64 `json:"maintenanceWindowStartingHour,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_diskconfigassessmentrequest.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_diskconfigassessmentrequest.go new file mode 100644 index 00000000000..26180a536c3 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_diskconfigassessmentrequest.go @@ -0,0 +1,8 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiskConfigAssessmentRequest struct { + RunDiskConfigRules *bool `json:"runDiskConfigRules,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_keyvaultcredentialsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_keyvaultcredentialsettings.go new file mode 100644 index 00000000000..e5407cb7381 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_keyvaultcredentialsettings.go @@ -0,0 +1,12 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultCredentialSettings struct { + AzureKeyVaultUrl *string `json:"azureKeyVaultUrl,omitempty"` + CredentialName *string `json:"credentialName,omitempty"` + Enable *bool `json:"enable,omitempty"` + ServicePrincipalName *string `json:"servicePrincipalName,omitempty"` + ServicePrincipalSecret *string `json:"servicePrincipalSecret,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_resourceidentity.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_resourceidentity.go new file mode 100644 index 00000000000..2ece9340a1d --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_resourceidentity.go @@ -0,0 +1,10 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceIdentity struct { + PrincipalId *string `json:"principalId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Type *IdentityType `json:"type,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_schedule.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_schedule.go new file mode 100644 index 00000000000..daf17d8673a --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_schedule.go @@ -0,0 +1,12 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Schedule struct { + DayOfWeek *AssessmentDayOfWeek `json:"dayOfWeek,omitempty"` + Enable *bool `json:"enable,omitempty"` + MonthlyOccurrence *int64 `json:"monthlyOccurrence,omitempty"` + StartTime *string `json:"startTime,omitempty"` + WeeklyInterval *int64 `json:"weeklyInterval,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_serverconfigurationsmanagementsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_serverconfigurationsmanagementsettings.go new file mode 100644 index 00000000000..17c13839c7d --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_serverconfigurationsmanagementsettings.go @@ -0,0 +1,13 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerConfigurationsManagementSettings struct { + AdditionalFeaturesServerConfigurations *AdditionalFeaturesServerConfigurations `json:"additionalFeaturesServerConfigurations,omitempty"` + AzureAdAuthenticationSettings *AADAuthenticationSettings `json:"azureAdAuthenticationSettings,omitempty"` + SqlConnectivityUpdateSettings *SqlConnectivityUpdateSettings `json:"sqlConnectivityUpdateSettings,omitempty"` + SqlInstanceSettings *SQLInstanceSettings `json:"sqlInstanceSettings,omitempty"` + SqlStorageUpdateSettings *SqlStorageUpdateSettings `json:"sqlStorageUpdateSettings,omitempty"` + SqlWorkloadTypeUpdateSettings *SqlWorkloadTypeUpdateSettings `json:"sqlWorkloadTypeUpdateSettings,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlconnectivityupdatesettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlconnectivityupdatesettings.go new file mode 100644 index 00000000000..fd63d6e4fc1 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlconnectivityupdatesettings.go @@ -0,0 +1,11 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlConnectivityUpdateSettings struct { + ConnectivityType *ConnectivityType `json:"connectivityType,omitempty"` + Port *int64 `json:"port,omitempty"` + SqlAuthUpdatePassword *string `json:"sqlAuthUpdatePassword,omitempty"` + SqlAuthUpdateUserName *string `json:"sqlAuthUpdateUserName,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlinstancesettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlinstancesettings.go new file mode 100644 index 00000000000..b6da449b41d --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlinstancesettings.go @@ -0,0 +1,14 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLInstanceSettings struct { + Collation *string `json:"collation,omitempty"` + IsIfiEnabled *bool `json:"isIfiEnabled,omitempty"` + IsLpimEnabled *bool `json:"isLpimEnabled,omitempty"` + IsOptimizeForAdHocWorkloadsEnabled *bool `json:"isOptimizeForAdHocWorkloadsEnabled,omitempty"` + MaxDop *int64 `json:"maxDop,omitempty"` + MaxServerMemoryMB *int64 `json:"maxServerMemoryMB,omitempty"` + MinServerMemoryMB *int64 `json:"minServerMemoryMB,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstoragesettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstoragesettings.go new file mode 100644 index 00000000000..ef857c1d4ae --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstoragesettings.go @@ -0,0 +1,10 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLStorageSettings struct { + DefaultFilePath *string `json:"defaultFilePath,omitempty"` + Luns *[]int64 `json:"luns,omitempty"` + UseStoragePool *bool `json:"useStoragePool,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstorageupdatesettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstorageupdatesettings.go new file mode 100644 index 00000000000..a5186fd3711 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlstorageupdatesettings.go @@ -0,0 +1,10 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlStorageUpdateSettings struct { + DiskConfigurationType *DiskConfigurationType `json:"diskConfigurationType,omitempty"` + DiskCount *int64 `json:"diskCount,omitempty"` + StartingDeviceId *int64 `json:"startingDeviceId,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqltempdbsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqltempdbsettings.go new file mode 100644 index 00000000000..11cdd849830 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqltempdbsettings.go @@ -0,0 +1,17 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SQLTempDbSettings struct { + DataFileCount *int64 `json:"dataFileCount,omitempty"` + DataFileSize *int64 `json:"dataFileSize,omitempty"` + DataGrowth *int64 `json:"dataGrowth,omitempty"` + DefaultFilePath *string `json:"defaultFilePath,omitempty"` + LogFileSize *int64 `json:"logFileSize,omitempty"` + LogGrowth *int64 `json:"logGrowth,omitempty"` + Luns *[]int64 `json:"luns,omitempty"` + PersistFolder *bool `json:"persistFolder,omitempty"` + PersistFolderPath *string `json:"persistFolderPath,omitempty"` + UseStoragePool *bool `json:"useStoragePool,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachine.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachine.go new file mode 100644 index 00000000000..3d03a6b0be4 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachine.go @@ -0,0 +1,19 @@ +package sqlvirtualmachines + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachine struct { + Id *string `json:"id,omitempty"` + Identity *ResourceIdentity `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SqlVirtualMachineProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineproperties.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineproperties.go new file mode 100644 index 00000000000..55567172c52 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineproperties.go @@ -0,0 +1,28 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachineProperties struct { + AdditionalVMPatch *AdditionalOsPatch `json:"additionalVmPatch,omitempty"` + AssessmentSettings *AssessmentSettings `json:"assessmentSettings,omitempty"` + AutoBackupSettings *AutoBackupSettings `json:"autoBackupSettings,omitempty"` + AutoPatchingSettings *AutoPatchingSettings `json:"autoPatchingSettings,omitempty"` + EnableAutomaticUpgrade *bool `json:"enableAutomaticUpgrade,omitempty"` + KeyVaultCredentialSettings *KeyVaultCredentialSettings `json:"keyVaultCredentialSettings,omitempty"` + LeastPrivilegeMode *LeastPrivilegeMode `json:"leastPrivilegeMode,omitempty"` + OsType *OsType `json:"osType,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ServerConfigurationsManagementSettings *ServerConfigurationsManagementSettings `json:"serverConfigurationsManagementSettings,omitempty"` + SqlImageOffer *string `json:"sqlImageOffer,omitempty"` + SqlImageSku *SqlImageSku `json:"sqlImageSku,omitempty"` + SqlManagement *SqlManagementMode `json:"sqlManagement,omitempty"` + SqlServerLicenseType *SqlServerLicenseType `json:"sqlServerLicenseType,omitempty"` + SqlVirtualMachineGroupResourceId *string `json:"sqlVirtualMachineGroupResourceId,omitempty"` + StorageConfigurationSettings *StorageConfigurationSettings `json:"storageConfigurationSettings,omitempty"` + TroubleshootingStatus *TroubleshootingStatus `json:"troubleshootingStatus,omitempty"` + VirtualMachineIdentitySettings *VirtualMachineIdentity `json:"virtualMachineIdentitySettings,omitempty"` + VirtualMachineResourceId *string `json:"virtualMachineResourceId,omitempty"` + WsfcDomainCredentials *WsfcDomainCredentials `json:"wsfcDomainCredentials,omitempty"` + WsfcStaticIP *string `json:"wsfcStaticIp,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineupdate.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineupdate.go new file mode 100644 index 00000000000..b02b09b0aaa --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlvirtualmachineupdate.go @@ -0,0 +1,8 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachineUpdate struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlworkloadtypeupdatesettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlworkloadtypeupdatesettings.go new file mode 100644 index 00000000000..118f0cf2f1f --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_sqlworkloadtypeupdatesettings.go @@ -0,0 +1,8 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlWorkloadTypeUpdateSettings struct { + SqlWorkloadType *SqlWorkloadType `json:"sqlWorkloadType,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_storageconfigurationsettings.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_storageconfigurationsettings.go new file mode 100644 index 00000000000..8eca3cc8b77 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_storageconfigurationsettings.go @@ -0,0 +1,14 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageConfigurationSettings struct { + DiskConfigurationType *DiskConfigurationType `json:"diskConfigurationType,omitempty"` + EnableStorageConfigBlade *bool `json:"enableStorageConfigBlade,omitempty"` + SqlDataSettings *SQLStorageSettings `json:"sqlDataSettings,omitempty"` + SqlLogSettings *SQLStorageSettings `json:"sqlLogSettings,omitempty"` + SqlSystemDbOnDataDisk *bool `json:"sqlSystemDbOnDataDisk,omitempty"` + SqlTempDbSettings *SQLTempDbSettings `json:"sqlTempDbSettings,omitempty"` + StorageWorkloadType *StorageWorkloadType `json:"storageWorkloadType,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingadditionalproperties.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingadditionalproperties.go new file mode 100644 index 00000000000..c0433d34726 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingadditionalproperties.go @@ -0,0 +1,8 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TroubleshootingAdditionalProperties struct { + UnhealthyReplicaInfo *UnhealthyReplicaInfo `json:"unhealthyReplicaInfo,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingstatus.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingstatus.go new file mode 100644 index 00000000000..da69e4a85b6 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_troubleshootingstatus.go @@ -0,0 +1,55 @@ +package sqlvirtualmachines + +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 TroubleshootingStatus struct { + EndTimeUtc *string `json:"endTimeUtc,omitempty"` + LastTriggerTimeUtc *string `json:"lastTriggerTimeUtc,omitempty"` + Properties *TroubleshootingAdditionalProperties `json:"properties,omitempty"` + RootCause *string `json:"rootCause,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + TroubleshootingScenario *TroubleshootingScenario `json:"troubleshootingScenario,omitempty"` +} + +func (o *TroubleshootingStatus) GetEndTimeUtcAsTime() (*time.Time, error) { + if o.EndTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *TroubleshootingStatus) SetEndTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTimeUtc = &formatted +} + +func (o *TroubleshootingStatus) GetLastTriggerTimeUtcAsTime() (*time.Time, error) { + if o.LastTriggerTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastTriggerTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *TroubleshootingStatus) SetLastTriggerTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastTriggerTimeUtc = &formatted +} + +func (o *TroubleshootingStatus) GetStartTimeUtcAsTime() (*time.Time, error) { + if o.StartTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *TroubleshootingStatus) SetStartTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeUtc = &formatted +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_unhealthyreplicainfo.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_unhealthyreplicainfo.go new file mode 100644 index 00000000000..10c069b604e --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_unhealthyreplicainfo.go @@ -0,0 +1,8 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnhealthyReplicaInfo struct { + AvailabilityGroupName *string `json:"availabilityGroupName,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_virtualmachineidentity.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_virtualmachineidentity.go new file mode 100644 index 00000000000..5030911fff3 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_virtualmachineidentity.go @@ -0,0 +1,9 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineIdentity struct { + ResourceId *string `json:"resourceId,omitempty"` + Type *VMIdentityType `json:"type,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_wsfcdomaincredentials.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_wsfcdomaincredentials.go new file mode 100644 index 00000000000..abefce4cde6 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/model_wsfcdomaincredentials.go @@ -0,0 +1,10 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WsfcDomainCredentials struct { + ClusterBootstrapAccountPassword *string `json:"clusterBootstrapAccountPassword,omitempty"` + ClusterOperatorAccountPassword *string `json:"clusterOperatorAccountPassword,omitempty"` + SqlServiceAccountPassword *string `json:"sqlServiceAccountPassword,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/predicates.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/predicates.go new file mode 100644 index 00000000000..1fd5e8f748c --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/predicates.go @@ -0,0 +1,32 @@ +package sqlvirtualmachines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SqlVirtualMachineOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SqlVirtualMachineOperationPredicate) Matches(input SqlVirtualMachine) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/version.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/version.go new file mode 100644 index 00000000000..2c8d7fb3ad3 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachines/version.go @@ -0,0 +1,12 @@ +package sqlvirtualmachines + +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-10-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/sqlvirtualmachines/%s", defaultApiVersion) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/README.md b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/README.md new file mode 100644 index 00000000000..e5620d91de0 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot` Documentation + +The `sqlvirtualmachinetroubleshoot` SDK allows for interaction with the Azure Resource Manager Service `sqlvirtualmachine` (API Version `2023-10-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot" +``` + + +### Client Initialization + +```go +client := sqlvirtualmachinetroubleshoot.NewSqlVirtualMachineTroubleshootClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SqlVirtualMachineTroubleshootClient.Troubleshoot` + +```go +ctx := context.TODO() +id := sqlvirtualmachinetroubleshoot.NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + +payload := sqlvirtualmachinetroubleshoot.SqlVMTroubleshooting{ + // ... +} + + +if err := client.TroubleshootThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/client.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/client.go new file mode 100644 index 00000000000..419352a64df --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/client.go @@ -0,0 +1,26 @@ +package sqlvirtualmachinetroubleshoot + +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 SqlVirtualMachineTroubleshootClient struct { + Client *resourcemanager.Client +} + +func NewSqlVirtualMachineTroubleshootClientWithBaseURI(sdkApi sdkEnv.Api) (*SqlVirtualMachineTroubleshootClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "sqlvirtualmachinetroubleshoot", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SqlVirtualMachineTroubleshootClient: %+v", err) + } + + return &SqlVirtualMachineTroubleshootClient{ + Client: client, + }, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/constants.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/constants.go new file mode 100644 index 00000000000..6bc2d575488 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/constants.go @@ -0,0 +1,48 @@ +package sqlvirtualmachinetroubleshoot + +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 TroubleshootingScenario string + +const ( + TroubleshootingScenarioUnhealthyReplica TroubleshootingScenario = "UnhealthyReplica" +) + +func PossibleValuesForTroubleshootingScenario() []string { + return []string{ + string(TroubleshootingScenarioUnhealthyReplica), + } +} + +func (s *TroubleshootingScenario) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTroubleshootingScenario(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTroubleshootingScenario(input string) (*TroubleshootingScenario, error) { + vals := map[string]TroubleshootingScenario{ + "unhealthyreplica": TroubleshootingScenarioUnhealthyReplica, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TroubleshootingScenario(input) + return &out, nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine.go new file mode 100644 index 00000000000..bc28c1a860a --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine.go @@ -0,0 +1,130 @@ +package sqlvirtualmachinetroubleshoot + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SqlVirtualMachineId{}) +} + +var _ resourceids.ResourceId = &SqlVirtualMachineId{} + +// SqlVirtualMachineId is a struct representing the Resource ID for a Sql Virtual Machine +type SqlVirtualMachineId struct { + SubscriptionId string + ResourceGroupName string + SqlVirtualMachineName string +} + +// NewSqlVirtualMachineID returns a new SqlVirtualMachineId struct +func NewSqlVirtualMachineID(subscriptionId string, resourceGroupName string, sqlVirtualMachineName string) SqlVirtualMachineId { + return SqlVirtualMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SqlVirtualMachineName: sqlVirtualMachineName, + } +} + +// ParseSqlVirtualMachineID parses 'input' into a SqlVirtualMachineId +func ParseSqlVirtualMachineID(input string) (*SqlVirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSqlVirtualMachineIDInsensitively parses 'input' case-insensitively into a SqlVirtualMachineId +// note: this method should only be used for API response data and not user input +func ParseSqlVirtualMachineIDInsensitively(input string) (*SqlVirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&SqlVirtualMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SqlVirtualMachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SqlVirtualMachineId) 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.SqlVirtualMachineName, ok = input.Parsed["sqlVirtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sqlVirtualMachineName", input) + } + + return nil +} + +// ValidateSqlVirtualMachineID checks that 'input' can be parsed as a Sql Virtual Machine ID +func ValidateSqlVirtualMachineID(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 := ParseSqlVirtualMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sql Virtual Machine ID +func (id SqlVirtualMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SqlVirtualMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sql Virtual Machine ID +func (id SqlVirtualMachineId) 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("staticMicrosoftSqlVirtualMachine", "Microsoft.SqlVirtualMachine", "Microsoft.SqlVirtualMachine"), + resourceids.StaticSegment("staticSqlVirtualMachines", "sqlVirtualMachines", "sqlVirtualMachines"), + resourceids.UserSpecifiedSegment("sqlVirtualMachineName", "sqlVirtualMachineValue"), + } +} + +// String returns a human-readable description of this Sql Virtual Machine ID +func (id SqlVirtualMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Sql Virtual Machine Name: %q", id.SqlVirtualMachineName), + } + return fmt.Sprintf("Sql Virtual Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine_test.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine_test.go new file mode 100644 index 00000000000..a631ca8e122 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/id_sqlvirtualmachine_test.go @@ -0,0 +1,282 @@ +package sqlvirtualmachinetroubleshoot + +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 = &SqlVirtualMachineId{} + +func TestNewSqlVirtualMachineID(t *testing.T) { + id := NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue") + + 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.SqlVirtualMachineName != "sqlVirtualMachineValue" { + t.Fatalf("Expected %q but got %q for Segment 'SqlVirtualMachineName'", id.SqlVirtualMachineName, "sqlVirtualMachineValue") + } +} + +func TestFormatSqlVirtualMachineID(t *testing.T) { + actual := NewSqlVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "sqlVirtualMachineValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSqlVirtualMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue", + Expected: &SqlVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineName: "sqlVirtualMachineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineName != v.Expected.SqlVirtualMachineName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineName", v.Expected.SqlVirtualMachineName, actual.SqlVirtualMachineName) + } + + } +} + +func TestParseSqlVirtualMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SqlVirtualMachineId + }{ + { + // 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.SqlVirtualMachine", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue", + Expected: &SqlVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SqlVirtualMachineName: "sqlVirtualMachineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/sqlVirtualMachineValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeS/sQlViRtUaLmAcHiNeVaLuE", + Expected: &SqlVirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SqlVirtualMachineName: "sQlViRtUaLmAcHiNeVaLuE", + }, + }, + { + // 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.sQlViRtUaLmAcHiNe/sQlViRtUaLmAcHiNeS/sQlViRtUaLmAcHiNeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSqlVirtualMachineIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SqlVirtualMachineName != v.Expected.SqlVirtualMachineName { + t.Fatalf("Expected %q but got %q for SqlVirtualMachineName", v.Expected.SqlVirtualMachineName, actual.SqlVirtualMachineName) + } + + } +} + +func TestSegmentsForSqlVirtualMachineId(t *testing.T) { + segments := SqlVirtualMachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SqlVirtualMachineId 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/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/method_troubleshoot.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/method_troubleshoot.go new file mode 100644 index 00000000000..33069c06249 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/method_troubleshoot.go @@ -0,0 +1,75 @@ +package sqlvirtualmachinetroubleshoot + +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 TroubleshootOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SqlVMTroubleshooting +} + +// Troubleshoot ... +func (c SqlVirtualMachineTroubleshootClient) Troubleshoot(ctx context.Context, id SqlVirtualMachineId, input SqlVMTroubleshooting) (result TroubleshootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/troubleshoot", 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 +} + +// TroubleshootThenPoll performs Troubleshoot then polls until it's completed +func (c SqlVirtualMachineTroubleshootClient) TroubleshootThenPoll(ctx context.Context, id SqlVirtualMachineId, input SqlVMTroubleshooting) error { + result, err := c.Troubleshoot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Troubleshoot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Troubleshoot: %+v", err) + } + + return nil +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_sqlvmtroubleshooting.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_sqlvmtroubleshooting.go new file mode 100644 index 00000000000..ee1eb44198f --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_sqlvmtroubleshooting.go @@ -0,0 +1,42 @@ +package sqlvirtualmachinetroubleshoot + +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 SqlVMTroubleshooting struct { + EndTimeUtc *string `json:"endTimeUtc,omitempty"` + Properties *TroubleshootingAdditionalProperties `json:"properties,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + TroubleshootingScenario *TroubleshootingScenario `json:"troubleshootingScenario,omitempty"` + VirtualMachineResourceId *string `json:"virtualMachineResourceId,omitempty"` +} + +func (o *SqlVMTroubleshooting) GetEndTimeUtcAsTime() (*time.Time, error) { + if o.EndTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SqlVMTroubleshooting) SetEndTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTimeUtc = &formatted +} + +func (o *SqlVMTroubleshooting) GetStartTimeUtcAsTime() (*time.Time, error) { + if o.StartTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SqlVMTroubleshooting) SetStartTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeUtc = &formatted +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_troubleshootingadditionalproperties.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_troubleshootingadditionalproperties.go new file mode 100644 index 00000000000..158215e27e3 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_troubleshootingadditionalproperties.go @@ -0,0 +1,8 @@ +package sqlvirtualmachinetroubleshoot + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TroubleshootingAdditionalProperties struct { + UnhealthyReplicaInfo *UnhealthyReplicaInfo `json:"unhealthyReplicaInfo,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_unhealthyreplicainfo.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_unhealthyreplicainfo.go new file mode 100644 index 00000000000..70827c43e8a --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/model_unhealthyreplicainfo.go @@ -0,0 +1,8 @@ +package sqlvirtualmachinetroubleshoot + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnhealthyReplicaInfo struct { + AvailabilityGroupName *string `json:"availabilityGroupName,omitempty"` +} diff --git a/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/version.go b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/version.go new file mode 100644 index 00000000000..4c7bff87b59 --- /dev/null +++ b/resource-manager/sqlvirtualmachine/2023-10-01/sqlvirtualmachinetroubleshoot/version.go @@ -0,0 +1,12 @@ +package sqlvirtualmachinetroubleshoot + +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-10-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/sqlvirtualmachinetroubleshoot/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-01-01/appserviceenvironments/model_siteproperties.go b/resource-manager/web/2023-01-01/appserviceenvironments/model_siteproperties.go index 37d0c491c74..3413efafc9d 100644 --- a/resource-manager/web/2023-01-01/appserviceenvironments/model_siteproperties.go +++ b/resource-manager/web/2023-01-01/appserviceenvironments/model_siteproperties.go @@ -23,6 +23,7 @@ type SiteProperties struct { DefaultHostName *string `json:"defaultHostName,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` HostNames *[]string `json:"hostNames,omitempty"` diff --git a/resource-manager/web/2023-01-01/appserviceplans/model_siteproperties.go b/resource-manager/web/2023-01-01/appserviceplans/model_siteproperties.go index aafda2821e2..cb28607e89f 100644 --- a/resource-manager/web/2023-01-01/appserviceplans/model_siteproperties.go +++ b/resource-manager/web/2023-01-01/appserviceplans/model_siteproperties.go @@ -23,6 +23,7 @@ type SiteProperties struct { DefaultHostName *string `json:"defaultHostName,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` HostNames *[]string `json:"hostNames,omitempty"` diff --git a/resource-manager/web/2023-01-01/webapps/model_siteproperties.go b/resource-manager/web/2023-01-01/webapps/model_siteproperties.go index 2652a0f07ad..db2b3b6e3bc 100644 --- a/resource-manager/web/2023-01-01/webapps/model_siteproperties.go +++ b/resource-manager/web/2023-01-01/webapps/model_siteproperties.go @@ -23,6 +23,7 @@ type SiteProperties struct { DefaultHostName *string `json:"defaultHostName,omitempty"` Enabled *bool `json:"enabled,omitempty"` EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` HTTPSOnly *bool `json:"httpsOnly,omitempty"` HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` HostNames *[]string `json:"hostNames,omitempty"` diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/README.md b/resource-manager/web/2023-12-01/appservicecertificateorders/README.md new file mode 100644 index 00000000000..3853972067b --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/README.md @@ -0,0 +1,381 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appservicecertificateorders` Documentation + +The `appservicecertificateorders` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appservicecertificateorders" +``` + + +### Client Initialization + +```go +client := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +payload := appservicecertificateorders.AppServiceCertificateResource{ + // ... +} + + +if err := client.CreateOrUpdateCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Delete` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.DeleteCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +read, err := client.DeleteCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Get` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +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: `AppServiceCertificateOrdersClient.GetCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +read, err := client.GetCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `AppServiceCertificateOrdersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListCertificates` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +// alternatively `client.ListCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Reissue` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.ReissueCertificateOrderRequest{ + // ... +} + + +read, err := client.Reissue(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Renew` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.RenewCertificateOrderRequest{ + // ... +} + + +read, err := client.Renew(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendEmail` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.ResendEmail(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendRequestEmails` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.NameIdentifier{ + // ... +} + + +read, err := client.ResendRequestEmails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateActions` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.RetrieveCertificateActions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateEmailHistory` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.RetrieveCertificateEmailHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveSiteSeal` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.SiteSealRequest{ + // ... +} + + +read, err := client.RetrieveSiteSeal(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Update` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +payload := appservicecertificateorders.AppServiceCertificateOrderPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.UpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + +payload := appservicecertificateorders.AppServiceCertificatePatchResource{ + // ... +} + + +read, err := client.UpdateCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ValidatePurchaseInformation` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +read, err := client.ValidatePurchaseInformation(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.VerifyDomainOwnership` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +read, err := client.VerifyDomainOwnership(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/web/2023-12-01/appservicecertificateorders/client.go b/resource-manager/web/2023-12-01/appservicecertificateorders/client.go new file mode 100644 index 00000000000..06d6b4e2962 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/client.go @@ -0,0 +1,26 @@ +package appservicecertificateorders + +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 AppServiceCertificateOrdersClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceCertificateOrdersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "appservicecertificateorders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceCertificateOrdersClient: %+v", err) + } + + return &AppServiceCertificateOrdersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/constants.go b/resource-manager/web/2023-12-01/appservicecertificateorders/constants.go new file mode 100644 index 00000000000..7fd04266697 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/constants.go @@ -0,0 +1,355 @@ +package appservicecertificateorders + +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 CertificateOrderActionType string + +const ( + CertificateOrderActionTypeCertificateExpirationWarning CertificateOrderActionType = "CertificateExpirationWarning" + CertificateOrderActionTypeCertificateExpired CertificateOrderActionType = "CertificateExpired" + CertificateOrderActionTypeCertificateIssued CertificateOrderActionType = "CertificateIssued" + CertificateOrderActionTypeCertificateOrderCanceled CertificateOrderActionType = "CertificateOrderCanceled" + CertificateOrderActionTypeCertificateOrderCreated CertificateOrderActionType = "CertificateOrderCreated" + CertificateOrderActionTypeCertificateRevoked CertificateOrderActionType = "CertificateRevoked" + CertificateOrderActionTypeDomainValidationComplete CertificateOrderActionType = "DomainValidationComplete" + CertificateOrderActionTypeFraudCleared CertificateOrderActionType = "FraudCleared" + CertificateOrderActionTypeFraudDetected CertificateOrderActionType = "FraudDetected" + CertificateOrderActionTypeFraudDocumentationRequired CertificateOrderActionType = "FraudDocumentationRequired" + CertificateOrderActionTypeOrgNameChange CertificateOrderActionType = "OrgNameChange" + CertificateOrderActionTypeOrgValidationComplete CertificateOrderActionType = "OrgValidationComplete" + CertificateOrderActionTypeSanDrop CertificateOrderActionType = "SanDrop" + CertificateOrderActionTypeUnknown CertificateOrderActionType = "Unknown" +) + +func PossibleValuesForCertificateOrderActionType() []string { + return []string{ + string(CertificateOrderActionTypeCertificateExpirationWarning), + string(CertificateOrderActionTypeCertificateExpired), + string(CertificateOrderActionTypeCertificateIssued), + string(CertificateOrderActionTypeCertificateOrderCanceled), + string(CertificateOrderActionTypeCertificateOrderCreated), + string(CertificateOrderActionTypeCertificateRevoked), + string(CertificateOrderActionTypeDomainValidationComplete), + string(CertificateOrderActionTypeFraudCleared), + string(CertificateOrderActionTypeFraudDetected), + string(CertificateOrderActionTypeFraudDocumentationRequired), + string(CertificateOrderActionTypeOrgNameChange), + string(CertificateOrderActionTypeOrgValidationComplete), + string(CertificateOrderActionTypeSanDrop), + string(CertificateOrderActionTypeUnknown), + } +} + +func (s *CertificateOrderActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderActionType(input string) (*CertificateOrderActionType, error) { + vals := map[string]CertificateOrderActionType{ + "certificateexpirationwarning": CertificateOrderActionTypeCertificateExpirationWarning, + "certificateexpired": CertificateOrderActionTypeCertificateExpired, + "certificateissued": CertificateOrderActionTypeCertificateIssued, + "certificateordercanceled": CertificateOrderActionTypeCertificateOrderCanceled, + "certificateordercreated": CertificateOrderActionTypeCertificateOrderCreated, + "certificaterevoked": CertificateOrderActionTypeCertificateRevoked, + "domainvalidationcomplete": CertificateOrderActionTypeDomainValidationComplete, + "fraudcleared": CertificateOrderActionTypeFraudCleared, + "frauddetected": CertificateOrderActionTypeFraudDetected, + "frauddocumentationrequired": CertificateOrderActionTypeFraudDocumentationRequired, + "orgnamechange": CertificateOrderActionTypeOrgNameChange, + "orgvalidationcomplete": CertificateOrderActionTypeOrgValidationComplete, + "sandrop": CertificateOrderActionTypeSanDrop, + "unknown": CertificateOrderActionTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderActionType(input) + return &out, nil +} + +type CertificateOrderStatus string + +const ( + CertificateOrderStatusCanceled CertificateOrderStatus = "Canceled" + CertificateOrderStatusDenied CertificateOrderStatus = "Denied" + CertificateOrderStatusExpired CertificateOrderStatus = "Expired" + CertificateOrderStatusIssued CertificateOrderStatus = "Issued" + CertificateOrderStatusNotSubmitted CertificateOrderStatus = "NotSubmitted" + CertificateOrderStatusPendingRekey CertificateOrderStatus = "PendingRekey" + CertificateOrderStatusPendingissuance CertificateOrderStatus = "Pendingissuance" + CertificateOrderStatusPendingrevocation CertificateOrderStatus = "Pendingrevocation" + CertificateOrderStatusRevoked CertificateOrderStatus = "Revoked" + CertificateOrderStatusUnused CertificateOrderStatus = "Unused" +) + +func PossibleValuesForCertificateOrderStatus() []string { + return []string{ + string(CertificateOrderStatusCanceled), + string(CertificateOrderStatusDenied), + string(CertificateOrderStatusExpired), + string(CertificateOrderStatusIssued), + string(CertificateOrderStatusNotSubmitted), + string(CertificateOrderStatusPendingRekey), + string(CertificateOrderStatusPendingissuance), + string(CertificateOrderStatusPendingrevocation), + string(CertificateOrderStatusRevoked), + string(CertificateOrderStatusUnused), + } +} + +func (s *CertificateOrderStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderStatus(input string) (*CertificateOrderStatus, error) { + vals := map[string]CertificateOrderStatus{ + "canceled": CertificateOrderStatusCanceled, + "denied": CertificateOrderStatusDenied, + "expired": CertificateOrderStatusExpired, + "issued": CertificateOrderStatusIssued, + "notsubmitted": CertificateOrderStatusNotSubmitted, + "pendingrekey": CertificateOrderStatusPendingRekey, + "pendingissuance": CertificateOrderStatusPendingissuance, + "pendingrevocation": CertificateOrderStatusPendingrevocation, + "revoked": CertificateOrderStatusRevoked, + "unused": CertificateOrderStatusUnused, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderStatus(input) + return &out, nil +} + +type CertificateProductType string + +const ( + CertificateProductTypeStandardDomainValidatedSsl CertificateProductType = "StandardDomainValidatedSsl" + CertificateProductTypeStandardDomainValidatedWildCardSsl CertificateProductType = "StandardDomainValidatedWildCardSsl" +) + +func PossibleValuesForCertificateProductType() []string { + return []string{ + string(CertificateProductTypeStandardDomainValidatedSsl), + string(CertificateProductTypeStandardDomainValidatedWildCardSsl), + } +} + +func (s *CertificateProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProductType(input string) (*CertificateProductType, error) { + vals := map[string]CertificateProductType{ + "standarddomainvalidatedssl": CertificateProductTypeStandardDomainValidatedSsl, + "standarddomainvalidatedwildcardssl": CertificateProductTypeStandardDomainValidatedWildCardSsl, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProductType(input) + return &out, nil +} + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate.go b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate.go new file mode 100644 index 00000000000..e1678574f38 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate.go @@ -0,0 +1,139 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, certificateOrderName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderValue"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate_test.go b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate_test.go new file mode 100644 index 00000000000..60d72344ae0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificate_test.go @@ -0,0 +1,327 @@ +package appservicecertificateorders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue") + + 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.CertificateOrderName != "certificateOrderValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderValue") + } + + if id.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/certificates/certificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/certificates/certificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/certificates/certificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRvAlUe", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/cErTiFiCaTeS/cErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder.go b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder.go new file mode 100644 index 00000000000..7f0356716b2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder.go @@ -0,0 +1,130 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(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 := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderValue"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder_test.go b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder_test.go new file mode 100644 index 00000000000..cbb4fd42d00 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/id_certificateorder_test.go @@ -0,0 +1,282 @@ +package appservicecertificateorders + +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 = &CertificateOrderId{} + +func TestNewCertificateOrderID(t *testing.T) { + id := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + + 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.CertificateOrderName != "certificateOrderValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderValue") + } +} + +func TestFormatCertificateOrderID(t *testing.T) { + actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestParseCertificateOrderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRvAlUe", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestSegmentsForCertificateOrderId(t *testing.T) { + segments := CertificateOrderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderId 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/web/2023-12-01/appservicecertificateorders/method_createorupdate.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_createorupdate.go new file mode 100644 index 00000000000..0ee50f71694 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_createorupdate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// CreateOrUpdate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go new file mode 100644 index 00000000000..f8d50a20ddc --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_createorupdatecertificate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +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 CreateOrUpdateCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// CreateOrUpdateCertificate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificateResource) (result CreateOrUpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateCertificateThenPoll performs CreateOrUpdateCertificate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificateThenPoll(ctx context.Context, id CertificateId, input AppServiceCertificateResource) error { + result, err := c.CreateOrUpdateCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateCertificate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_delete.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_delete.go new file mode 100644 index 00000000000..f8f40a08c11 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_delete.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServiceCertificateOrdersClient) Delete(ctx context.Context, id CertificateOrderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_deletecertificate.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_deletecertificate.go new file mode 100644 index 00000000000..1bd00712f78 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_deletecertificate.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +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 DeleteCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteCertificate ... +func (c AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, id CertificateId) (result DeleteCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_get.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_get.go new file mode 100644 index 00000000000..b4df83fdd65 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_get.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +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 *AppServiceCertificateOrder +} + +// Get ... +func (c AppServiceCertificateOrdersClient) Get(ctx context.Context, id CertificateOrderId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateOrder + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_getcertificate.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_getcertificate.go new file mode 100644 index 00000000000..45675824b49 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_getcertificate.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +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 GetCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// GetCertificate ... +func (c AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, id CertificateId) (result GetCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_list.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_list.go new file mode 100644 index 00000000000..a6c3ac26212 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_list.go @@ -0,0 +1,92 @@ +package appservicecertificateorders + +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 *[]AppServiceCertificateOrder +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +// List ... +func (c AppServiceCertificateOrdersClient) List(ctx context.Context, id commonids.SubscriptionId) (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.CertificateRegistration/certificateOrders", 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 *[]AppServiceCertificateOrder `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 AppServiceCertificateOrdersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceCertificateOrderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 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/web/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go new file mode 100644 index 00000000000..74ea0faa4b0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +// ListByResourceGroup ... +func (c AppServiceCertificateOrdersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", 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 *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceCertificateOrderOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_listcertificates.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_listcertificates.go new file mode 100644 index 00000000000..f13d03c4b86 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_listcertificates.go @@ -0,0 +1,91 @@ +package appservicecertificateorders + +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 ListCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateResource +} + +type ListCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateResource +} + +// ListCertificates ... +func (c AppServiceCertificateOrdersClient) ListCertificates(ctx context.Context, id CertificateOrderId) (result ListCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/certificates", 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 *[]AppServiceCertificateResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCertificatesComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListCertificatesComplete(ctx context.Context, id CertificateOrderId) (ListCertificatesCompleteResult, error) { + return c.ListCertificatesCompleteMatchingPredicate(ctx, id, AppServiceCertificateResourceOperationPredicate{}) +} + +// ListCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate AppServiceCertificateResourceOperationPredicate) (result ListCertificatesCompleteResult, err error) { + items := make([]AppServiceCertificateResource, 0) + + resp, err := c.ListCertificates(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 = ListCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_reissue.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_reissue.go new file mode 100644 index 00000000000..91b863f81f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_reissue.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +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 ReissueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reissue ... +func (c AppServiceCertificateOrdersClient) Reissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (result ReissueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reissue", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_renew.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_renew.go new file mode 100644 index 00000000000..0d15451ed17 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_renew.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +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 RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c AppServiceCertificateOrdersClient) Renew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", 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 + } + + return +} diff --git a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/method_clusterstriggerupgradepost.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_resendemail.go similarity index 69% rename from resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/method_clusterstriggerupgradepost.go rename to resource-manager/web/2023-12-01/appservicecertificateorders/method_resendemail.go index d7fbac9171b..49de4389c59 100644 --- a/resource-manager/eventhub/2024-01-01/eventhubsclustersupgrade/method_clusterstriggerupgradepost.go +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_resendemail.go @@ -1,4 +1,4 @@ -package eventhubsclustersupgrade +package appservicecertificateorders import ( "context" @@ -12,20 +12,20 @@ import ( // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. -type ClustersTriggerUpgradePostOperationResponse struct { +type ResendEmailOperationResponse struct { HttpResponse *http.Response OData *odata.OData } -// ClustersTriggerUpgradePost ... -func (c EventHubsClustersUpgradeClient) ClustersTriggerUpgradePost(ctx context.Context, id ClusterId) (result ClustersTriggerUpgradePostOperationResponse, err error) { +// ResendEmail ... +func (c AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, id CertificateOrderId) (result ResendEmailOperationResponse, err error) { opts := client.RequestOptions{ ContentType: "application/json; charset=utf-8", ExpectedStatusCodes: []int{ http.StatusNoContent, }, HttpMethod: http.MethodPost, - Path: fmt.Sprintf("%s/triggerUpgrade", id.ID()), + Path: fmt.Sprintf("%s/resendEmail", id.ID()), } req, err := c.Client.NewRequest(ctx, opts) diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_resendrequestemails.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_resendrequestemails.go new file mode 100644 index 00000000000..e758b4dd706 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_resendrequestemails.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +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 ResendRequestEmailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendRequestEmails ... +func (c AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (result ResendRequestEmailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendRequestEmails", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go new file mode 100644 index 00000000000..306f696af31 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateactions.go @@ -0,0 +1,55 @@ +package appservicecertificateorders + +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 RetrieveCertificateActionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateOrderAction +} + +// RetrieveCertificateActions ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateActionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveCertificateActions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateOrderAction + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go new file mode 100644 index 00000000000..7fc5e4324d7 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievecertificateemailhistory.go @@ -0,0 +1,55 @@ +package appservicecertificateorders + +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 RetrieveCertificateEmailHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateEmail +} + +// RetrieveCertificateEmailHistory ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveEmailHistory", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateEmail + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go new file mode 100644 index 00000000000..d84e5f86511 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_retrievesiteseal.go @@ -0,0 +1,59 @@ +package appservicecertificateorders + +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 RetrieveSiteSealOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSeal +} + +// RetrieveSiteSeal ... +func (c AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (result RetrieveSiteSealOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveSiteSeal", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSeal + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_update.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_update.go new file mode 100644 index 00000000000..999e03e24ae --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_update.go @@ -0,0 +1,58 @@ +package appservicecertificateorders + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Update ... +func (c AppServiceCertificateOrdersClient) Update(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model AppServiceCertificateOrder + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_updatecertificate.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_updatecertificate.go new file mode 100644 index 00000000000..b94998c44aa --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_updatecertificate.go @@ -0,0 +1,58 @@ +package appservicecertificateorders + +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 UpdateCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// UpdateCertificate ... +func (c AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, id CertificateId, input AppServiceCertificatePatchResource) (result UpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model AppServiceCertificateResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go new file mode 100644 index 00000000000..1a4c9a08f69 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_validatepurchaseinformation.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +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 ValidatePurchaseInformationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidatePurchaseInformation ... +func (c AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (result ValidatePurchaseInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/method_verifydomainownership.go b/resource-manager/web/2023-12-01/appservicecertificateorders/method_verifydomainownership.go new file mode 100644 index 00000000000..413d5008994 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/method_verifydomainownership.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +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 VerifyDomainOwnershipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// VerifyDomainOwnership ... +func (c AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (result VerifyDomainOwnershipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verifyDomainOwnership", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificate.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificate.go new file mode 100644 index 00000000000..5572932e257 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificate.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificate struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + ProvisioningState *KeyVaultSecretStatus `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go new file mode 100644 index 00000000000..3f171abb6db --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorder.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrder struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go new file mode 100644 index 00000000000..f0b6b7d477d --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go new file mode 100644 index 00000000000..4657e81b440 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +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 AppServiceCertificateOrderPatchResourceProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go new file mode 100644 index 00000000000..9b30d4ae973 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateorderproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +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 AppServiceCertificateOrderProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go new file mode 100644 index 00000000000..8f8d91b6c87 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificatepatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go new file mode 100644 index 00000000000..7cd601e38f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_appservicecertificateresource.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificatedetails.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificatedetails.go new file mode 100644 index 00000000000..6905351a7c5 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificatedetails.go @@ -0,0 +1,46 @@ +package appservicecertificateorders + +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 CertificateDetails struct { + Issuer *string `json:"issuer,omitempty"` + NotAfter *string `json:"notAfter,omitempty"` + NotBefore *string `json:"notBefore,omitempty"` + RawData *string `json:"rawData,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignatureAlgorithm *string `json:"signatureAlgorithm,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Version *int64 `json:"version,omitempty"` +} + +func (o *CertificateDetails) GetNotAfterAsTime() (*time.Time, error) { + if o.NotAfter == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotAfter, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotAfterAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotAfter = &formatted +} + +func (o *CertificateDetails) GetNotBeforeAsTime() (*time.Time, error) { + if o.NotBefore == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotBefore, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotBeforeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotBefore = &formatted +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateemail.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateemail.go new file mode 100644 index 00000000000..27ec4e4d6f2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateemail.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +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 CertificateEmail struct { + EmailId *string `json:"emailId,omitempty"` + TimeStamp *string `json:"timeStamp,omitempty"` +} + +func (o *CertificateEmail) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateEmail) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateorderaction.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateorderaction.go new file mode 100644 index 00000000000..5a7f75ca664 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateorderaction.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +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 CertificateOrderAction struct { + ActionType *CertificateOrderActionType `json:"actionType,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` +} + +func (o *CertificateOrderAction) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateOrderAction) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateordercontact.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateordercontact.go new file mode 100644 index 00000000000..65e867d2102 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_certificateordercontact.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderContact struct { + Email *string `json:"email,omitempty"` + NameFirst *string `json:"nameFirst,omitempty"` + NameLast *string `json:"nameLast,omitempty"` + Phone *string `json:"phone,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_nameidentifier.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_nameidentifier.go new file mode 100644 index 00000000000..72477ac557d --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go new file mode 100644 index 00000000000..15d4fec9572 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReissueCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go new file mode 100644 index 00000000000..edcc06283c9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + DelayExistingRevokeInHours *int64 `json:"delayExistingRevokeInHours,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go new file mode 100644 index 00000000000..cacc0bada97 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RenewCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go new file mode 100644 index 00000000000..161c783b54e --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_siteseal.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_siteseal.go new file mode 100644 index 00000000000..64f302c54e8 --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_siteseal.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSeal struct { + Html string `json:"html"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/model_sitesealrequest.go b/resource-manager/web/2023-12-01/appservicecertificateorders/model_sitesealrequest.go new file mode 100644 index 00000000000..ed81319016d --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/model_sitesealrequest.go @@ -0,0 +1,9 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSealRequest struct { + LightTheme *bool `json:"lightTheme,omitempty"` + Locale *string `json:"locale,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/predicates.go b/resource-manager/web/2023-12-01/appservicecertificateorders/predicates.go new file mode 100644 index 00000000000..e7457040d0b --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/predicates.go @@ -0,0 +1,70 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateOrderOperationPredicate) Matches(input AppServiceCertificateOrder) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type AppServiceCertificateResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateResourceOperationPredicate) Matches(input AppServiceCertificateResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2023-12-01/appservicecertificateorders/version.go b/resource-manager/web/2023-12-01/appservicecertificateorders/version.go new file mode 100644 index 00000000000..e17da3ea23a --- /dev/null +++ b/resource-manager/web/2023-12-01/appservicecertificateorders/version.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/appservicecertificateorders/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/README.md b/resource-manager/web/2023-12-01/appserviceenvironments/README.md new file mode 100644 index 00000000000..d55dae3816f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/README.md @@ -0,0 +1,833 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceenvironments` Documentation + +The `appserviceenvironments` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceenvironments" +``` + + +### Client Initialization + +```go +client := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "privateEndpointConnectionValue") + +payload := appserviceenvironments.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ChangeVnet` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +payload := appserviceenvironments.VirtualNetworkProfile{ + // ... +} + + +// alternatively `client.ChangeVnet(ctx, id, payload)` can be used to do batched pagination +items, err := client.ChangeVnetComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +payload := appserviceenvironments.AppServiceEnvironmentResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdateMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +if err := client.CreateOrUpdateMultiRolePoolThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdateWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +if err := client.CreateOrUpdateWorkerPoolThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +if err := client.DeleteThenPoll(ctx, id, appserviceenvironments.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.DeleteAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.DeleteAseCustomDnsSuffixConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "privateEndpointConnectionValue") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +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: `AppServiceEnvironmentsClient.GetAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.GetAseCustomDnsSuffixConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetAseV3NetworkingConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.GetAseV3NetworkingConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetDiagnosticsItem` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "diagnosticValue") + +read, err := client.GetDiagnosticsItem(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetInboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.GetInboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.GetInboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.GetMultiRolePool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.GetOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.GetOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "privateEndpointConnectionValue") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetVipInfo` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.GetVipInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue") + +read, err := client.GetWorkerPool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `AppServiceEnvironmentsClient.ListAppServicePlans` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListAppServicePlans(ctx, id)` can be used to do batched pagination +items, err := client.ListAppServicePlansComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListCapacities` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListCapacities(ctx, id)` can be used to do batched pagination +items, err := client.ListCapacitiesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListDiagnostics` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.ListDiagnostics(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRoleMetricDefinitions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListMultiRoleMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRoleMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePoolInstanceMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "instanceValue") + +// alternatively `client.ListMultiRolePoolInstanceMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePoolSkus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListMultiRolePoolSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePools` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListMultiRolePools(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRoleUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListMultiRoleUsages(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRoleUsagesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListOperations` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.ListOperations(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListUsages(ctx, id, appserviceenvironments.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, appserviceenvironments.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListWebApps(ctx, id, appserviceenvironments.DefaultListWebAppsOperationOptions())` can be used to do batched pagination +items, err := client.ListWebAppsComplete(ctx, id, appserviceenvironments.DefaultListWebAppsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebWorkerMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue") + +// alternatively `client.ListWebWorkerMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListWebWorkerMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebWorkerUsages` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue") + +// alternatively `client.ListWebWorkerUsages(ctx, id)` can be used to do batched pagination +items, err := client.ListWebWorkerUsagesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPoolInstanceMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue", "instanceValue") + +// alternatively `client.ListWorkerPoolInstanceMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolInstanceMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPoolSkus` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue") + +// alternatively `client.ListWorkerPoolSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPools` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListWorkerPools(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Reboot` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.Reboot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Resume` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.Resume(ctx, id)` can be used to do batched pagination +items, err := client.ResumeComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Suspend` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.Suspend(ctx, id)` can be used to do batched pagination +items, err := client.SuspendComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.TestUpgradeAvailableNotification` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.TestUpgradeAvailableNotification(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +payload := appserviceenvironments.AppServiceEnvironmentPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +payload := appserviceenvironments.CustomDnsSuffixConfiguration{ + // ... +} + + +read, err := client.UpdateAseCustomDnsSuffixConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateAseNetworkingConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +payload := appserviceenvironments.AseV3NetworkingConfiguration{ + // ... +} + + +read, err := client.UpdateAseNetworkingConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +read, err := client.UpdateMultiRolePool(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +read, err := client.UpdateWorkerPool(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Upgrade` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +if err := client.UpgradeThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/client.go b/resource-manager/web/2023-12-01/appserviceenvironments/client.go new file mode 100644 index 00000000000..b9c0ff155f6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/client.go @@ -0,0 +1,26 @@ +package appserviceenvironments + +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 AppServiceEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceEnvironmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "appserviceenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceEnvironmentsClient: %+v", err) + } + + return &AppServiceEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/constants.go b/resource-manager/web/2023-12-01/appserviceenvironments/constants.go new file mode 100644 index 00000000000..23055b71ef7 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/constants.go @@ -0,0 +1,1621 @@ +package appserviceenvironments + +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 AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ComputeModeOptions string + +const ( + ComputeModeOptionsDedicated ComputeModeOptions = "Dedicated" + ComputeModeOptionsDynamic ComputeModeOptions = "Dynamic" + ComputeModeOptionsShared ComputeModeOptions = "Shared" +) + +func PossibleValuesForComputeModeOptions() []string { + return []string{ + string(ComputeModeOptionsDedicated), + string(ComputeModeOptionsDynamic), + string(ComputeModeOptionsShared), + } +} + +func (s *ComputeModeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeModeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeModeOptions(input string) (*ComputeModeOptions, error) { + vals := map[string]ComputeModeOptions{ + "dedicated": ComputeModeOptionsDedicated, + "dynamic": ComputeModeOptionsDynamic, + "shared": ComputeModeOptionsShared, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeModeOptions(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type CustomDnsSuffixProvisioningState string + +const ( + CustomDnsSuffixProvisioningStateDegraded CustomDnsSuffixProvisioningState = "Degraded" + CustomDnsSuffixProvisioningStateFailed CustomDnsSuffixProvisioningState = "Failed" + CustomDnsSuffixProvisioningStateInProgress CustomDnsSuffixProvisioningState = "InProgress" + CustomDnsSuffixProvisioningStateSucceeded CustomDnsSuffixProvisioningState = "Succeeded" +) + +func PossibleValuesForCustomDnsSuffixProvisioningState() []string { + return []string{ + string(CustomDnsSuffixProvisioningStateDegraded), + string(CustomDnsSuffixProvisioningStateFailed), + string(CustomDnsSuffixProvisioningStateInProgress), + string(CustomDnsSuffixProvisioningStateSucceeded), + } +} + +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { + vals := map[string]CustomDnsSuffixProvisioningState{ + "degraded": CustomDnsSuffixProvisioningStateDegraded, + "failed": CustomDnsSuffixProvisioningStateFailed, + "inprogress": CustomDnsSuffixProvisioningStateInProgress, + "succeeded": CustomDnsSuffixProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDnsSuffixProvisioningState(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type HostingEnvironmentStatus string + +const ( + HostingEnvironmentStatusDeleting HostingEnvironmentStatus = "Deleting" + HostingEnvironmentStatusPreparing HostingEnvironmentStatus = "Preparing" + HostingEnvironmentStatusReady HostingEnvironmentStatus = "Ready" + HostingEnvironmentStatusScaling HostingEnvironmentStatus = "Scaling" +) + +func PossibleValuesForHostingEnvironmentStatus() []string { + return []string{ + string(HostingEnvironmentStatusDeleting), + string(HostingEnvironmentStatusPreparing), + string(HostingEnvironmentStatusReady), + string(HostingEnvironmentStatusScaling), + } +} + +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { + vals := map[string]HostingEnvironmentStatus{ + "deleting": HostingEnvironmentStatusDeleting, + "preparing": HostingEnvironmentStatusPreparing, + "ready": HostingEnvironmentStatusReady, + "scaling": HostingEnvironmentStatusScaling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingEnvironmentStatus(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type LoadBalancingMode string + +const ( + LoadBalancingModeNone LoadBalancingMode = "None" + LoadBalancingModePublishing LoadBalancingMode = "Publishing" + LoadBalancingModeWeb LoadBalancingMode = "Web" + LoadBalancingModeWebPublishing LoadBalancingMode = "Web, Publishing" +) + +func PossibleValuesForLoadBalancingMode() []string { + return []string{ + string(LoadBalancingModeNone), + string(LoadBalancingModePublishing), + string(LoadBalancingModeWeb), + string(LoadBalancingModeWebPublishing), + } +} + +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { + vals := map[string]LoadBalancingMode{ + "none": LoadBalancingModeNone, + "publishing": LoadBalancingModePublishing, + "web": LoadBalancingModeWeb, + "web, publishing": LoadBalancingModeWebPublishing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancingMode(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreated OperationStatus = "Created" + OperationStatusFailed OperationStatus = "Failed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusSucceeded OperationStatus = "Succeeded" + OperationStatusTimedOut OperationStatus = "TimedOut" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreated), + string(OperationStatusFailed), + string(OperationStatusInProgress), + string(OperationStatusSucceeded), + string(OperationStatusTimedOut), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "created": OperationStatusCreated, + "failed": OperationStatusFailed, + "inprogress": OperationStatusInProgress, + "succeeded": OperationStatusSucceeded, + "timedout": OperationStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type StatusOptions string + +const ( + StatusOptionsCreating StatusOptions = "Creating" + StatusOptionsPending StatusOptions = "Pending" + StatusOptionsReady StatusOptions = "Ready" +) + +func PossibleValuesForStatusOptions() []string { + return []string{ + string(StatusOptionsCreating), + string(StatusOptionsPending), + string(StatusOptionsReady), + } +} + +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusOptions(input string) (*StatusOptions, error) { + vals := map[string]StatusOptions{ + "creating": StatusOptionsCreating, + "pending": StatusOptionsPending, + "ready": StatusOptionsReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusOptions(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeBlobContainer StorageType = "blobContainer" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeBlobContainer), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "blobcontainer": StorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type UpgradeAvailability string + +const ( + UpgradeAvailabilityNone UpgradeAvailability = "None" + UpgradeAvailabilityReady UpgradeAvailability = "Ready" +) + +func PossibleValuesForUpgradeAvailability() []string { + return []string{ + string(UpgradeAvailabilityNone), + string(UpgradeAvailabilityReady), + } +} + +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { + vals := map[string]UpgradeAvailability{ + "none": UpgradeAvailabilityNone, + "ready": UpgradeAvailabilityReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeAvailability(input) + return &out, nil +} + +type UpgradePreference string + +const ( + UpgradePreferenceEarly UpgradePreference = "Early" + UpgradePreferenceLate UpgradePreference = "Late" + UpgradePreferenceManual UpgradePreference = "Manual" + UpgradePreferenceNone UpgradePreference = "None" +) + +func PossibleValuesForUpgradePreference() []string { + return []string{ + string(UpgradePreferenceEarly), + string(UpgradePreferenceLate), + string(UpgradePreferenceManual), + string(UpgradePreferenceNone), + } +} + +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradePreference(input string) (*UpgradePreference, error) { + vals := map[string]UpgradePreference{ + "early": UpgradePreferenceEarly, + "late": UpgradePreferenceLate, + "manual": UpgradePreferenceManual, + "none": UpgradePreferenceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradePreference(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} + +type WorkerSizeOptions string + +const ( + WorkerSizeOptionsDOne WorkerSizeOptions = "D1" + WorkerSizeOptionsDThree WorkerSizeOptions = "D3" + WorkerSizeOptionsDTwo WorkerSizeOptions = "D2" + WorkerSizeOptionsDefault WorkerSizeOptions = "Default" + WorkerSizeOptionsLarge WorkerSizeOptions = "Large" + WorkerSizeOptionsLargeVThree WorkerSizeOptions = "LargeV3" + WorkerSizeOptionsMedium WorkerSizeOptions = "Medium" + WorkerSizeOptionsMediumVThree WorkerSizeOptions = "MediumV3" + WorkerSizeOptionsNestedSmall WorkerSizeOptions = "NestedSmall" + WorkerSizeOptionsNestedSmallLinux WorkerSizeOptions = "NestedSmallLinux" + WorkerSizeOptionsSmall WorkerSizeOptions = "Small" + WorkerSizeOptionsSmallVThree WorkerSizeOptions = "SmallV3" +) + +func PossibleValuesForWorkerSizeOptions() []string { + return []string{ + string(WorkerSizeOptionsDOne), + string(WorkerSizeOptionsDThree), + string(WorkerSizeOptionsDTwo), + string(WorkerSizeOptionsDefault), + string(WorkerSizeOptionsLarge), + string(WorkerSizeOptionsLargeVThree), + string(WorkerSizeOptionsMedium), + string(WorkerSizeOptionsMediumVThree), + string(WorkerSizeOptionsNestedSmall), + string(WorkerSizeOptionsNestedSmallLinux), + string(WorkerSizeOptionsSmall), + string(WorkerSizeOptionsSmallVThree), + } +} + +func (s *WorkerSizeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkerSizeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkerSizeOptions(input string) (*WorkerSizeOptions, error) { + vals := map[string]WorkerSizeOptions{ + "d1": WorkerSizeOptionsDOne, + "d3": WorkerSizeOptionsDThree, + "d2": WorkerSizeOptionsDTwo, + "default": WorkerSizeOptionsDefault, + "large": WorkerSizeOptionsLarge, + "largev3": WorkerSizeOptionsLargeVThree, + "medium": WorkerSizeOptionsMedium, + "mediumv3": WorkerSizeOptionsMediumVThree, + "nestedsmall": WorkerSizeOptionsNestedSmall, + "nestedsmalllinux": WorkerSizeOptionsNestedSmallLinux, + "small": WorkerSizeOptionsSmall, + "smallv3": WorkerSizeOptionsSmallVThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkerSizeOptions(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance.go new file mode 100644 index 00000000000..5636848009c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance.go @@ -0,0 +1,141 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DefaultInstanceId{}) +} + +var _ resourceids.ResourceId = &DefaultInstanceId{} + +// DefaultInstanceId is a struct representing the Resource ID for a Default Instance +type DefaultInstanceId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + InstanceName string +} + +// NewDefaultInstanceID returns a new DefaultInstanceId struct +func NewDefaultInstanceID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, instanceName string) DefaultInstanceId { + return DefaultInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + InstanceName: instanceName, + } +} + +// ParseDefaultInstanceID parses 'input' into a DefaultInstanceId +func ParseDefaultInstanceID(input string) (*DefaultInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDefaultInstanceIDInsensitively parses 'input' case-insensitively into a DefaultInstanceId +// note: this method should only be used for API response data and not user input +func ParseDefaultInstanceIDInsensitively(input string) (*DefaultInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DefaultInstanceId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.InstanceName, ok = input.Parsed["instanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceName", input) + } + + return nil +} + +// ValidateDefaultInstanceID checks that 'input' can be parsed as a Default Instance ID +func ValidateDefaultInstanceID(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 := ParseDefaultInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Default Instance ID +func (id DefaultInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/multiRolePools/default/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.InstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Default Instance ID +func (id DefaultInstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentValue"), + resourceids.StaticSegment("staticMultiRolePools", "multiRolePools", "multiRolePools"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceName", "instanceValue"), + } +} + +// String returns a human-readable description of this Default Instance ID +func (id DefaultInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Instance Name: %q", id.InstanceName), + } + return fmt.Sprintf("Default Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance_test.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance_test.go new file mode 100644 index 00000000000..9aa1a334346 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_defaultinstance_test.go @@ -0,0 +1,357 @@ +package appserviceenvironments + +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 = &DefaultInstanceId{} + +func TestNewDefaultInstanceID(t *testing.T) { + id := NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "instanceValue") + + 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.HostingEnvironmentName != "hostingEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentValue") + } + + if id.InstanceName != "instanceValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceName'", id.InstanceName, "instanceValue") + } +} + +func TestFormatDefaultInstanceID(t *testing.T) { + actual := NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "instanceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default/instances/instanceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDefaultInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default/instances/instanceValue", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + InstanceName: "instanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default/instances/instanceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestParseDefaultInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/mUlTiRoLePoOlS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/mUlTiRoLePoOlS/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default/instances/instanceValue", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + InstanceName: "instanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/multiRolePools/default/instances/instanceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs/iNsTaNcEvAlUe", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTvAlUe", + InstanceName: "iNsTaNcEvAlUe", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs/iNsTaNcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestSegmentsForDefaultInstanceId(t *testing.T) { + segments := DefaultInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DefaultInstanceId 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/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go new file mode 100644 index 00000000000..feeb735318a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentDiagnosticId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentDiagnosticId{} + +// HostingEnvironmentDiagnosticId is a struct representing the Resource ID for a Hosting Environment Diagnostic +type HostingEnvironmentDiagnosticId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + DiagnosticName string +} + +// NewHostingEnvironmentDiagnosticID returns a new HostingEnvironmentDiagnosticId struct +func NewHostingEnvironmentDiagnosticID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, diagnosticName string) HostingEnvironmentDiagnosticId { + return HostingEnvironmentDiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + DiagnosticName: diagnosticName, + } +} + +// ParseHostingEnvironmentDiagnosticID parses 'input' into a HostingEnvironmentDiagnosticId +func ParseHostingEnvironmentDiagnosticID(input string) (*HostingEnvironmentDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDiagnosticId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentDiagnosticIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentDiagnosticId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentDiagnosticIDInsensitively(input string) (*HostingEnvironmentDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDiagnosticId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentDiagnosticId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateHostingEnvironmentDiagnosticID checks that 'input' can be parsed as a Hosting Environment Diagnostic ID +func ValidateHostingEnvironmentDiagnosticID(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 := ParseHostingEnvironmentDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentValue"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticValue"), + } +} + +// String returns a human-readable description of this Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Hosting Environment Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go new file mode 100644 index 00000000000..173fefc59d0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +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 = &HostingEnvironmentDiagnosticId{} + +func TestNewHostingEnvironmentDiagnosticID(t *testing.T) { + id := NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "diagnosticValue") + + 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.HostingEnvironmentName != "hostingEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentValue") + } + + if id.DiagnosticName != "diagnosticValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticValue") + } +} + +func TestFormatHostingEnvironmentDiagnosticID(t *testing.T) { + actual := NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "diagnosticValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/diagnostics/diagnosticValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/diagnostics/diagnosticValue", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + DiagnosticName: "diagnosticValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/diagnostics/diagnosticValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDiagnosticID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseHostingEnvironmentDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/diagnostics/diagnosticValue", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + DiagnosticName: "diagnosticValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/diagnostics/diagnosticValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTvAlUe", + DiagnosticName: "dIaGnOsTiCvAlUe", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDiagnosticIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForHostingEnvironmentDiagnosticId(t *testing.T) { + segments := HostingEnvironmentDiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentDiagnosticId 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/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go new file mode 100644 index 00000000000..bbba42867e3 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentPrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentPrivateEndpointConnectionId{} + +// HostingEnvironmentPrivateEndpointConnectionId is a struct representing the Resource ID for a Hosting Environment Private Endpoint Connection +type HostingEnvironmentPrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + PrivateEndpointConnectionName string +} + +// NewHostingEnvironmentPrivateEndpointConnectionID returns a new HostingEnvironmentPrivateEndpointConnectionId struct +func NewHostingEnvironmentPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, privateEndpointConnectionName string) HostingEnvironmentPrivateEndpointConnectionId { + return HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseHostingEnvironmentPrivateEndpointConnectionID parses 'input' into a HostingEnvironmentPrivateEndpointConnectionId +func ParseHostingEnvironmentPrivateEndpointConnectionID(input string) (*HostingEnvironmentPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentPrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentPrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(input string) (*HostingEnvironmentPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentPrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentPrivateEndpointConnectionId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateHostingEnvironmentPrivateEndpointConnectionID checks that 'input' can be parsed as a Hosting Environment Private Endpoint Connection ID +func ValidateHostingEnvironmentPrivateEndpointConnectionID(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 := ParseHostingEnvironmentPrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Hosting Environment Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go new file mode 100644 index 00000000000..6a6b9ee75b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +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 = &HostingEnvironmentPrivateEndpointConnectionId{} + +func TestNewHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + id := NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + actual := NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentPrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTvAlUe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForHostingEnvironmentPrivateEndpointConnectionId(t *testing.T) { + segments := HostingEnvironmentPrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentPrivateEndpointConnectionId 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/web/2023-12-01/appserviceenvironments/id_workerpool.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpool.go new file mode 100644 index 00000000000..463fca27669 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpool.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkerPoolId{}) +} + +var _ resourceids.ResourceId = &WorkerPoolId{} + +// WorkerPoolId is a struct representing the Resource ID for a Worker Pool +type WorkerPoolId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + WorkerPoolName string +} + +// NewWorkerPoolID returns a new WorkerPoolId struct +func NewWorkerPoolID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, workerPoolName string) WorkerPoolId { + return WorkerPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + WorkerPoolName: workerPoolName, + } +} + +// ParseWorkerPoolID parses 'input' into a WorkerPoolId +func ParseWorkerPoolID(input string) (*WorkerPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerPoolIDInsensitively parses 'input' case-insensitively into a WorkerPoolId +// note: this method should only be used for API response data and not user input +func ParseWorkerPoolIDInsensitively(input string) (*WorkerPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerPoolId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.WorkerPoolName, ok = input.Parsed["workerPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerPoolName", input) + } + + return nil +} + +// ValidateWorkerPoolID checks that 'input' can be parsed as a Worker Pool ID +func ValidateWorkerPoolID(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 := ParseWorkerPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker Pool ID +func (id WorkerPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/workerPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.WorkerPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker Pool ID +func (id WorkerPoolId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentValue"), + resourceids.StaticSegment("staticWorkerPools", "workerPools", "workerPools"), + resourceids.UserSpecifiedSegment("workerPoolName", "workerPoolValue"), + } +} + +// String returns a human-readable description of this Worker Pool ID +func (id WorkerPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Worker Pool Name: %q", id.WorkerPoolName), + } + return fmt.Sprintf("Worker Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpool_test.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpool_test.go new file mode 100644 index 00000000000..99177cb7aa2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpool_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +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 = &WorkerPoolId{} + +func TestNewWorkerPoolID(t *testing.T) { + id := NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue") + + 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.HostingEnvironmentName != "hostingEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentValue") + } + + if id.WorkerPoolName != "workerPoolValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerPoolName'", id.WorkerPoolName, "workerPoolValue") + } +} + +func TestFormatWorkerPoolID(t *testing.T) { + actual := NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + WorkerPoolName: "workerPoolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + } +} + +func TestParseWorkerPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + WorkerPoolName: "workerPoolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs/wOrKeRpOoLvAlUe", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTvAlUe", + WorkerPoolName: "wOrKeRpOoLvAlUe", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs/wOrKeRpOoLvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + } +} + +func TestSegmentsForWorkerPoolId(t *testing.T) { + segments := WorkerPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerPoolId 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/web/2023-12-01/appserviceenvironments/id_workerpoolinstance.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpoolinstance.go new file mode 100644 index 00000000000..0bf747795a2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpoolinstance.go @@ -0,0 +1,148 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkerPoolInstanceId{}) +} + +var _ resourceids.ResourceId = &WorkerPoolInstanceId{} + +// WorkerPoolInstanceId is a struct representing the Resource ID for a Worker Pool Instance +type WorkerPoolInstanceId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + WorkerPoolName string + InstanceName string +} + +// NewWorkerPoolInstanceID returns a new WorkerPoolInstanceId struct +func NewWorkerPoolInstanceID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, workerPoolName string, instanceName string) WorkerPoolInstanceId { + return WorkerPoolInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + WorkerPoolName: workerPoolName, + InstanceName: instanceName, + } +} + +// ParseWorkerPoolInstanceID parses 'input' into a WorkerPoolInstanceId +func ParseWorkerPoolInstanceID(input string) (*WorkerPoolInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerPoolInstanceIDInsensitively parses 'input' case-insensitively into a WorkerPoolInstanceId +// note: this method should only be used for API response data and not user input +func ParseWorkerPoolInstanceIDInsensitively(input string) (*WorkerPoolInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerPoolInstanceId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.WorkerPoolName, ok = input.Parsed["workerPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerPoolName", input) + } + + if id.InstanceName, ok = input.Parsed["instanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceName", input) + } + + return nil +} + +// ValidateWorkerPoolInstanceID checks that 'input' can be parsed as a Worker Pool Instance ID +func ValidateWorkerPoolInstanceID(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 := ParseWorkerPoolInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker Pool Instance ID +func (id WorkerPoolInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/workerPools/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.WorkerPoolName, id.InstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker Pool Instance ID +func (id WorkerPoolInstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentValue"), + resourceids.StaticSegment("staticWorkerPools", "workerPools", "workerPools"), + resourceids.UserSpecifiedSegment("workerPoolName", "workerPoolValue"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceName", "instanceValue"), + } +} + +// String returns a human-readable description of this Worker Pool Instance ID +func (id WorkerPoolInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Worker Pool Name: %q", id.WorkerPoolName), + fmt.Sprintf("Instance Name: %q", id.InstanceName), + } + return fmt.Sprintf("Worker Pool Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpoolinstance_test.go b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpoolinstance_test.go new file mode 100644 index 00000000000..1478932338f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/id_workerpoolinstance_test.go @@ -0,0 +1,372 @@ +package appserviceenvironments + +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 = &WorkerPoolInstanceId{} + +func TestNewWorkerPoolInstanceID(t *testing.T) { + id := NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue", "instanceValue") + + 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.HostingEnvironmentName != "hostingEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentValue") + } + + if id.WorkerPoolName != "workerPoolValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerPoolName'", id.WorkerPoolName, "workerPoolValue") + } + + if id.InstanceName != "instanceValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceName'", id.InstanceName, "instanceValue") + } +} + +func TestFormatWorkerPoolInstanceID(t *testing.T) { + actual := NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "workerPoolValue", "instanceValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/instances/instanceValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerPoolInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/instances/instanceValue", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + WorkerPoolName: "workerPoolValue", + InstanceName: "instanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/instances/instanceValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestParseWorkerPoolInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs/wOrKeRpOoLvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs/wOrKeRpOoLvAlUe/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/instances/instanceValue", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + WorkerPoolName: "workerPoolValue", + InstanceName: "instanceValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/workerPools/workerPoolValue/instances/instanceValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs/wOrKeRpOoLvAlUe/iNsTaNcEs/iNsTaNcEvAlUe", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTvAlUe", + WorkerPoolName: "wOrKeRpOoLvAlUe", + InstanceName: "iNsTaNcEvAlUe", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/wOrKeRpOoLs/wOrKeRpOoLvAlUe/iNsTaNcEs/iNsTaNcEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestSegmentsForWorkerPoolInstanceId(t *testing.T) { + segments := WorkerPoolInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerPoolInstanceId 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/web/2023-12-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..5bd10a90134 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package appserviceenvironments + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_changevnet.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_changevnet.go new file mode 100644 index 00000000000..3c0aaf531fd --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_changevnet.go @@ -0,0 +1,81 @@ +package appserviceenvironments + +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/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 ChangeVnetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ChangeVnetCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +// ChangeVnet ... +func (c AppServiceEnvironmentsClient) ChangeVnet(ctx context.Context, id commonids.AppServiceEnvironmentId, input VirtualNetworkProfile) (result ChangeVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/changeVirtualNetwork", 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 +} + +// ChangeVnetThenPoll performs ChangeVnet then polls until it's completed +func (c AppServiceEnvironmentsClient) ChangeVnetThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input VirtualNetworkProfile) error { + result, err := c.ChangeVnet(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ChangeVnet: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ChangeVnet: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdate.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdate.go new file mode 100644 index 00000000000..0e325049b7f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdate.go @@ -0,0 +1,77 @@ +package appserviceenvironments + +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/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// CreateOrUpdate ... +func (c AppServiceEnvironmentsClient) CreateOrUpdate(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdatemultirolepool.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdatemultirolepool.go new file mode 100644 index 00000000000..680b38261e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdatemultirolepool.go @@ -0,0 +1,76 @@ +package appserviceenvironments + +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/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 CreateOrUpdateMultiRolePoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// CreateOrUpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) (result CreateOrUpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/multiRolePools/default", 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 +} + +// CreateOrUpdateMultiRolePoolThenPoll performs CreateOrUpdateMultiRolePool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePoolThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateMultiRolePool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateMultiRolePool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateMultiRolePool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdateworkerpool.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdateworkerpool.go new file mode 100644 index 00000000000..a3cb8c751fd --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_createorupdateworkerpool.go @@ -0,0 +1,75 @@ +package appserviceenvironments + +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 CreateOrUpdateWorkerPoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// CreateOrUpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result CreateOrUpdateWorkerPoolOperationResponse, 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 +} + +// CreateOrUpdateWorkerPoolThenPoll performs CreateOrUpdateWorkerPool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPoolThenPoll(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateWorkerPool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateWorkerPool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateWorkerPool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_delete.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_delete.go new file mode 100644 index 00000000000..67e550c1929 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_delete.go @@ -0,0 +1,99 @@ +package appserviceenvironments + +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/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 { + ForceDelete *bool +} + +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.ForceDelete != nil { + out.Append("forceDelete", fmt.Sprintf("%v", *o.ForceDelete)) + } + return &out +} + +// Delete ... +func (c AppServiceEnvironmentsClient) Delete(ctx context.Context, id commonids.AppServiceEnvironmentId, 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 AppServiceEnvironmentsClient) DeleteThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, 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/web/2023-12-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..911c456e29b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go @@ -0,0 +1,57 @@ +package appserviceenvironments + +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 DeleteAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeleteAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) DeleteAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result DeleteAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_deleteprivateendpointconnection.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f15f2fafc23 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package appserviceenvironments + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_get.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_get.go new file mode 100644 index 00000000000..2e5e2bb0d14 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_get.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// Get ... +func (c AppServiceEnvironmentsClient) Get(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceEnvironmentResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..9be53936c71 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 GetAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// GetAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomDnsSuffixConfiguration + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getasev3networkingconfiguration.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getasev3networkingconfiguration.go new file mode 100644 index 00000000000..1ca5a50286f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getasev3networkingconfiguration.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 GetAseV3NetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// GetAseV3NetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseV3NetworkingConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetAseV3NetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/networking", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AseV3NetworkingConfiguration + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getdiagnosticsitem.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getdiagnosticsitem.go new file mode 100644 index 00000000000..b6d0e47a783 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getdiagnosticsitem.go @@ -0,0 +1,54 @@ +package appserviceenvironments + +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 GetDiagnosticsItemOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostingEnvironmentDiagnostics +} + +// GetDiagnosticsItem ... +func (c AppServiceEnvironmentsClient) GetDiagnosticsItem(ctx context.Context, id HostingEnvironmentDiagnosticId) (result GetDiagnosticsItemOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostingEnvironmentDiagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..4493ea5c9d0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 GetInboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]InboundEnvironmentEndpoint +} + +type GetInboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []InboundEnvironmentEndpoint +} + +// GetInboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/inboundNetworkDependenciesEndpoints", 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 *[]InboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetInboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetInboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, InboundEnvironmentEndpointOperationPredicate{}) +} + +// GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate InboundEnvironmentEndpointOperationPredicate) (result GetInboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]InboundEnvironmentEndpoint, 0) + + resp, err := c.GetInboundNetworkDependenciesEndpoints(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 = GetInboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getmultirolepool.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getmultirolepool.go new file mode 100644 index 00000000000..8823968375d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getmultirolepool.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 GetMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetMultiRolePool ... +func (c AppServiceEnvironmentsClient) GetMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/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 + } + + var model WorkerPoolResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..094f19e69eb --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 GetOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type GetOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +// GetOutboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", 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 *[]OutboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate OutboundEnvironmentEndpointOperationPredicate) (result GetOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.GetOutboundNetworkDependenciesEndpoints(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 = GetOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnection.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..6bf182be11e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnection.go @@ -0,0 +1,54 @@ +package appserviceenvironments + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnectionlist.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..c4b41eb7dac --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivateendpointconnectionlist.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionList ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionList(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(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 = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivatelinkresources.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivatelinkresources.go new file mode 100644 index 00000000000..e0c2f0c4365 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getprivatelinkresources.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c AppServiceEnvironmentsClient) GetPrivateLinkResources(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getvipinfo.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getvipinfo.go new file mode 100644 index 00000000000..a0f52038b9c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getvipinfo.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 GetVipInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AddressResponse +} + +// GetVipInfo ... +func (c AppServiceEnvironmentsClient) GetVipInfo(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetVipInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capacities/virtualip", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AddressResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_getworkerpool.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_getworkerpool.go new file mode 100644 index 00000000000..bd617d301a8 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_getworkerpool.go @@ -0,0 +1,54 @@ +package appserviceenvironments + +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 GetWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetWorkerPool ... +func (c AppServiceEnvironmentsClient) GetWorkerPool(ctx context.Context, id WorkerPoolId) (result GetWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkerPoolResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_list.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_list.go new file mode 100644 index 00000000000..e462dbfa38e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_list.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 *[]AppServiceEnvironmentResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceEnvironmentResource +} + +// List ... +func (c AppServiceEnvironmentsClient) List(ctx context.Context, id commonids.SubscriptionId) (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.Web/hostingEnvironments", 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 *[]AppServiceEnvironmentResource `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 AppServiceEnvironmentsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 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/web/2023-12-01/appserviceenvironments/method_listappserviceplans.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listappserviceplans.go new file mode 100644 index 00000000000..cf076211d49 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listappserviceplans.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 ListAppServicePlansOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListAppServicePlansCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +// ListAppServicePlans ... +func (c AppServiceEnvironmentsClient) ListAppServicePlans(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListAppServicePlansOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/serverFarms", 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 *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServicePlansComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListAppServicePlansComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListAppServicePlansCompleteResult, error) { + return c.ListAppServicePlansCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListAppServicePlansCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListAppServicePlansCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate AppServicePlanOperationPredicate) (result ListAppServicePlansCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListAppServicePlans(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 = ListAppServicePlansCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..9c862bb5c82 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceEnvironmentResource +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceEnvironmentResource +} + +// ListByResourceGroup ... +func (c AppServiceEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", 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 *[]AppServiceEnvironmentResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listcapacities.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listcapacities.go new file mode 100644 index 00000000000..4057c576b7d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listcapacities.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 ListCapacitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StampCapacity +} + +type ListCapacitiesCompleteResult struct { + LatestHttpResponse *http.Response + Items []StampCapacity +} + +// ListCapacities ... +func (c AppServiceEnvironmentsClient) ListCapacities(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListCapacitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capacities/compute", 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 *[]StampCapacity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCapacitiesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListCapacitiesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListCapacitiesCompleteResult, error) { + return c.ListCapacitiesCompleteMatchingPredicate(ctx, id, StampCapacityOperationPredicate{}) +} + +// ListCapacitiesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCapacitiesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate StampCapacityOperationPredicate) (result ListCapacitiesCompleteResult, err error) { + items := make([]StampCapacity, 0) + + resp, err := c.ListCapacities(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 = ListCapacitiesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listdiagnostics.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listdiagnostics.go new file mode 100644 index 00000000000..050adc5112e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listdiagnostics.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 ListDiagnosticsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostingEnvironmentDiagnostics +} + +// ListDiagnostics ... +func (c AppServiceEnvironmentsClient) ListDiagnostics(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListDiagnosticsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []HostingEnvironmentDiagnostics + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolemetricdefinitions.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolemetricdefinitions.go new file mode 100644 index 00000000000..20000132a61 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolemetricdefinitions.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 ListMultiRoleMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRoleMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +// ListMultiRoleMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitions(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRoleMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRoleMetricDefinitionsCompleteResult, error) { + return c.ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRoleMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRoleMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRoleMetricDefinitions(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 = ListMultiRoleMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..123869d1d9d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go @@ -0,0 +1,91 @@ +package appserviceenvironments + +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 ListMultiRolePoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRolePoolInstanceMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +// ListMultiRolePoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitions(ctx context.Context, id DefaultInstanceId) (result ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx context.Context, id DefaultInstanceId) (ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id DefaultInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRolePoolInstanceMetricDefinitions(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 = ListMultiRolePoolInstanceMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepools.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepools.go new file mode 100644 index 00000000000..7bf7efb7db1 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepools.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 ListMultiRolePoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListMultiRolePoolsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkerPoolResource +} + +// ListMultiRolePools ... +func (c AppServiceEnvironmentsClient) ListMultiRolePools(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRolePoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools", 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 *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRolePoolsCompleteResult, error) { + return c.ListMultiRolePoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListMultiRolePoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListMultiRolePoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListMultiRolePools(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 = ListMultiRolePoolsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolskus.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolskus.go new file mode 100644 index 00000000000..90d77b111e1 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultirolepoolskus.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 ListMultiRolePoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListMultiRolePoolSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SkuInfo +} + +// ListMultiRolePoolSkus ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkus(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRolePoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default/skus", 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 *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRolePoolSkusCompleteResult, error) { + return c.ListMultiRolePoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListMultiRolePoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate SkuInfoOperationPredicate) (result ListMultiRolePoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListMultiRolePoolSkus(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 = ListMultiRolePoolSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultiroleusages.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultiroleusages.go new file mode 100644 index 00000000000..42efb56a5a6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listmultiroleusages.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 ListMultiRoleUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListMultiRoleUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +// ListMultiRoleUsages ... +func (c AppServiceEnvironmentsClient) ListMultiRoleUsages(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRoleUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default/usages", 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 *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRoleUsagesCompleteResult, error) { + return c.ListMultiRoleUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListMultiRoleUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate UsageOperationPredicate) (result ListMultiRoleUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListMultiRoleUsages(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 = ListMultiRoleUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listoperations.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listoperations.go new file mode 100644 index 00000000000..49fef987d75 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listoperations.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +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 ListOperationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Operation +} + +// ListOperations ... +func (c AppServiceEnvironmentsClient) ListOperations(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListOperationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []Operation + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listusages.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listusages.go new file mode 100644 index 00000000000..125af5668b0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listusages.go @@ -0,0 +1,120 @@ +package appserviceenvironments + +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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsages ... +func (c AppServiceEnvironmentsClient) ListUsages(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListUsagesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(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 = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebapps.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebapps.go new file mode 100644 index 00000000000..c87610a4e8f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebapps.go @@ -0,0 +1,120 @@ +package appserviceenvironments + +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 ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListWebAppsOperationOptions struct { + PropertiesToInclude *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.PropertiesToInclude != nil { + out.Append("propertiesToInclude", fmt.Sprintf("%v", *o.PropertiesToInclude)) + } + return &out +} + +// ListWebApps ... +func (c AppServiceEnvironmentsClient) ListWebApps(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sites", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebAppsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(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 = ListWebAppsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkermetricdefinitions.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkermetricdefinitions.go new file mode 100644 index 00000000000..15b7dfa730c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkermetricdefinitions.go @@ -0,0 +1,91 @@ +package appserviceenvironments + +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 ListWebWorkerMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWebWorkerMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +// ListWebWorkerMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitions(ctx context.Context, id WorkerPoolId) (result ListWebWorkerMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerMetricDefinitionsCompleteResult, error) { + return c.ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWebWorkerMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWebWorkerMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWebWorkerMetricDefinitions(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 = ListWebWorkerMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkerusages.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkerusages.go new file mode 100644 index 00000000000..56294af7040 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listwebworkerusages.go @@ -0,0 +1,91 @@ +package appserviceenvironments + +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 ListWebWorkerUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListWebWorkerUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +// ListWebWorkerUsages ... +func (c AppServiceEnvironmentsClient) ListWebWorkerUsages(ctx context.Context, id WorkerPoolId) (result ListWebWorkerUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerUsagesCompleteResult, error) { + return c.ListWebWorkerUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListWebWorkerUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate UsageOperationPredicate) (result ListWebWorkerUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListWebWorkerUsages(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 = ListWebWorkerUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..a6499bafdc9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go @@ -0,0 +1,91 @@ +package appserviceenvironments + +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 ListWorkerPoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWorkerPoolInstanceMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +// ListWorkerPoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitions(ctx context.Context, id WorkerPoolInstanceId) (result ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/metricdefinitions", 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 *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsComplete(ctx context.Context, id WorkerPoolInstanceId) (ListWorkerPoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWorkerPoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWorkerPoolInstanceMetricDefinitions(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 = ListWorkerPoolInstanceMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpools.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpools.go new file mode 100644 index 00000000000..4af0becc487 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpools.go @@ -0,0 +1,92 @@ +package appserviceenvironments + +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 ListWorkerPoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListWorkerPoolsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkerPoolResource +} + +// ListWorkerPools ... +func (c AppServiceEnvironmentsClient) ListWorkerPools(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListWorkerPoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/workerPools", 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 *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListWorkerPoolsCompleteResult, error) { + return c.ListWorkerPoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListWorkerPoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListWorkerPoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListWorkerPools(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 = ListWorkerPoolsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolskus.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolskus.go new file mode 100644 index 00000000000..294542fd097 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_listworkerpoolskus.go @@ -0,0 +1,91 @@ +package appserviceenvironments + +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 ListWorkerPoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListWorkerPoolSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SkuInfo +} + +// ListWorkerPoolSkus ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkus(ctx context.Context, id WorkerPoolId) (result ListWorkerPoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", 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 *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusComplete(ctx context.Context, id WorkerPoolId) (ListWorkerPoolSkusCompleteResult, error) { + return c.ListWorkerPoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListWorkerPoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate SkuInfoOperationPredicate) (result ListWorkerPoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListWorkerPoolSkus(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 = ListWorkerPoolSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_reboot.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_reboot.go new file mode 100644 index 00000000000..da6ac719365 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_reboot.go @@ -0,0 +1,48 @@ +package appserviceenvironments + +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 RebootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reboot ... +func (c AppServiceEnvironmentsClient) Reboot(ctx context.Context, id commonids.AppServiceEnvironmentId) (result RebootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_resume.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_resume.go new file mode 100644 index 00000000000..def906a3f1a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_resume.go @@ -0,0 +1,77 @@ +package appserviceenvironments + +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/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 *[]Site +} + +type ResumeCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +// Resume ... +func (c AppServiceEnvironmentsClient) Resume(ctx context.Context, id commonids.AppServiceEnvironmentId) (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 + } + + 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 AppServiceEnvironmentsClient) ResumeThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Resume(ctx, id) + 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/web/2023-12-01/appserviceenvironments/method_suspend.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_suspend.go new file mode 100644 index 00000000000..5395b21b683 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_suspend.go @@ -0,0 +1,77 @@ +package appserviceenvironments + +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/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 SuspendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type SuspendCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +// Suspend ... +func (c AppServiceEnvironmentsClient) Suspend(ctx context.Context, id commonids.AppServiceEnvironmentId) (result SuspendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/suspend", 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 +} + +// SuspendThenPoll performs Suspend then polls until it's completed +func (c AppServiceEnvironmentsClient) SuspendThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Suspend(ctx, id) + if err != nil { + return fmt.Errorf("performing Suspend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Suspend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_testupgradeavailablenotification.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_testupgradeavailablenotification.go new file mode 100644 index 00000000000..3c1081f9144 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_testupgradeavailablenotification.go @@ -0,0 +1,48 @@ +package appserviceenvironments + +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 TestUpgradeAvailableNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TestUpgradeAvailableNotification ... +func (c AppServiceEnvironmentsClient) TestUpgradeAvailableNotification(ctx context.Context, id commonids.AppServiceEnvironmentId) (result TestUpgradeAvailableNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testUpgradeAvailableNotification", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_update.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_update.go new file mode 100644 index 00000000000..c3afa9e6f0d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_update.go @@ -0,0 +1,61 @@ +package appserviceenvironments + +import ( + "context" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// Update ... +func (c AppServiceEnvironmentsClient) Update(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + 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 + } + + var model AppServiceEnvironmentResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..376d25fe92b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +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 UpdateAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// UpdateAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId, input CustomDnsSuffixConfiguration) (result UpdateAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomDnsSuffixConfiguration + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_updateasenetworkingconfiguration.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_updateasenetworkingconfiguration.go new file mode 100644 index 00000000000..0661a11d23d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_updateasenetworkingconfiguration.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +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 UpdateAseNetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// UpdateAseNetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseNetworkingConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId, input AseV3NetworkingConfiguration) (result UpdateAseNetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/networking", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AseV3NetworkingConfiguration + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_updatemultirolepool.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_updatemultirolepool.go new file mode 100644 index 00000000000..d71d810e1d4 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_updatemultirolepool.go @@ -0,0 +1,61 @@ +package appserviceenvironments + +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 UpdateMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) UpdateMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) (result UpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/multiRolePools/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkerPoolResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_updateworkerpool.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_updateworkerpool.go new file mode 100644 index 00000000000..85733a6f536 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_updateworkerpool.go @@ -0,0 +1,59 @@ +package appserviceenvironments + +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 UpdateWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) UpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result UpdateWorkerPoolOperationResponse, 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 + } + + var model WorkerPoolResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/method_upgrade.go b/resource-manager/web/2023-12-01/appserviceenvironments/method_upgrade.go new file mode 100644 index 00000000000..36584682ac1 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/method_upgrade.go @@ -0,0 +1,70 @@ +package appserviceenvironments + +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/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 UpgradeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Upgrade ... +func (c AppServiceEnvironmentsClient) Upgrade(ctx context.Context, id commonids.AppServiceEnvironmentId) (result UpgradeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgrade", 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 +} + +// UpgradeThenPoll performs Upgrade then polls until it's completed +func (c AppServiceEnvironmentsClient) UpgradeThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Upgrade(ctx, id) + if err != nil { + return fmt.Errorf("performing Upgrade: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Upgrade: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponse.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponse.go new file mode 100644 index 00000000000..5949ada3aeb --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponse.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AddressResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponseproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponseproperties.go new file mode 100644 index 00000000000..22241e69975 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_addressresponseproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressResponseProperties struct { + InternalIPAddress *string `json:"internalIpAddress,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + ServiceIPAddress *string `json:"serviceIpAddress,omitempty"` + VipMappings *[]VirtualIPMapping `json:"vipMappings,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_apidefinitioninfo.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_apidefinitioninfo.go new file mode 100644 index 00000000000..b29b3fb28ec --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_apimanagementconfig.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_apimanagementconfig.go new file mode 100644 index 00000000000..eca6e5d45b9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironment.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironment.go new file mode 100644 index 00000000000..7e868462756 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironment.go @@ -0,0 +1,27 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironment struct { + ClusterSettings *[]NameValuePair `json:"clusterSettings,omitempty"` + CustomDnsSuffixConfiguration *CustomDnsSuffixConfiguration `json:"customDnsSuffixConfiguration,omitempty"` + DedicatedHostCount *int64 `json:"dedicatedHostCount,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + FrontEndScaleFactor *int64 `json:"frontEndScaleFactor,omitempty"` + HasLinuxWorkers *bool `json:"hasLinuxWorkers,omitempty"` + IPsslAddressCount *int64 `json:"ipsslAddressCount,omitempty"` + InternalLoadBalancingMode *LoadBalancingMode `json:"internalLoadBalancingMode,omitempty"` + MaximumNumberOfMachines *int64 `json:"maximumNumberOfMachines,omitempty"` + MultiRoleCount *int64 `json:"multiRoleCount,omitempty"` + MultiSize *string `json:"multiSize,omitempty"` + NetworkingConfiguration *AseV3NetworkingConfiguration `json:"networkingConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *HostingEnvironmentStatus `json:"status,omitempty"` + Suspended *bool `json:"suspended,omitempty"` + UpgradeAvailability *UpgradeAvailability `json:"upgradeAvailability,omitempty"` + UpgradePreference *UpgradePreference `json:"upgradePreference,omitempty"` + UserWhitelistedIPRanges *[]string `json:"userWhitelistedIpRanges,omitempty"` + VirtualNetwork VirtualNetworkProfile `json:"virtualNetwork"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go new file mode 100644 index 00000000000..594e57510dd --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceEnvironment `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentresource.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentresource.go new file mode 100644 index 00000000000..31263ba6394 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceenvironmentresource.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceEnvironment `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplan.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplan.go new file mode 100644 index 00000000000..499328be215 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplan.go @@ -0,0 +1,16 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlan struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanProperties `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplanproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplanproperties.go new file mode 100644 index 00000000000..df541821251 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_appserviceplanproperties.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +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 AppServicePlanProperties struct { + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_armidwrapper.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_armidwrapper.go new file mode 100644 index 00000000000..23291cc1624 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_armidwrapper.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfiguration.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfiguration.go new file mode 100644 index 00000000000..dd9c6b64a48 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfiguration.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseV3NetworkingConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go new file mode 100644 index 00000000000..82c8e80d94e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfigurationProperties struct { + AllowNewPrivateEndpointConnections *bool `json:"allowNewPrivateEndpointConnections,omitempty"` + ExternalInboundIPAddresses *[]string `json:"externalInboundIpAddresses,omitempty"` + FtpEnabled *bool `json:"ftpEnabled,omitempty"` + InboundIPAddressOverride *string `json:"inboundIpAddressOverride,omitempty"` + InternalInboundIPAddresses *[]string `json:"internalInboundIpAddresses,omitempty"` + LinuxOutboundIPAddresses *[]string `json:"linuxOutboundIpAddresses,omitempty"` + RemoteDebugEnabled *bool `json:"remoteDebugEnabled,omitempty"` + WindowsOutboundIPAddresses *[]string `json:"windowsOutboundIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealactions.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealactions.go new file mode 100644 index 00000000000..a53db3433d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealactions.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealcustomaction.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealcustomaction.go new file mode 100644 index 00000000000..b4979e90b7a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealrules.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealrules.go new file mode 100644 index 00000000000..cd835879fe2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealrules.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealtriggers.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealtriggers.go new file mode 100644 index 00000000000..2d6842a3f7d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_azurestorageinfovalue.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..57e32f54dc0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_capability.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_capability.go new file mode 100644 index 00000000000..6b07c220bef --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_capability.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_cloninginfo.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_cloninginfo.go new file mode 100644 index 00000000000..f9505ee3c37 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_cloninginfo.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_connstringinfo.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_connstringinfo.go new file mode 100644 index 00000000000..a4172f89872 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_connstringinfo.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_corssettings.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_corssettings.go new file mode 100644 index 00000000000..24390a28726 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_corssettings.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_csmusagequota.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_csmusagequota.go new file mode 100644 index 00000000000..0ba4a1dd059 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_csmusagequota.go @@ -0,0 +1,30 @@ +package appserviceenvironments + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfiguration.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfiguration.go new file mode 100644 index 00000000000..ed5fdcd1b9a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfiguration.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomDnsSuffixConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go new file mode 100644 index 00000000000..80ac53f7a52 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfigurationProperties struct { + CertificateUrl *string `json:"certificateUrl,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + ProvisioningDetails *string `json:"provisioningDetails,omitempty"` + ProvisioningState *CustomDnsSuffixProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_daprconfig.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_daprconfig.go new file mode 100644 index 00000000000..9268fd62dc0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_daprconfig.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdependency.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdependency.go new file mode 100644 index 00000000000..9840103ce20 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdependency.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdetail.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdetail.go new file mode 100644 index 00000000000..d738ebeb260 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_endpointdetail.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + IPAddress *string `json:"ipAddress,omitempty"` + IsAccessible *bool `json:"isAccessible,omitempty"` + Latency *float64 `json:"latency,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_errorentity.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_errorentity.go new file mode 100644 index 00000000000..8125008a5d2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_errorentity.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_experiments.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_experiments.go new file mode 100644 index 00000000000..9bd9653d59f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_experiments.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_extendedlocation.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_extendedlocation.go new file mode 100644 index 00000000000..b24df8493f9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_extendedlocation.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionappconfig.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionappconfig.go new file mode 100644 index 00000000000..e3733b6a7c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionappconfig.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsalwaysreadyconfig.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..d5a46a9b4c3 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *float64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeployment.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeployment.go new file mode 100644 index 00000000000..4b819404793 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorage.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..365122fd093 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *StorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..deebac5deb3 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsruntime.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsruntime.go new file mode 100644 index 00000000000..b0fc099b28b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsruntime.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrency.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..dfafdfb6f31 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *float64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *float64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..28d4106d6fb --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..e045e941664 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *float64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_handlermapping.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_handlermapping.go new file mode 100644 index 00000000000..add89600372 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_handlermapping.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go new file mode 100644 index 00000000000..1d298e705f6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentDiagnostics struct { + DiagnosticsOutput *string `json:"diagnosticsOutput,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentprofile.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..e67fbad99e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_hostnamesslstate.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_hostnamesslstate.go new file mode 100644 index 00000000000..b60ed2b41ef --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_inboundenvironmentendpoint.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_inboundenvironmentendpoint.go new file mode 100644 index 00000000000..83dea79b75b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_inboundenvironmentendpoint.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundEnvironmentEndpoint struct { + Description *string `json:"description,omitempty"` + Endpoints *[]string `json:"endpoints,omitempty"` + Ports *[]string `json:"ports,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_ipsecurityrestriction.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..cce3b7521d2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_kubeenvironmentprofile.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_kubeenvironmentprofile.go new file mode 100644 index 00000000000..1ad013915fa --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_kubeenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_localizablestring.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_localizablestring.go new file mode 100644 index 00000000000..5974acdfb1a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_localizablestring.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_namevaluepair.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_namevaluepair.go new file mode 100644 index 00000000000..ac9cb553c36 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_namevaluepair.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_operation.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_operation.go new file mode 100644 index 00000000000..e226cf16987 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_operation.go @@ -0,0 +1,57 @@ +package appserviceenvironments + +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 Operation struct { + CreatedTime *string `json:"createdTime,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + GeoMasterOperationId *string `json:"geoMasterOperationId,omitempty"` + Id *string `json:"id,omitempty"` + ModifiedTime *string `json:"modifiedTime,omitempty"` + Name *string `json:"name,omitempty"` + Status *OperationStatus `json:"status,omitempty"` +} + +func (o *Operation) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *Operation) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *Operation) GetModifiedTimeAsTime() (*time.Time, error) { + if o.ModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_outboundenvironmentendpoint.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..04928bef582 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundEnvironmentEndpoint struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkconnectionstate.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..86ca1b14e24 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresource.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresource.go new file mode 100644 index 00000000000..1b58321d272 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..ecd58509b6f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceswrapper.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..40cc8c0e8b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettings.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettings.go new file mode 100644 index 00000000000..addca78ae4d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettings.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettingsproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettingsproperties.go new file mode 100644 index 00000000000..6c80542248a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_rampuprule.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_rampuprule.go new file mode 100644 index 00000000000..ace74b58d88 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_rampuprule.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackUrl *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..314760728b6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..a96786cf386 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_requestsbasedtrigger.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..57351c32612 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_resourceconfig.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourceconfig.go new file mode 100644 index 00000000000..d6f6c721d3c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourceconfig.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricavailability.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricavailability.go new file mode 100644 index 00000000000..2688445beaa --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricavailability.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricAvailability struct { + Retention *string `json:"retention,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinition.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinition.go new file mode 100644 index 00000000000..8645bb913f3 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinition.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricDefinition struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceMetricDefinitionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go new file mode 100644 index 00000000000..d1d6856879a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricDefinitionProperties struct { + MetricAvailabilities *[]ResourceMetricAvailability `json:"metricAvailabilities,omitempty"` + PrimaryAggregationType *string `json:"primaryAggregationType,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_site.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_site.go new file mode 100644 index 00000000000..a09cdcffac4 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_site.go @@ -0,0 +1,20 @@ +package appserviceenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_siteconfig.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteconfig.go new file mode 100644 index 00000000000..df4daa18008 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteconfig.go @@ -0,0 +1,97 @@ +package appserviceenvironments + +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 SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_sitednsconfig.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_sitednsconfig.go new file mode 100644 index 00000000000..4b4479a9c71 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_sitelimits.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_sitelimits.go new file mode 100644 index 00000000000..b3130e580f6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_sitelimits.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_sitemachinekey.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_sitemachinekey.go new file mode 100644 index 00000000000..267ce523b14 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go new file mode 100644 index 00000000000..3d3d567781e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_siteproperties.go @@ -0,0 +1,89 @@ +package appserviceenvironments + +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 SiteProperties struct { + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + VnetBackupRestoreEnabled *bool `json:"vnetBackupRestoreEnabled,omitempty"` + VnetContentShareEnabled *bool `json:"vnetContentShareEnabled,omitempty"` + VnetImagePullEnabled *bool `json:"vnetImagePullEnabled,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_skucapacity.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_skucapacity.go new file mode 100644 index 00000000000..2e04c5df978 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_skucapacity.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_skudescription.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_skudescription.go new file mode 100644 index 00000000000..47f1a308d34 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_skudescription.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_skuinfo.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_skuinfo.go new file mode 100644 index 00000000000..9faba036b8a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_skuinfo.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuInfo struct { + Capacity *SkuCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_slotswapstatus.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_slotswapstatus.go new file mode 100644 index 00000000000..ae1901b782c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package appserviceenvironments + +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 SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_slowrequestsbasedtrigger.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..ef74f6f556b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_stampcapacity.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_stampcapacity.go new file mode 100644 index 00000000000..138ebe09348 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_stampcapacity.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StampCapacity struct { + AvailableCapacity *int64 `json:"availableCapacity,omitempty"` + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + ExcludeFromCapacityAllocation *bool `json:"excludeFromCapacityAllocation,omitempty"` + IsApplicableForAllComputeModes *bool `json:"isApplicableForAllComputeModes,omitempty"` + IsLinux *bool `json:"isLinux,omitempty"` + Name *string `json:"name,omitempty"` + SiteMode *string `json:"siteMode,omitempty"` + TotalCapacity *int64 `json:"totalCapacity,omitempty"` + Unit *string `json:"unit,omitempty"` + WorkerSize *WorkerSizeOptions `json:"workerSize,omitempty"` + WorkerSizeId *int64 `json:"workerSizeId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesbasedtrigger.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..633cfec8a5e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..ccbeced17af --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_usage.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_usage.go new file mode 100644 index 00000000000..7e9e07f4502 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_usage.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UsageProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_usageproperties.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_usageproperties.go new file mode 100644 index 00000000000..8b0f3272bdf --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_usageproperties.go @@ -0,0 +1,33 @@ +package appserviceenvironments + +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 UsageProperties struct { + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + CurrentValue *int64 `json:"currentValue,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Limit *int64 `json:"limit,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + SiteMode *string `json:"siteMode,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *UsageProperties) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UsageProperties) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualapplication.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualapplication.go new file mode 100644 index 00000000000..bdac22a3474 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualapplication.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualdirectory.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualdirectory.go new file mode 100644 index 00000000000..f4c38830a4c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualipmapping.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualipmapping.go new file mode 100644 index 00000000000..dc88e33ecba --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualipmapping.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualIPMapping struct { + InUse *bool `json:"inUse,omitempty"` + InternalHTTPPort *int64 `json:"internalHttpPort,omitempty"` + InternalHTTPSPort *int64 `json:"internalHttpsPort,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualnetworkprofile.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualnetworkprofile.go new file mode 100644 index 00000000000..d01868e107b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_virtualnetworkprofile.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkProfile struct { + Id string `json:"id"` + Name *string `json:"name,omitempty"` + Subnet *string `json:"subnet,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_workerpool.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_workerpool.go new file mode 100644 index 00000000000..fbb7707c437 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_workerpool.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkerPool struct { + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + InstanceNames *[]string `json:"instanceNames,omitempty"` + WorkerCount *int64 `json:"workerCount,omitempty"` + WorkerSize *string `json:"workerSize,omitempty"` + WorkerSizeId *int64 `json:"workerSizeId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/model_workerpoolresource.go b/resource-manager/web/2023-12-01/appserviceenvironments/model_workerpoolresource.go new file mode 100644 index 00000000000..6a4150ac46d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/model_workerpoolresource.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkerPoolResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkerPool `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceenvironments/predicates.go b/resource-manager/web/2023-12-01/appserviceenvironments/predicates.go new file mode 100644 index 00000000000..96a5324bde9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/predicates.go @@ -0,0 +1,335 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceEnvironmentResourceOperationPredicate) Matches(input AppServiceEnvironmentResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type AppServicePlanOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServicePlanOperationPredicate) Matches(input AppServicePlan) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type InboundEnvironmentEndpointOperationPredicate struct { + Description *string +} + +func (p InboundEnvironmentEndpointOperationPredicate) Matches(input InboundEnvironmentEndpoint) bool { + + if p.Description != nil && (input.Description == nil || *p.Description != *input.Description) { + return false + } + + return true +} + +type OutboundEnvironmentEndpointOperationPredicate struct { + Category *string +} + +func (p OutboundEnvironmentEndpointOperationPredicate) Matches(input OutboundEnvironmentEndpoint) bool { + + if p.Category != nil && (input.Category == nil || *p.Category != *input.Category) { + return false + } + + return true +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ResourceMetricDefinitionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ResourceMetricDefinitionOperationPredicate) Matches(input ResourceMetricDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SkuInfoOperationPredicate struct { + ResourceType *string +} + +func (p SkuInfoOperationPredicate) Matches(input SkuInfo) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} + +type StampCapacityOperationPredicate struct { + AvailableCapacity *int64 + ExcludeFromCapacityAllocation *bool + IsApplicableForAllComputeModes *bool + IsLinux *bool + Name *string + SiteMode *string + TotalCapacity *int64 + Unit *string + WorkerSizeId *int64 +} + +func (p StampCapacityOperationPredicate) Matches(input StampCapacity) bool { + + if p.AvailableCapacity != nil && (input.AvailableCapacity == nil || *p.AvailableCapacity != *input.AvailableCapacity) { + return false + } + + if p.ExcludeFromCapacityAllocation != nil && (input.ExcludeFromCapacityAllocation == nil || *p.ExcludeFromCapacityAllocation != *input.ExcludeFromCapacityAllocation) { + return false + } + + if p.IsApplicableForAllComputeModes != nil && (input.IsApplicableForAllComputeModes == nil || *p.IsApplicableForAllComputeModes != *input.IsApplicableForAllComputeModes) { + return false + } + + if p.IsLinux != nil && (input.IsLinux == nil || *p.IsLinux != *input.IsLinux) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.SiteMode != nil && (input.SiteMode == nil || *p.SiteMode != *input.SiteMode) { + return false + } + + if p.TotalCapacity != nil && (input.TotalCapacity == nil || *p.TotalCapacity != *input.TotalCapacity) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + if p.WorkerSizeId != nil && (input.WorkerSizeId == nil || *p.WorkerSizeId != *input.WorkerSizeId) { + return false + } + + return true +} + +type UsageOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WorkerPoolResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WorkerPoolResourceOperationPredicate) Matches(input WorkerPoolResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/appserviceenvironments/version.go b/resource-manager/web/2023-12-01/appserviceenvironments/version.go new file mode 100644 index 00000000000..3ee7bc37614 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceenvironments/version.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/appserviceenvironments/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/README.md b/resource-manager/web/2023-12-01/appserviceplans/README.md new file mode 100644 index 00000000000..1ca5f17dbf3 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/README.md @@ -0,0 +1,480 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans` Documentation + +The `appserviceplans` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans" +``` + + +### Client Initialization + +```go +client := appserviceplans.NewAppServicePlansClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServicePlansClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +payload := appserviceplans.AppServicePlan{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServicePlansClient.CreateOrUpdateVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "routeValue") + +payload := appserviceplans.VnetRoute{ + // ... +} + + +read, err := client.CreateOrUpdateVnetRoute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.DeleteHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "hybridConnectionNamespaceValue", "relayValue") + +read, err := client.DeleteHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.DeleteVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "routeValue") + +read, err := client.DeleteVnetRoute(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +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: `AppServicePlansClient.GetHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "hybridConnectionNamespaceValue", "relayValue") + +read, err := client.GetHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetHybridConnectionPlanLimit` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +read, err := client.GetHybridConnectionPlanLimit(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetRouteForVnet` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "routeValue") + +read, err := client.GetRouteForVnet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetServerFarmSkus` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +read, err := client.GetServerFarmSkus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetVnetFromServerFarm` + +```go +ctx := context.TODO() +id := appserviceplans.NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue") + +read, err := client.GetVnetFromServerFarm(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetVnetGateway` + +```go +ctx := context.TODO() +id := appserviceplans.NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "gatewayValue") + +read, err := client.GetVnetGateway(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, appserviceplans.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, appserviceplans.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListCapabilities` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +read, err := client.ListCapabilities(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListHybridConnectionKeys` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "hybridConnectionNamespaceValue", "relayValue") + +read, err := client.ListHybridConnectionKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListHybridConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +// alternatively `client.ListHybridConnections(ctx, id)` can be used to do batched pagination +items, err := client.ListHybridConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListRoutesForVnet` + +```go +ctx := context.TODO() +id := appserviceplans.NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue") + +read, err := client.ListRoutesForVnet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +// alternatively `client.ListUsages(ctx, id, appserviceplans.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, appserviceplans.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListVnets` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +read, err := client.ListVnets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +// alternatively `client.ListWebApps(ctx, id, appserviceplans.DefaultListWebAppsOperationOptions())` can be used to do batched pagination +items, err := client.ListWebAppsComplete(ctx, id, appserviceplans.DefaultListWebAppsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListWebAppsByHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "hybridConnectionNamespaceValue", "relayValue") + +// alternatively `client.ListWebAppsByHybridConnection(ctx, id)` can be used to do batched pagination +items, err := client.ListWebAppsByHybridConnectionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.RebootWorker` + +```go +ctx := context.TODO() +id := appserviceplans.NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "workerValue") + +read, err := client.RebootWorker(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.RestartWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +read, err := client.RestartWebApps(ctx, id, appserviceplans.DefaultRestartWebAppsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue") + +payload := appserviceplans.AppServicePlanPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.UpdateVnetGateway` + +```go +ctx := context.TODO() +id := appserviceplans.NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "gatewayValue") + +payload := appserviceplans.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.UpdateVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "routeValue") + +payload := appserviceplans.VnetRoute{ + // ... +} + + +read, err := client.UpdateVnetRoute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2023-12-01/appserviceplans/client.go b/resource-manager/web/2023-12-01/appserviceplans/client.go new file mode 100644 index 00000000000..8fe56fbaa27 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/client.go @@ -0,0 +1,26 @@ +package appserviceplans + +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 AppServicePlansClient struct { + Client *resourcemanager.Client +} + +func NewAppServicePlansClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServicePlansClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "appserviceplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServicePlansClient: %+v", err) + } + + return &AppServicePlansClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/constants.go b/resource-manager/web/2023-12-01/appserviceplans/constants.go new file mode 100644 index 00000000000..0d47b9fa049 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/constants.go @@ -0,0 +1,1271 @@ +package appserviceplans + +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 AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type RouteType string + +const ( + RouteTypeDefault RouteType = "DEFAULT" + RouteTypeINHERITED RouteType = "INHERITED" + RouteTypeSTATIC RouteType = "STATIC" +) + +func PossibleValuesForRouteType() []string { + return []string{ + string(RouteTypeDefault), + string(RouteTypeINHERITED), + string(RouteTypeSTATIC), + } +} + +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteType(input string) (*RouteType, error) { + vals := map[string]RouteType{ + "default": RouteTypeDefault, + "inherited": RouteTypeINHERITED, + "static": RouteTypeSTATIC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteType(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type StatusOptions string + +const ( + StatusOptionsCreating StatusOptions = "Creating" + StatusOptionsPending StatusOptions = "Pending" + StatusOptionsReady StatusOptions = "Ready" +) + +func PossibleValuesForStatusOptions() []string { + return []string{ + string(StatusOptionsCreating), + string(StatusOptionsPending), + string(StatusOptionsReady), + } +} + +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusOptions(input string) (*StatusOptions, error) { + vals := map[string]StatusOptions{ + "creating": StatusOptionsCreating, + "pending": StatusOptionsPending, + "ready": StatusOptionsReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusOptions(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeBlobContainer StorageType = "blobContainer" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeBlobContainer), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "blobcontainer": StorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay.go b/resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay.go new file mode 100644 index 00000000000..2b32c834b81 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HybridConnectionNamespaceRelayId{}) +} + +var _ resourceids.ResourceId = &HybridConnectionNamespaceRelayId{} + +// HybridConnectionNamespaceRelayId is a struct representing the Resource ID for a Hybrid Connection Namespace Relay +type HybridConnectionNamespaceRelayId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewHybridConnectionNamespaceRelayID returns a new HybridConnectionNamespaceRelayId struct +func NewHybridConnectionNamespaceRelayID(subscriptionId string, resourceGroupName string, serverFarmName string, hybridConnectionNamespaceName string, relayName string) HybridConnectionNamespaceRelayId { + return HybridConnectionNamespaceRelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseHybridConnectionNamespaceRelayID parses 'input' into a HybridConnectionNamespaceRelayId +func ParseHybridConnectionNamespaceRelayID(input string) (*HybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionNamespaceRelayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHybridConnectionNamespaceRelayIDInsensitively parses 'input' case-insensitively into a HybridConnectionNamespaceRelayId +// note: this method should only be used for API response data and not user input +func ParseHybridConnectionNamespaceRelayIDInsensitively(input string) (*HybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionNamespaceRelayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HybridConnectionNamespaceRelayId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateHybridConnectionNamespaceRelayID checks that 'input' can be parsed as a Hybrid Connection Namespace Relay ID +func ValidateHybridConnectionNamespaceRelayID(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 := ParseHybridConnectionNamespaceRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmValue"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceValue"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayValue"), + } +} + +// String returns a human-readable description of this Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Hybrid Connection Namespace Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go b/resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go new file mode 100644 index 00000000000..c188bc9fd20 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +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 = &HybridConnectionNamespaceRelayId{} + +func TestNewHybridConnectionNamespaceRelayID(t *testing.T) { + id := NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "hybridConnectionNamespaceValue", "relayValue") + + 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.ServerFarmName != "serverFarmValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmValue") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceValue") + } + + if id.RelayName != "relayValue" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayValue") + } +} + +func TestFormatHybridConnectionNamespaceRelayID(t *testing.T) { + actual := NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "hybridConnectionNamespaceValue", "relayValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHybridConnectionNamespaceRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + HybridConnectionNamespaceName: "hybridConnectionNamespaceValue", + RelayName: "relayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionNamespaceRelayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseHybridConnectionNamespaceRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + HybridConnectionNamespaceName: "hybridConnectionNamespaceValue", + RelayName: "relayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS/rElAyVaLuE", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMvAlUe", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE", + RelayName: "rElAyVaLuE", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS/rElAyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionNamespaceRelayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForHybridConnectionNamespaceRelayId(t *testing.T) { + segments := HybridConnectionNamespaceRelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HybridConnectionNamespaceRelayId 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/web/2023-12-01/appserviceplans/id_route.go b/resource-manager/web/2023-12-01/appserviceplans/id_route.go new file mode 100644 index 00000000000..ad716f02546 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_route.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteId{}) +} + +var _ resourceids.ResourceId = &RouteId{} + +// RouteId is a struct representing the Resource ID for a Route +type RouteId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string + RouteName string +} + +// NewRouteID returns a new RouteId struct +func NewRouteID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string, routeName string) RouteId { + return RouteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + RouteName: routeName, + } +} + +// ParseRouteID parses 'input' into a RouteId +func ParseRouteID(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteIDInsensitively parses 'input' case-insensitively into a RouteId +// note: this method should only be used for API response data and not user input +func ParseRouteIDInsensitively(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.RouteName, ok = input.Parsed["routeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeName", input) + } + + return nil +} + +// ValidateRouteID checks that 'input' can be parsed as a Route ID +func ValidateRouteID(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 := ParseRouteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route ID +func (id RouteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s/routes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName, id.RouteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route ID +func (id RouteId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmValue"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionValue"), + resourceids.StaticSegment("staticRoutes", "routes", "routes"), + resourceids.UserSpecifiedSegment("routeName", "routeValue"), + } +} + +// String returns a human-readable description of this Route ID +func (id RouteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Route Name: %q", id.RouteName), + } + return fmt.Sprintf("Route (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/id_route_test.go b/resource-manager/web/2023-12-01/appserviceplans/id_route_test.go new file mode 100644 index 00000000000..63b0414f07e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_route_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +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 = &RouteId{} + +func TestNewRouteID(t *testing.T) { + id := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "routeValue") + + 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.ServerFarmName != "serverFarmValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmValue") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionValue") + } + + if id.RouteName != "routeValue" { + t.Fatalf("Expected %q but got %q for Segment 'RouteName'", id.RouteName, "routeValue") + } +} + +func TestFormatRouteID(t *testing.T) { + actual := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "routeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/routes/routeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/routes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/routes/routeValue", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + RouteName: "routeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/routes/routeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestParseRouteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/routes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/rOuTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/routes/routeValue", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + RouteName: "routeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/routes/routeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/rOuTeS/rOuTeVaLuE", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMvAlUe", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + RouteName: "rOuTeVaLuE", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/rOuTeS/rOuTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestSegmentsForRouteId(t *testing.T) { + segments := RouteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteId 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/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go b/resource-manager/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go new file mode 100644 index 00000000000..17ab90193a3 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go @@ -0,0 +1,139 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServerFarmVirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &ServerFarmVirtualNetworkConnectionId{} + +// ServerFarmVirtualNetworkConnectionId is a struct representing the Resource ID for a Server Farm Virtual Network Connection +type ServerFarmVirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string +} + +// NewServerFarmVirtualNetworkConnectionID returns a new ServerFarmVirtualNetworkConnectionId struct +func NewServerFarmVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string) ServerFarmVirtualNetworkConnectionId { + return ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseServerFarmVirtualNetworkConnectionID parses 'input' into a ServerFarmVirtualNetworkConnectionId +func ParseServerFarmVirtualNetworkConnectionID(input string) (*ServerFarmVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerFarmVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerFarmVirtualNetworkConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServerFarmVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a ServerFarmVirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseServerFarmVirtualNetworkConnectionIDInsensitively(input string) (*ServerFarmVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerFarmVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerFarmVirtualNetworkConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServerFarmVirtualNetworkConnectionId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateServerFarmVirtualNetworkConnectionID checks that 'input' can be parsed as a Server Farm Virtual Network Connection ID +func ValidateServerFarmVirtualNetworkConnectionID(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 := ParseServerFarmVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmValue"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionValue"), + } +} + +// String returns a human-readable description of this Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Server Farm Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go b/resource-manager/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go new file mode 100644 index 00000000000..232cc84cfc9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go @@ -0,0 +1,327 @@ +package appserviceplans + +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 = &ServerFarmVirtualNetworkConnectionId{} + +func TestNewServerFarmVirtualNetworkConnectionID(t *testing.T) { + id := NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue") + + 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.ServerFarmName != "serverFarmValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmValue") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionValue") + } +} + +func TestFormatServerFarmVirtualNetworkConnectionID(t *testing.T) { + actual := NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServerFarmVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerFarmVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerFarmVirtualNetworkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseServerFarmVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerFarmVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMvAlUe", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerFarmVirtualNetworkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForServerFarmVirtualNetworkConnectionId(t *testing.T) { + segments := ServerFarmVirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServerFarmVirtualNetworkConnectionId 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/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway.go b/resource-manager/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway.go new file mode 100644 index 00000000000..fd8f8a5724d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkConnectionGatewayId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkConnectionGatewayId{} + +// VirtualNetworkConnectionGatewayId is a struct representing the Resource ID for a Virtual Network Connection Gateway +type VirtualNetworkConnectionGatewayId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewVirtualNetworkConnectionGatewayID returns a new VirtualNetworkConnectionGatewayId struct +func NewVirtualNetworkConnectionGatewayID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string, gatewayName string) VirtualNetworkConnectionGatewayId { + return VirtualNetworkConnectionGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseVirtualNetworkConnectionGatewayID parses 'input' into a VirtualNetworkConnectionGatewayId +func ParseVirtualNetworkConnectionGatewayID(input string) (*VirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionGatewayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkConnectionGatewayIDInsensitively parses 'input' case-insensitively into a VirtualNetworkConnectionGatewayId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkConnectionGatewayIDInsensitively(input string) (*VirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionGatewayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkConnectionGatewayId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateVirtualNetworkConnectionGatewayID checks that 'input' can be parsed as a Virtual Network Connection Gateway ID +func ValidateVirtualNetworkConnectionGatewayID(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 := ParseVirtualNetworkConnectionGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmValue"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionValue"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayValue"), + } +} + +// String returns a human-readable description of this Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Virtual Network Connection Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go b/resource-manager/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go new file mode 100644 index 00000000000..1cae560d284 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +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 = &VirtualNetworkConnectionGatewayId{} + +func TestNewVirtualNetworkConnectionGatewayID(t *testing.T) { + id := NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "gatewayValue") + + 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.ServerFarmName != "serverFarmValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmValue") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionValue") + } + + if id.GatewayName != "gatewayValue" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayValue") + } +} + +func TestFormatVirtualNetworkConnectionGatewayID(t *testing.T) { + actual := NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "virtualNetworkConnectionValue", "gatewayValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkConnectionGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + GatewayName: "gatewayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseVirtualNetworkConnectionGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + GatewayName: "gatewayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS/gAtEwAyVaLuE", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMvAlUe", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + GatewayName: "gAtEwAyVaLuE", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS/gAtEwAyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForVirtualNetworkConnectionGatewayId(t *testing.T) { + segments := VirtualNetworkConnectionGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkConnectionGatewayId 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/web/2023-12-01/appserviceplans/id_worker.go b/resource-manager/web/2023-12-01/appserviceplans/id_worker.go new file mode 100644 index 00000000000..284032cb1f8 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_worker.go @@ -0,0 +1,139 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkerId{}) +} + +var _ resourceids.ResourceId = &WorkerId{} + +// WorkerId is a struct representing the Resource ID for a Worker +type WorkerId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + WorkerName string +} + +// NewWorkerID returns a new WorkerId struct +func NewWorkerID(subscriptionId string, resourceGroupName string, serverFarmName string, workerName string) WorkerId { + return WorkerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + WorkerName: workerName, + } +} + +// ParseWorkerID parses 'input' into a WorkerId +func ParseWorkerID(input string) (*WorkerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerIDInsensitively parses 'input' case-insensitively into a WorkerId +// note: this method should only be used for API response data and not user input +func ParseWorkerIDInsensitively(input string) (*WorkerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerId) 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.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.WorkerName, ok = input.Parsed["workerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerName", input) + } + + return nil +} + +// ValidateWorkerID checks that 'input' can be parsed as a Worker ID +func ValidateWorkerID(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 := ParseWorkerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker ID +func (id WorkerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/workers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.WorkerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker ID +func (id WorkerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmValue"), + resourceids.StaticSegment("staticWorkers", "workers", "workers"), + resourceids.UserSpecifiedSegment("workerName", "workerValue"), + } +} + +// String returns a human-readable description of this Worker ID +func (id WorkerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Worker Name: %q", id.WorkerName), + } + return fmt.Sprintf("Worker (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/id_worker_test.go b/resource-manager/web/2023-12-01/appserviceplans/id_worker_test.go new file mode 100644 index 00000000000..8e8617f0b52 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/id_worker_test.go @@ -0,0 +1,327 @@ +package appserviceplans + +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 = &WorkerId{} + +func TestNewWorkerID(t *testing.T) { + id := NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "workerValue") + + 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.ServerFarmName != "serverFarmValue" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmValue") + } + + if id.WorkerName != "workerValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerName'", id.WorkerName, "workerValue") + } +} + +func TestFormatWorkerID(t *testing.T) { + actual := NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmValue", "workerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/workers/workerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/workers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/workers/workerValue", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + WorkerName: "workerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/workers/workerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.WorkerName != v.Expected.WorkerName { + t.Fatalf("Expected %q but got %q for WorkerName", v.Expected.WorkerName, actual.WorkerName) + } + + } +} + +func TestParseWorkerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/workers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/wOrKeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/workers/workerValue", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmValue", + WorkerName: "workerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmValue/workers/workerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMvAlUe/wOrKeRs/wOrKeRvAlUe", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMvAlUe", + WorkerName: "wOrKeRvAlUe", + }, + }, + { + // 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.wEb/sErVeRfArMs/sErVeRfArMvAlUe/wOrKeRs/wOrKeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.WorkerName != v.Expected.WorkerName { + t.Fatalf("Expected %q but got %q for WorkerName", v.Expected.WorkerName, actual.WorkerName) + } + + } +} + +func TestSegmentsForWorkerId(t *testing.T) { + segments := WorkerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerId 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/web/2023-12-01/appserviceplans/method_createorupdate.go b/resource-manager/web/2023-12-01/appserviceplans/method_createorupdate.go new file mode 100644 index 00000000000..130e220ffb1 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_createorupdate.go @@ -0,0 +1,76 @@ +package appserviceplans + +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/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// CreateOrUpdate ... +func (c AppServicePlansClient) CreateOrUpdate(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlan) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServicePlansClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlan) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_createorupdatevnetroute.go b/resource-manager/web/2023-12-01/appserviceplans/method_createorupdatevnetroute.go new file mode 100644 index 00000000000..c61bc8980f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_createorupdatevnetroute.go @@ -0,0 +1,58 @@ +package appserviceplans + +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 CreateOrUpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// CreateOrUpdateVnetRoute ... +func (c AppServicePlansClient) CreateOrUpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result CreateOrUpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetRoute + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_delete.go b/resource-manager/web/2023-12-01/appserviceplans/method_delete.go new file mode 100644 index 00000000000..4d95de15002 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_delete.go @@ -0,0 +1,48 @@ +package appserviceplans + +import ( + "context" + "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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServicePlansClient) Delete(ctx context.Context, id commonids.AppServicePlanId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_deletehybridconnection.go b/resource-manager/web/2023-12-01/appserviceplans/method_deletehybridconnection.go new file mode 100644 index 00000000000..e886d4067bc --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_deletehybridconnection.go @@ -0,0 +1,47 @@ +package appserviceplans + +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 DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c AppServicePlansClient) DeleteHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_deletevnetroute.go b/resource-manager/web/2023-12-01/appserviceplans/method_deletevnetroute.go new file mode 100644 index 00000000000..ad025ea00a2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_deletevnetroute.go @@ -0,0 +1,46 @@ +package appserviceplans + +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 DeleteVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetRoute ... +func (c AppServicePlansClient) DeleteVnetRoute(ctx context.Context, id RouteId) (result DeleteVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_get.go b/resource-manager/web/2023-12-01/appserviceplans/method_get.go new file mode 100644 index 00000000000..a4d52b636e6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_get.go @@ -0,0 +1,55 @@ +package appserviceplans + +import ( + "context" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// Get ... +func (c AppServicePlansClient) Get(ctx context.Context, id commonids.AppServicePlanId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServicePlan + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnection.go b/resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnection.go new file mode 100644 index 00000000000..61c582b536d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnection.go @@ -0,0 +1,54 @@ +package appserviceplans + +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 GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c AppServicePlansClient) GetHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result GetHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnectionplanlimit.go b/resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnectionplanlimit.go new file mode 100644 index 00000000000..b6099bdcb7f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_gethybridconnectionplanlimit.go @@ -0,0 +1,56 @@ +package appserviceplans + +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 GetHybridConnectionPlanLimitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionLimits +} + +// GetHybridConnectionPlanLimit ... +func (c AppServicePlansClient) GetHybridConnectionPlanLimit(ctx context.Context, id commonids.AppServicePlanId) (result GetHybridConnectionPlanLimitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionPlanLimits/limit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnectionLimits + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_getrouteforvnet.go b/resource-manager/web/2023-12-01/appserviceplans/method_getrouteforvnet.go new file mode 100644 index 00000000000..338777c766d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_getrouteforvnet.go @@ -0,0 +1,54 @@ +package appserviceplans + +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 GetRouteForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// GetRouteForVnet ... +func (c AppServicePlansClient) GetRouteForVnet(ctx context.Context, id RouteId) (result GetRouteForVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetRoute + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_getserverfarmskus.go b/resource-manager/web/2023-12-01/appserviceplans/method_getserverfarmskus.go new file mode 100644 index 00000000000..227a69198de --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_getserverfarmskus.go @@ -0,0 +1,56 @@ +package appserviceplans + +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 GetServerFarmSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetServerFarmSkus ... +func (c AppServicePlansClient) GetServerFarmSkus(ctx context.Context, id commonids.AppServicePlanId) (result GetServerFarmSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_getvnetfromserverfarm.go b/resource-manager/web/2023-12-01/appserviceplans/method_getvnetfromserverfarm.go new file mode 100644 index 00000000000..3190297402b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_getvnetfromserverfarm.go @@ -0,0 +1,54 @@ +package appserviceplans + +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 GetVnetFromServerFarmOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetFromServerFarm ... +func (c AppServicePlansClient) GetVnetFromServerFarm(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result GetVnetFromServerFarmOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_getvnetgateway.go b/resource-manager/web/2023-12-01/appserviceplans/method_getvnetgateway.go new file mode 100644 index 00000000000..ce36c736228 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_getvnetgateway.go @@ -0,0 +1,54 @@ +package appserviceplans + +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 GetVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetGateway ... +func (c AppServicePlansClient) GetVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId) (result GetVnetGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_list.go b/resource-manager/web/2023-12-01/appserviceplans/method_list.go new file mode 100644 index 00000000000..b247deb0d59 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_list.go @@ -0,0 +1,120 @@ +package appserviceplans + +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 *[]AppServicePlan +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +type ListOperationOptions struct { + Detailed *bool +} + +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.Detailed != nil { + out.Append("detailed", fmt.Sprintf("%v", *o.Detailed)) + } + return &out +} + +// List ... +func (c AppServicePlansClient) List(ctx context.Context, id commonids.SubscriptionId, 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/providers/Microsoft.Web/serverFarms", 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 *[]AppServicePlan `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 AppServicePlansClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, AppServicePlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate AppServicePlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServicePlan, 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/web/2023-12-01/appserviceplans/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/appserviceplans/method_listbyresourcegroup.go new file mode 100644 index 00000000000..48dabe9757a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +// ListByResourceGroup ... +func (c AppServicePlansClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", 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 *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServicePlanOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listcapabilities.go b/resource-manager/web/2023-12-01/appserviceplans/method_listcapabilities.go new file mode 100644 index 00000000000..5720548c003 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listcapabilities.go @@ -0,0 +1,56 @@ +package appserviceplans + +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 ListCapabilitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Capability +} + +// ListCapabilities ... +func (c AppServicePlansClient) ListCapabilities(ctx context.Context, id commonids.AppServicePlanId) (result ListCapabilitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capabilities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []Capability + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnectionkeys.go b/resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnectionkeys.go new file mode 100644 index 00000000000..874cdd76c26 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnectionkeys.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 ListHybridConnectionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionKey +} + +// ListHybridConnectionKeys ... +func (c AppServicePlansClient) ListHybridConnectionKeys(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListHybridConnectionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnectionKey + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnections.go b/resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnections.go new file mode 100644 index 00000000000..61d7d2202ba --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listhybridconnections.go @@ -0,0 +1,92 @@ +package appserviceplans + +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 ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HybridConnection +} + +type ListHybridConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []HybridConnection +} + +// ListHybridConnections ... +func (c AppServicePlansClient) ListHybridConnections(ctx context.Context, id commonids.AppServicePlanId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", 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 *[]HybridConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHybridConnectionsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListHybridConnectionsComplete(ctx context.Context, id commonids.AppServicePlanId) (ListHybridConnectionsCompleteResult, error) { + return c.ListHybridConnectionsCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) +} + +// ListHybridConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListHybridConnectionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, predicate HybridConnectionOperationPredicate) (result ListHybridConnectionsCompleteResult, err error) { + items := make([]HybridConnection, 0) + + resp, err := c.ListHybridConnections(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 = ListHybridConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listroutesforvnet.go b/resource-manager/web/2023-12-01/appserviceplans/method_listroutesforvnet.go new file mode 100644 index 00000000000..84c82c62f54 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listroutesforvnet.go @@ -0,0 +1,55 @@ +package appserviceplans + +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 ListRoutesForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// ListRoutesForVnet ... +func (c AppServicePlansClient) ListRoutesForVnet(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result ListRoutesForVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/routes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetRoute + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listusages.go b/resource-manager/web/2023-12-01/appserviceplans/method_listusages.go new file mode 100644 index 00000000000..8458aa9981e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listusages.go @@ -0,0 +1,120 @@ +package appserviceplans + +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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsages ... +func (c AppServicePlansClient) ListUsages(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListUsagesComplete(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(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 = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listvnets.go b/resource-manager/web/2023-12-01/appserviceplans/method_listvnets.go new file mode 100644 index 00000000000..39863133e91 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listvnets.go @@ -0,0 +1,56 @@ +package appserviceplans + +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 ListVnetsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnets ... +func (c AppServicePlansClient) ListVnets(ctx context.Context, id commonids.AppServicePlanId) (result ListVnetsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listwebapps.go b/resource-manager/web/2023-12-01/appserviceplans/method_listwebapps.go new file mode 100644 index 00000000000..e5801e22f2c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listwebapps.go @@ -0,0 +1,124 @@ +package appserviceplans + +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 ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListWebAppsOperationOptions struct { + Filter *string + Top *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListWebApps ... +func (c AppServicePlansClient) ListWebApps(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sites", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsComplete(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(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 = ListWebAppsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_listwebappsbyhybridconnection.go b/resource-manager/web/2023-12-01/appserviceplans/method_listwebappsbyhybridconnection.go new file mode 100644 index 00000000000..5b13718ee5d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_listwebappsbyhybridconnection.go @@ -0,0 +1,84 @@ +package appserviceplans + +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 ListWebAppsByHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type ListWebAppsByHybridConnectionCompleteResult struct { + LatestHttpResponse *http.Response + Items []string +} + +// ListWebAppsByHybridConnection ... +func (c AppServicePlansClient) ListWebAppsByHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sites", 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 *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsByHybridConnectionComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsByHybridConnectionComplete(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.ListWebAppsByHybridConnection(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListWebAppsByHybridConnectionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_rebootworker.go b/resource-manager/web/2023-12-01/appserviceplans/method_rebootworker.go new file mode 100644 index 00000000000..b1e54e3cffe --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_rebootworker.go @@ -0,0 +1,47 @@ +package appserviceplans + +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 RebootWorkerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RebootWorker ... +func (c AppServicePlansClient) RebootWorker(ctx context.Context, id WorkerId) (result RebootWorkerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_restartwebapps.go b/resource-manager/web/2023-12-01/appserviceplans/method_restartwebapps.go new file mode 100644 index 00000000000..ffa2a205011 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_restartwebapps.go @@ -0,0 +1,76 @@ +package appserviceplans + +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 RestartWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartWebAppsOperationOptions struct { + SoftRestart *bool +} + +func DefaultRestartWebAppsOperationOptions() RestartWebAppsOperationOptions { + return RestartWebAppsOperationOptions{} +} + +func (o RestartWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RestartWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + return &out +} + +// RestartWebApps ... +func (c AppServicePlansClient) RestartWebApps(ctx context.Context, id commonids.AppServicePlanId, options RestartWebAppsOperationOptions) (result RestartWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restartSites", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_update.go b/resource-manager/web/2023-12-01/appserviceplans/method_update.go new file mode 100644 index 00000000000..8c369f53a74 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_update.go @@ -0,0 +1,60 @@ +package appserviceplans + +import ( + "context" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// Update ... +func (c AppServicePlansClient) Update(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlanPatchResource) (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 + } + + var model AppServicePlan + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_updatevnetgateway.go b/resource-manager/web/2023-12-01/appserviceplans/method_updatevnetgateway.go new file mode 100644 index 00000000000..a0861673f2a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_updatevnetgateway.go @@ -0,0 +1,58 @@ +package appserviceplans + +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 UpdateVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetGateway ... +func (c AppServicePlansClient) UpdateVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/method_updatevnetroute.go b/resource-manager/web/2023-12-01/appserviceplans/method_updatevnetroute.go new file mode 100644 index 00000000000..38d2438c46c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/method_updatevnetroute.go @@ -0,0 +1,58 @@ +package appserviceplans + +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 UpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// UpdateVnetRoute ... +func (c AppServicePlansClient) UpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result UpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetRoute + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_apidefinitioninfo.go b/resource-manager/web/2023-12-01/appserviceplans/model_apidefinitioninfo.go new file mode 100644 index 00000000000..2ac5fa81cba --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_apimanagementconfig.go b/resource-manager/web/2023-12-01/appserviceplans/model_apimanagementconfig.go new file mode 100644 index 00000000000..dab0ea80e65 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplan.go b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplan.go new file mode 100644 index 00000000000..939499f257a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplan.go @@ -0,0 +1,16 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlan struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanProperties `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresource.go b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresource.go new file mode 100644 index 00000000000..e2e21fc04a7 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresource.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresourceproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresourceproperties.go new file mode 100644 index 00000000000..efdb53cdcff --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanpatchresourceproperties.go @@ -0,0 +1,60 @@ +package appserviceplans + +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 AppServicePlanPatchResourceProperties struct { + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanPatchResourceProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanPatchResourceProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanPatchResourceProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanPatchResourceProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanproperties.go new file mode 100644 index 00000000000..6fde086c9ed --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_appserviceplanproperties.go @@ -0,0 +1,60 @@ +package appserviceplans + +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 AppServicePlanProperties struct { + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_autohealactions.go b/resource-manager/web/2023-12-01/appserviceplans/model_autohealactions.go new file mode 100644 index 00000000000..e32290fd78e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_autohealactions.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_autohealcustomaction.go b/resource-manager/web/2023-12-01/appserviceplans/model_autohealcustomaction.go new file mode 100644 index 00000000000..2b7e2af847d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_autohealrules.go b/resource-manager/web/2023-12-01/appserviceplans/model_autohealrules.go new file mode 100644 index 00000000000..6da2d1028df --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_autohealrules.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_autohealtriggers.go b/resource-manager/web/2023-12-01/appserviceplans/model_autohealtriggers.go new file mode 100644 index 00000000000..a3c3a7fe781 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_azurestorageinfovalue.go b/resource-manager/web/2023-12-01/appserviceplans/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..0c62698b97b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_capability.go b/resource-manager/web/2023-12-01/appserviceplans/model_capability.go new file mode 100644 index 00000000000..0cfebd66ae9 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_capability.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_cloninginfo.go b/resource-manager/web/2023-12-01/appserviceplans/model_cloninginfo.go new file mode 100644 index 00000000000..5d297b188da --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_cloninginfo.go @@ -0,0 +1,18 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_connstringinfo.go b/resource-manager/web/2023-12-01/appserviceplans/model_connstringinfo.go new file mode 100644 index 00000000000..367ae1ac201 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_connstringinfo.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_corssettings.go b/resource-manager/web/2023-12-01/appserviceplans/model_corssettings.go new file mode 100644 index 00000000000..ec523b9ae12 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_corssettings.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_csmusagequota.go b/resource-manager/web/2023-12-01/appserviceplans/model_csmusagequota.go new file mode 100644 index 00000000000..24ec9c595c0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_csmusagequota.go @@ -0,0 +1,30 @@ +package appserviceplans + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_daprconfig.go b/resource-manager/web/2023-12-01/appserviceplans/model_daprconfig.go new file mode 100644 index 00000000000..bd07c41dcc8 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_daprconfig.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_experiments.go b/resource-manager/web/2023-12-01/appserviceplans/model_experiments.go new file mode 100644 index 00000000000..c10e0c96da0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_experiments.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_extendedlocation.go b/resource-manager/web/2023-12-01/appserviceplans/model_extendedlocation.go new file mode 100644 index 00000000000..9e237794a1d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_extendedlocation.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionappconfig.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionappconfig.go new file mode 100644 index 00000000000..5eb3b499888 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionappconfig.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsalwaysreadyconfig.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..db67a134da1 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *float64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeployment.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeployment.go new file mode 100644 index 00000000000..41f4213a7c6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorage.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..548179a4e08 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *StorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..e194eb9b172 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsruntime.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsruntime.go new file mode 100644 index 00000000000..d04994cdbd0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsruntime.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrency.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..497bdfea72a --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *float64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *float64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..9a87d6ba0f2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..1d051eda2a0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *float64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_handlermapping.go b/resource-manager/web/2023-12-01/appserviceplans/model_handlermapping.go new file mode 100644 index 00000000000..2b0fd51c628 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_handlermapping.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hostingenvironmentprofile.go b/resource-manager/web/2023-12-01/appserviceplans/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..3e6d1e245c0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hostnamesslstate.go b/resource-manager/web/2023-12-01/appserviceplans/model_hostnamesslstate.go new file mode 100644 index 00000000000..eb49e879dbe --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnection.go b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnection.go new file mode 100644 index 00000000000..92deac554e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnection.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkey.go b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkey.go new file mode 100644 index 00000000000..95cbaf8d9c6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkey.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionKey struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionKeyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkeyproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkeyproperties.go new file mode 100644 index 00000000000..b9d55a5c698 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionkeyproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionKeyProperties struct { + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimits.go b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimits.go new file mode 100644 index 00000000000..1463d5e4dbf --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimits.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionLimits struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionLimitsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimitsproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimitsproperties.go new file mode 100644 index 00000000000..a462d888655 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionlimitsproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionLimitsProperties struct { + Current *int64 `json:"current,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionproperties.go new file mode 100644 index 00000000000..93e6f70afd6 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_hybridconnectionproperties.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionProperties struct { + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + RelayArmUri *string `json:"relayArmUri,omitempty"` + RelayName *string `json:"relayName,omitempty"` + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + ServiceBusSuffix *string `json:"serviceBusSuffix,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_ipsecurityrestriction.go b/resource-manager/web/2023-12-01/appserviceplans/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..d1bf7483ffc --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_kubeenvironmentprofile.go b/resource-manager/web/2023-12-01/appserviceplans/model_kubeenvironmentprofile.go new file mode 100644 index 00000000000..a8c2c586a76 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_kubeenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_localizablestring.go b/resource-manager/web/2023-12-01/appserviceplans/model_localizablestring.go new file mode 100644 index 00000000000..3f1e149630e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_localizablestring.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_namevaluepair.go b/resource-manager/web/2023-12-01/appserviceplans/model_namevaluepair.go new file mode 100644 index 00000000000..8810fa8f3de --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_namevaluepair.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_pushsettings.go b/resource-manager/web/2023-12-01/appserviceplans/model_pushsettings.go new file mode 100644 index 00000000000..4dc8d4fea82 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_pushsettings.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_pushsettingsproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_pushsettingsproperties.go new file mode 100644 index 00000000000..beae479c519 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_rampuprule.go b/resource-manager/web/2023-12-01/appserviceplans/model_rampuprule.go new file mode 100644 index 00000000000..a8a0548b489 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_rampuprule.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackUrl *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_requestsbasedtrigger.go b/resource-manager/web/2023-12-01/appserviceplans/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..3858f02d387 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_resourceconfig.go b/resource-manager/web/2023-12-01/appserviceplans/model_resourceconfig.go new file mode 100644 index 00000000000..3998b6a1a11 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_resourceconfig.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_site.go b/resource-manager/web/2023-12-01/appserviceplans/model_site.go new file mode 100644 index 00000000000..f0199b22e0b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_site.go @@ -0,0 +1,20 @@ +package appserviceplans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_siteconfig.go b/resource-manager/web/2023-12-01/appserviceplans/model_siteconfig.go new file mode 100644 index 00000000000..d0cdbe23817 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_siteconfig.go @@ -0,0 +1,97 @@ +package appserviceplans + +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 SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_sitednsconfig.go b/resource-manager/web/2023-12-01/appserviceplans/model_sitednsconfig.go new file mode 100644 index 00000000000..58beab17a2d --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_sitelimits.go b/resource-manager/web/2023-12-01/appserviceplans/model_sitelimits.go new file mode 100644 index 00000000000..1036a87d597 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_sitelimits.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_sitemachinekey.go b/resource-manager/web/2023-12-01/appserviceplans/model_sitemachinekey.go new file mode 100644 index 00000000000..17855ad5e8c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go new file mode 100644 index 00000000000..e2cb7617883 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_siteproperties.go @@ -0,0 +1,89 @@ +package appserviceplans + +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 SiteProperties struct { + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + VnetBackupRestoreEnabled *bool `json:"vnetBackupRestoreEnabled,omitempty"` + VnetContentShareEnabled *bool `json:"vnetContentShareEnabled,omitempty"` + VnetImagePullEnabled *bool `json:"vnetImagePullEnabled,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_skucapacity.go b/resource-manager/web/2023-12-01/appserviceplans/model_skucapacity.go new file mode 100644 index 00000000000..7bbedd7e00e --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_skucapacity.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_skudescription.go b/resource-manager/web/2023-12-01/appserviceplans/model_skudescription.go new file mode 100644 index 00000000000..290adb2a1ad --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_skudescription.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_slotswapstatus.go b/resource-manager/web/2023-12-01/appserviceplans/model_slotswapstatus.go new file mode 100644 index 00000000000..707d5e1848f --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package appserviceplans + +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 SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_slowrequestsbasedtrigger.go b/resource-manager/web/2023-12-01/appserviceplans/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..d3f5bc55adb --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_statuscodesbasedtrigger.go b/resource-manager/web/2023-12-01/appserviceplans/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..9e615c4b53c --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2023-12-01/appserviceplans/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..b99ecfaebd7 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_virtualapplication.go b/resource-manager/web/2023-12-01/appserviceplans/model_virtualapplication.go new file mode 100644 index 00000000000..dc79bed2982 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_virtualapplication.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_virtualdirectory.go b/resource-manager/web/2023-12-01/appserviceplans/model_virtualdirectory.go new file mode 100644 index 00000000000..35b134e5664 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_vnetgateway.go b/resource-manager/web/2023-12-01/appserviceplans/model_vnetgateway.go new file mode 100644 index 00000000000..f7474dfa9e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_vnetgateway.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGateway struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetGatewayProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_vnetgatewayproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_vnetgatewayproperties.go new file mode 100644 index 00000000000..407a93e7f24 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_vnetgatewayproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGatewayProperties struct { + VnetName *string `json:"vnetName,omitempty"` + VpnPackageUri string `json:"vpnPackageUri"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_vnetinfo.go b/resource-manager/web/2023-12-01/appserviceplans/model_vnetinfo.go new file mode 100644 index 00000000000..fe7cf2d0253 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_vnetinfo.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfo struct { + CertBlob *string `json:"certBlob,omitempty"` + CertThumbprint *string `json:"certThumbprint,omitempty"` + DnsServers *string `json:"dnsServers,omitempty"` + IsSwift *bool `json:"isSwift,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + Routes *[]VnetRoute `json:"routes,omitempty"` + VnetResourceId *string `json:"vnetResourceId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_vnetinforesource.go b/resource-manager/web/2023-12-01/appserviceplans/model_vnetinforesource.go new file mode 100644 index 00000000000..2a5fcabaeaa --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_vnetinforesource.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfoResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_vnetroute.go b/resource-manager/web/2023-12-01/appserviceplans/model_vnetroute.go new file mode 100644 index 00000000000..ea4f24d9d78 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_vnetroute.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetRouteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/model_vnetrouteproperties.go b/resource-manager/web/2023-12-01/appserviceplans/model_vnetrouteproperties.go new file mode 100644 index 00000000000..ccedc00af71 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/model_vnetrouteproperties.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRouteProperties struct { + EndAddress *string `json:"endAddress,omitempty"` + RouteType *RouteType `json:"routeType,omitempty"` + StartAddress *string `json:"startAddress,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/predicates.go b/resource-manager/web/2023-12-01/appserviceplans/predicates.go new file mode 100644 index 00000000000..31b4416ccb0 --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/predicates.go @@ -0,0 +1,126 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServicePlanOperationPredicate) Matches(input AppServicePlan) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type HybridConnectionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p HybridConnectionOperationPredicate) Matches(input HybridConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2023-12-01/appserviceplans/version.go b/resource-manager/web/2023-12-01/appserviceplans/version.go new file mode 100644 index 00000000000..c624303ad0b --- /dev/null +++ b/resource-manager/web/2023-12-01/appserviceplans/version.go @@ -0,0 +1,12 @@ +package appserviceplans + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/appserviceplans/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/README.md b/resource-manager/web/2023-12-01/certificateordersdiagnostics/README.md new file mode 100644 index 00000000000..44987cb20e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificateordersdiagnostics` Documentation + +The `certificateordersdiagnostics` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificateordersdiagnostics" +``` + + +### Client Initialization + +```go +client := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificateOrdersDiagnosticsClient.GetAppServiceCertificateOrderDetectorResponse` + +```go +ctx := context.TODO() +id := certificateordersdiagnostics.NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "detectorValue") + +read, err := client.GetAppServiceCertificateOrderDetectorResponse(ctx, id, certificateordersdiagnostics.DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificateOrdersDiagnosticsClient.ListAppServiceCertificateOrderDetectorResponse` + +```go +ctx := context.TODO() +id := certificateordersdiagnostics.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + +// alternatively `client.ListAppServiceCertificateOrderDetectorResponse(ctx, id)` can be used to do batched pagination +items, err := client.ListAppServiceCertificateOrderDetectorResponseComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/client.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/client.go new file mode 100644 index 00000000000..b050da126b5 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/client.go @@ -0,0 +1,26 @@ +package certificateordersdiagnostics + +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 CertificateOrdersDiagnosticsClient struct { + Client *resourcemanager.Client +} + +func NewCertificateOrdersDiagnosticsClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificateOrdersDiagnosticsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "certificateordersdiagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateOrdersDiagnosticsClient: %+v", err) + } + + return &CertificateOrdersDiagnosticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/constants.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/constants.go new file mode 100644 index 00000000000..5a46c7d7aeb --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/constants.go @@ -0,0 +1,214 @@ +package certificateordersdiagnostics + +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 DetectorType string + +const ( + DetectorTypeAnalysis DetectorType = "Analysis" + DetectorTypeCategoryOverview DetectorType = "CategoryOverview" + DetectorTypeDetector DetectorType = "Detector" +) + +func PossibleValuesForDetectorType() []string { + return []string{ + string(DetectorTypeAnalysis), + string(DetectorTypeCategoryOverview), + string(DetectorTypeDetector), + } +} + +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDetectorType(input string) (*DetectorType, error) { + vals := map[string]DetectorType{ + "analysis": DetectorTypeAnalysis, + "categoryoverview": DetectorTypeCategoryOverview, + "detector": DetectorTypeDetector, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DetectorType(input) + return &out, nil +} + +type InsightStatus string + +const ( + InsightStatusCritical InsightStatus = "Critical" + InsightStatusInfo InsightStatus = "Info" + InsightStatusNone InsightStatus = "None" + InsightStatusSuccess InsightStatus = "Success" + InsightStatusWarning InsightStatus = "Warning" +) + +func PossibleValuesForInsightStatus() []string { + return []string{ + string(InsightStatusCritical), + string(InsightStatusInfo), + string(InsightStatusNone), + string(InsightStatusSuccess), + string(InsightStatusWarning), + } +} + +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInsightStatus(input string) (*InsightStatus, error) { + vals := map[string]InsightStatus{ + "critical": InsightStatusCritical, + "info": InsightStatusInfo, + "none": InsightStatusNone, + "success": InsightStatusSuccess, + "warning": InsightStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InsightStatus(input) + return &out, nil +} + +type RenderingType string + +const ( + RenderingTypeAppInsight RenderingType = "AppInsight" + RenderingTypeAppInsightEnablement RenderingType = "AppInsightEnablement" + RenderingTypeCard RenderingType = "Card" + RenderingTypeChangeAnalysisOnboarding RenderingType = "ChangeAnalysisOnboarding" + RenderingTypeChangeSets RenderingType = "ChangeSets" + RenderingTypeChangesView RenderingType = "ChangesView" + RenderingTypeDataSummary RenderingType = "DataSummary" + RenderingTypeDependencyGraph RenderingType = "DependencyGraph" + RenderingTypeDetector RenderingType = "Detector" + RenderingTypeDownTime RenderingType = "DownTime" + RenderingTypeDropDown RenderingType = "DropDown" + RenderingTypeDynamicInsight RenderingType = "DynamicInsight" + RenderingTypeEmail RenderingType = "Email" + RenderingTypeForm RenderingType = "Form" + RenderingTypeGuage RenderingType = "Guage" + RenderingTypeInsights RenderingType = "Insights" + RenderingTypeMarkdown RenderingType = "Markdown" + RenderingTypeNoGraph RenderingType = "NoGraph" + RenderingTypePieChart RenderingType = "PieChart" + RenderingTypeSearchComponent RenderingType = "SearchComponent" + RenderingTypeSolution RenderingType = "Solution" + RenderingTypeSummaryCard RenderingType = "SummaryCard" + RenderingTypeTable RenderingType = "Table" + RenderingTypeTimeSeries RenderingType = "TimeSeries" + RenderingTypeTimeSeriesPerInstance RenderingType = "TimeSeriesPerInstance" +) + +func PossibleValuesForRenderingType() []string { + return []string{ + string(RenderingTypeAppInsight), + string(RenderingTypeAppInsightEnablement), + string(RenderingTypeCard), + string(RenderingTypeChangeAnalysisOnboarding), + string(RenderingTypeChangeSets), + string(RenderingTypeChangesView), + string(RenderingTypeDataSummary), + string(RenderingTypeDependencyGraph), + string(RenderingTypeDetector), + string(RenderingTypeDownTime), + string(RenderingTypeDropDown), + string(RenderingTypeDynamicInsight), + string(RenderingTypeEmail), + string(RenderingTypeForm), + string(RenderingTypeGuage), + string(RenderingTypeInsights), + string(RenderingTypeMarkdown), + string(RenderingTypeNoGraph), + string(RenderingTypePieChart), + string(RenderingTypeSearchComponent), + string(RenderingTypeSolution), + string(RenderingTypeSummaryCard), + string(RenderingTypeTable), + string(RenderingTypeTimeSeries), + string(RenderingTypeTimeSeriesPerInstance), + } +} + +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRenderingType(input string) (*RenderingType, error) { + vals := map[string]RenderingType{ + "appinsight": RenderingTypeAppInsight, + "appinsightenablement": RenderingTypeAppInsightEnablement, + "card": RenderingTypeCard, + "changeanalysisonboarding": RenderingTypeChangeAnalysisOnboarding, + "changesets": RenderingTypeChangeSets, + "changesview": RenderingTypeChangesView, + "datasummary": RenderingTypeDataSummary, + "dependencygraph": RenderingTypeDependencyGraph, + "detector": RenderingTypeDetector, + "downtime": RenderingTypeDownTime, + "dropdown": RenderingTypeDropDown, + "dynamicinsight": RenderingTypeDynamicInsight, + "email": RenderingTypeEmail, + "form": RenderingTypeForm, + "guage": RenderingTypeGuage, + "insights": RenderingTypeInsights, + "markdown": RenderingTypeMarkdown, + "nograph": RenderingTypeNoGraph, + "piechart": RenderingTypePieChart, + "searchcomponent": RenderingTypeSearchComponent, + "solution": RenderingTypeSolution, + "summarycard": RenderingTypeSummaryCard, + "table": RenderingTypeTable, + "timeseries": RenderingTypeTimeSeries, + "timeseriesperinstance": RenderingTypeTimeSeriesPerInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RenderingType(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder.go new file mode 100644 index 00000000000..050fa6199a7 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder.go @@ -0,0 +1,130 @@ +package certificateordersdiagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(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 := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderValue"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder_test.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder_test.go new file mode 100644 index 00000000000..7722b12c80b --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_certificateorder_test.go @@ -0,0 +1,282 @@ +package certificateordersdiagnostics + +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 = &CertificateOrderId{} + +func TestNewCertificateOrderID(t *testing.T) { + id := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue") + + 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.CertificateOrderName != "certificateOrderValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderValue") + } +} + +func TestFormatCertificateOrderID(t *testing.T) { + actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestParseCertificateOrderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRvAlUe", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestSegmentsForCertificateOrderId(t *testing.T) { + segments := CertificateOrderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderId 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/web/2023-12-01/certificateordersdiagnostics/id_detector.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_detector.go new file mode 100644 index 00000000000..fe633a846ad --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_detector.go @@ -0,0 +1,139 @@ +package certificateordersdiagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DetectorId{}) +} + +var _ resourceids.ResourceId = &DetectorId{} + +// DetectorId is a struct representing the Resource ID for a Detector +type DetectorId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string + DetectorName string +} + +// NewDetectorID returns a new DetectorId struct +func NewDetectorID(subscriptionId string, resourceGroupName string, certificateOrderName string, detectorName string) DetectorId { + return DetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + DetectorName: detectorName, + } +} + +// ParseDetectorID parses 'input' into a DetectorId +func ParseDetectorID(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorIDInsensitively parses 'input' case-insensitively into a DetectorId +// note: this method should only be used for API response data and not user input +func ParseDetectorIDInsensitively(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorId) 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.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDetectorID checks that 'input' can be parsed as a Detector ID +func ValidateDetectorID(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 := ParseDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector ID +func (id DetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector ID +func (id DetectorId) 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("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Detector ID +func (id DetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_detector_test.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_detector_test.go new file mode 100644 index 00000000000..1e94040c1cc --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/id_detector_test.go @@ -0,0 +1,327 @@ +package certificateordersdiagnostics + +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 = &DetectorId{} + +func TestNewDetectorID(t *testing.T) { + id := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "detectorValue") + + 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.CertificateOrderName != "certificateOrderValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatDetectorID(t *testing.T) { + actual := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDetectorId(t *testing.T) { + segments := DetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorId 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/web/2023-12-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..43f26d37c36 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go @@ -0,0 +1,91 @@ +package certificateordersdiagnostics + +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 GetAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetAppServiceCertificateOrderDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions() GetAppServiceCertificateOrderDetectorResponseOperationOptions { + return GetAppServiceCertificateOrderDetectorResponseOperationOptions{} +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) GetAppServiceCertificateOrderDetectorResponse(ctx context.Context, id DetectorId, options GetAppServiceCertificateOrderDetectorResponseOperationOptions) (result GetAppServiceCertificateOrderDetectorResponseOperationResponse, 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 + } + + var model DetectorResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..31ea7f6b5bc --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go @@ -0,0 +1,91 @@ +package certificateordersdiagnostics + +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 ListAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListAppServiceCertificateOrderDetectorResponseCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +// ListAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderId) (result ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServiceCertificateOrderDetectorResponseComplete retrieves all the results into a single object +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseComplete(ctx context.Context, id CertificateOrderId) (ListAppServiceCertificateOrderDetectorResponseCompleteResult, error) { + return c.ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate DetectorResponseOperationPredicate) (result ListAppServiceCertificateOrderDetectorResponseCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListAppServiceCertificateOrderDetectorResponse(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 = ListAppServiceCertificateOrderDetectorResponseCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_dataprovidermetadata.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_dataprovidermetadata.go new file mode 100644 index 00000000000..3ca232e10ea --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_dataprovidermetadata.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProviderMetadata struct { + PropertyBag *[]KeyValuePairStringObject `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponsecolumn.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponsecolumn.go new file mode 100644 index 00000000000..94b13b9f1d3 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponsecolumn.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponseobject.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponseobject.go new file mode 100644 index 00000000000..0736e54ba5f --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_datatableresponseobject.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseObject struct { + Columns *[]DataTableResponseColumn `json:"columns,omitempty"` + Rows *[][]string `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorinfo.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorinfo.go new file mode 100644 index 00000000000..792b0133a14 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorinfo.go @@ -0,0 +1,16 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorInfo struct { + AnalysisType *[]string `json:"analysisType,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]SupportTopic `json:"supportTopicList,omitempty"` + Type *DetectorType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponse.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponse.go new file mode 100644 index 00000000000..8947d24dc8b --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponse.go @@ -0,0 +1,12 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponseproperties.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponseproperties.go new file mode 100644 index 00000000000..409f708d65f --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_detectorresponseproperties.go @@ -0,0 +1,12 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseProperties struct { + DataProvidersMetadata *[]DataProviderMetadata `json:"dataProvidersMetadata,omitempty"` + Dataset *[]DiagnosticData `json:"dataset,omitempty"` + Metadata *DetectorInfo `json:"metadata,omitempty"` + Status *Status `json:"status,omitempty"` + SuggestedUtterances *QueryUtterancesResults `json:"suggestedUtterances,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_diagnosticdata.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_diagnosticdata.go new file mode 100644 index 00000000000..23d24043011 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_diagnosticdata.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticData struct { + RenderingProperties *Rendering `json:"renderingProperties,omitempty"` + Table *DataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go new file mode 100644 index 00000000000..ebad30fedc1 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyValuePairStringObject struct { + Key *string `json:"key,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresult.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresult.go new file mode 100644 index 00000000000..6c29753e795 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresult.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResult struct { + SampleUtterance *SampleUtterance `json:"sampleUtterance,omitempty"` + Score *float64 `json:"score,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresults.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresults.go new file mode 100644 index 00000000000..c2120a0ebfd --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_queryutterancesresults.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResults struct { + Query *string `json:"query,omitempty"` + Results *[]QueryUtterancesResult `json:"results,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_rendering.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_rendering.go new file mode 100644 index 00000000000..c488d4de11e --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_rendering.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rendering struct { + Description *string `json:"description,omitempty"` + Title *string `json:"title,omitempty"` + Type *RenderingType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_sampleutterance.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_sampleutterance.go new file mode 100644 index 00000000000..648bd768413 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_sampleutterance.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SampleUtterance struct { + Links *[]string `json:"links,omitempty"` + Qid *string `json:"qid,omitempty"` + Text *string `json:"text,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_status.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_status.go new file mode 100644 index 00000000000..87558b9b81c --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_status.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Status struct { + Message *string `json:"message,omitempty"` + StatusId *InsightStatus `json:"statusId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_supporttopic.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_supporttopic.go new file mode 100644 index 00000000000..cb170a8c08b --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/model_supporttopic.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificateordersdiagnostics/predicates.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/predicates.go new file mode 100644 index 00000000000..149b9af0e1c --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/predicates.go @@ -0,0 +1,32 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorResponseOperationPredicate) Matches(input DetectorResponse) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/certificateordersdiagnostics/version.go b/resource-manager/web/2023-12-01/certificateordersdiagnostics/version.go new file mode 100644 index 00000000000..393ab2dfb9c --- /dev/null +++ b/resource-manager/web/2023-12-01/certificateordersdiagnostics/version.go @@ -0,0 +1,12 @@ +package certificateordersdiagnostics + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/certificateordersdiagnostics/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/certificates/README.md b/resource-manager/web/2023-12-01/certificates/README.md new file mode 100644 index 00000000000..13a439c3632 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates` Documentation + +The `certificates` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" +``` + + +### Client Initialization + +```go +client := certificates.NewCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificatesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateValue") + +payload := certificates.Certificate{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Delete` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Get` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateValue") + +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: `CertificatesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, certificates.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, certificates.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.Update` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateValue") + +payload := certificates.CertificatePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2023-12-01/certificates/client.go b/resource-manager/web/2023-12-01/certificates/client.go new file mode 100644 index 00000000000..7248daeda34 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/client.go @@ -0,0 +1,26 @@ +package certificates + +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 CertificatesClient struct { + Client *resourcemanager.Client +} + +func NewCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificatesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "certificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificatesClient: %+v", err) + } + + return &CertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/certificates/constants.go b/resource-manager/web/2023-12-01/certificates/constants.go new file mode 100644 index 00000000000..afe3445c7e6 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/constants.go @@ -0,0 +1,78 @@ +package certificates + +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 KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/certificates/id_certificate.go b/resource-manager/web/2023-12-01/certificates/id_certificate.go new file mode 100644 index 00000000000..24c9696e478 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/id_certificate.go @@ -0,0 +1,130 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateValue"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/certificates/id_certificate_test.go b/resource-manager/web/2023-12-01/certificates/id_certificate_test.go new file mode 100644 index 00000000000..2ac4a83cd1b --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/id_certificate_test.go @@ -0,0 +1,282 @@ +package certificates + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateValue") + + 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.CertificateName != "certificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateValue") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateValue", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateName: "certificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cErTiFiCaTeS/cErTiFiCaTeVaLuE", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateName: "cErTiFiCaTeVaLuE", + }, + }, + { + // 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.wEb/cErTiFiCaTeS/cErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2023-12-01/certificates/method_createorupdate.go b/resource-manager/web/2023-12-01/certificates/method_createorupdate.go new file mode 100644 index 00000000000..dd5b06bc250 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/method_createorupdate.go @@ -0,0 +1,58 @@ +package certificates + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CreateOrUpdate ... +func (c CertificatesClient) CreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/certificates/method_delete.go b/resource-manager/web/2023-12-01/certificates/method_delete.go new file mode 100644 index 00000000000..6f676ff9031 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/method_delete.go @@ -0,0 +1,47 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CertificatesClient) Delete(ctx context.Context, id CertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/certificates/method_get.go b/resource-manager/web/2023-12-01/certificates/method_get.go new file mode 100644 index 00000000000..339126ffd6a --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/method_get.go @@ -0,0 +1,54 @@ +package certificates + +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 *Certificate +} + +// Get ... +func (c CertificatesClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/certificates/method_list.go b/resource-manager/web/2023-12-01/certificates/method_list.go new file mode 100644 index 00000000000..291d0b5accc --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/method_list.go @@ -0,0 +1,120 @@ +package certificates + +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 *[]Certificate +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +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 CertificatesClient) List(ctx context.Context, id commonids.SubscriptionId, 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/providers/Microsoft.Web/certificates", 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 *[]Certificate `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 CertificatesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, CertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate CertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Certificate, 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/web/2023-12-01/certificates/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/certificates/method_listbyresourcegroup.go new file mode 100644 index 00000000000..30b0cd035e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +// ListByResourceGroup ... +func (c CertificatesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", 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 *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CertificatesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CertificateOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/certificates/method_update.go b/resource-manager/web/2023-12-01/certificates/method_update.go new file mode 100644 index 00000000000..038cd440dd0 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/method_update.go @@ -0,0 +1,58 @@ +package certificates + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Update ... +func (c CertificatesClient) Update(ctx context.Context, id CertificateId, input CertificatePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Certificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/certificates/model_certificate.go b/resource-manager/web/2023-12-01/certificates/model_certificate.go new file mode 100644 index 00000000000..354c3cbb53b --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/model_certificate.go @@ -0,0 +1,14 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go b/resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go new file mode 100644 index 00000000000..ad7a39f39b2 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/model_certificatepatchresource.go @@ -0,0 +1,12 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificatePatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go b/resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go new file mode 100644 index 00000000000..a3aec635456 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/model_certificatepatchresourceproperties.go @@ -0,0 +1,58 @@ +package certificates + +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 CertificatePatchResourceProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificatePatchResourceProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificatePatchResourceProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2023-12-01/certificates/model_certificateproperties.go b/resource-manager/web/2023-12-01/certificates/model_certificateproperties.go new file mode 100644 index 00000000000..0d950ddcd12 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/model_certificateproperties.go @@ -0,0 +1,58 @@ +package certificates + +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 CertificateProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go b/resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..33ed6c863f8 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/certificates/predicates.go b/resource-manager/web/2023-12-01/certificates/predicates.go new file mode 100644 index 00000000000..6a9b6eaebc6 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/predicates.go @@ -0,0 +1,37 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2023-12-01/certificates/version.go b/resource-manager/web/2023-12-01/certificates/version.go new file mode 100644 index 00000000000..8e7abe38127 --- /dev/null +++ b/resource-manager/web/2023-12-01/certificates/version.go @@ -0,0 +1,12 @@ +package certificates + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/certificates/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/client.go b/resource-manager/web/2023-12-01/client.go new file mode 100644 index 00000000000..b4fbfe631ea --- /dev/null +++ b/resource-manager/web/2023-12-01/client.go @@ -0,0 +1,244 @@ +package v2023_12_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/web/2023-12-01/appservicecertificateorders" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/appserviceplans" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificateordersdiagnostics" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/containerapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/containerappsrevisions" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/deletedwebapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/diagnostics" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/domains" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/global" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/kubeenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/provider" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/recommendations" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/resourcehealthmetadata" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/resourceproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/staticsites" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/topleveldomains" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowrunactions" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowruns" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflows" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowtriggerhistories" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowtriggers" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowversions" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AppServiceCertificateOrders *appservicecertificateorders.AppServiceCertificateOrdersClient + AppServiceEnvironments *appserviceenvironments.AppServiceEnvironmentsClient + AppServicePlans *appserviceplans.AppServicePlansClient + CertificateOrdersDiagnostics *certificateordersdiagnostics.CertificateOrdersDiagnosticsClient + Certificates *certificates.CertificatesClient + ContainerApps *containerapps.ContainerAppsClient + ContainerAppsRevisions *containerappsrevisions.ContainerAppsRevisionsClient + DeletedWebApps *deletedwebapps.DeletedWebAppsClient + Diagnostics *diagnostics.DiagnosticsClient + Domains *domains.DomainsClient + Global *global.GlobalClient + KubeEnvironments *kubeenvironments.KubeEnvironmentsClient + Provider *provider.ProviderClient + Recommendations *recommendations.RecommendationsClient + ResourceHealthMetadata *resourcehealthmetadata.ResourceHealthMetadataClient + ResourceProviders *resourceproviders.ResourceProvidersClient + StaticSites *staticsites.StaticSitesClient + TopLevelDomains *topleveldomains.TopLevelDomainsClient + WebApps *webapps.WebAppsClient + WorkflowRunActions *workflowrunactions.WorkflowRunActionsClient + WorkflowRuns *workflowruns.WorkflowRunsClient + WorkflowTriggerHistories *workflowtriggerhistories.WorkflowTriggerHistoriesClient + WorkflowTriggers *workflowtriggers.WorkflowTriggersClient + WorkflowVersions *workflowversions.WorkflowVersionsClient + Workflows *workflows.WorkflowsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + appServiceCertificateOrdersClient, err := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServiceCertificateOrders client: %+v", err) + } + configureFunc(appServiceCertificateOrdersClient.Client) + + appServiceEnvironmentsClient, err := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServiceEnvironments client: %+v", err) + } + configureFunc(appServiceEnvironmentsClient.Client) + + appServicePlansClient, err := appserviceplans.NewAppServicePlansClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServicePlans client: %+v", err) + } + configureFunc(appServicePlansClient.Client) + + certificateOrdersDiagnosticsClient, err := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CertificateOrdersDiagnostics client: %+v", err) + } + configureFunc(certificateOrdersDiagnosticsClient.Client) + + certificatesClient, err := certificates.NewCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Certificates client: %+v", err) + } + configureFunc(certificatesClient.Client) + + containerAppsClient, err := containerapps.NewContainerAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerApps client: %+v", err) + } + configureFunc(containerAppsClient.Client) + + containerAppsRevisionsClient, err := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ContainerAppsRevisions client: %+v", err) + } + configureFunc(containerAppsRevisionsClient.Client) + + deletedWebAppsClient, err := deletedwebapps.NewDeletedWebAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DeletedWebApps client: %+v", err) + } + configureFunc(deletedWebAppsClient.Client) + + diagnosticsClient, err := diagnostics.NewDiagnosticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Diagnostics client: %+v", err) + } + configureFunc(diagnosticsClient.Client) + + domainsClient, err := domains.NewDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Domains client: %+v", err) + } + configureFunc(domainsClient.Client) + + globalClient, err := global.NewGlobalClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Global client: %+v", err) + } + configureFunc(globalClient.Client) + + kubeEnvironmentsClient, err := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building KubeEnvironments client: %+v", err) + } + configureFunc(kubeEnvironmentsClient.Client) + + providerClient, err := provider.NewProviderClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Provider client: %+v", err) + } + configureFunc(providerClient.Client) + + recommendationsClient, err := recommendations.NewRecommendationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Recommendations client: %+v", err) + } + configureFunc(recommendationsClient.Client) + + resourceHealthMetadataClient, err := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceHealthMetadata client: %+v", err) + } + configureFunc(resourceHealthMetadataClient.Client) + + resourceProvidersClient, err := resourceproviders.NewResourceProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceProviders client: %+v", err) + } + configureFunc(resourceProvidersClient.Client) + + staticSitesClient, err := staticsites.NewStaticSitesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StaticSites client: %+v", err) + } + configureFunc(staticSitesClient.Client) + + topLevelDomainsClient, err := topleveldomains.NewTopLevelDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TopLevelDomains client: %+v", err) + } + configureFunc(topLevelDomainsClient.Client) + + webAppsClient, err := webapps.NewWebAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebApps client: %+v", err) + } + configureFunc(webAppsClient.Client) + + workflowRunActionsClient, err := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowRunActions client: %+v", err) + } + configureFunc(workflowRunActionsClient.Client) + + workflowRunsClient, err := workflowruns.NewWorkflowRunsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowRuns client: %+v", err) + } + configureFunc(workflowRunsClient.Client) + + workflowTriggerHistoriesClient, err := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggerHistories client: %+v", err) + } + configureFunc(workflowTriggerHistoriesClient.Client) + + workflowTriggersClient, err := workflowtriggers.NewWorkflowTriggersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggers client: %+v", err) + } + configureFunc(workflowTriggersClient.Client) + + workflowVersionsClient, err := workflowversions.NewWorkflowVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowVersions client: %+v", err) + } + configureFunc(workflowVersionsClient.Client) + + workflowsClient, err := workflows.NewWorkflowsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Workflows client: %+v", err) + } + configureFunc(workflowsClient.Client) + + return &Client{ + AppServiceCertificateOrders: appServiceCertificateOrdersClient, + AppServiceEnvironments: appServiceEnvironmentsClient, + AppServicePlans: appServicePlansClient, + CertificateOrdersDiagnostics: certificateOrdersDiagnosticsClient, + Certificates: certificatesClient, + ContainerApps: containerAppsClient, + ContainerAppsRevisions: containerAppsRevisionsClient, + DeletedWebApps: deletedWebAppsClient, + Diagnostics: diagnosticsClient, + Domains: domainsClient, + Global: globalClient, + KubeEnvironments: kubeEnvironmentsClient, + Provider: providerClient, + Recommendations: recommendationsClient, + ResourceHealthMetadata: resourceHealthMetadataClient, + ResourceProviders: resourceProvidersClient, + StaticSites: staticSitesClient, + TopLevelDomains: topLevelDomainsClient, + WebApps: webAppsClient, + WorkflowRunActions: workflowRunActionsClient, + WorkflowRuns: workflowRunsClient, + WorkflowTriggerHistories: workflowTriggerHistoriesClient, + WorkflowTriggers: workflowTriggersClient, + WorkflowVersions: workflowVersionsClient, + Workflows: workflowsClient, + }, nil +} diff --git a/resource-manager/web/2023-12-01/containerapps/README.md b/resource-manager/web/2023-12-01/containerapps/README.md new file mode 100644 index 00000000000..b302a1d2e09 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/README.md @@ -0,0 +1,116 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/containerapps` Documentation + +The `containerapps` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/containerapps" +``` + + +### Client Initialization + +```go +client := containerapps.NewContainerAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := containerapps.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +payload := containerapps.ContainerApp{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.Delete` + +```go +ctx := context.TODO() +id := containerapps.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ContainerAppsClient.Get` + +```go +ctx := context.TODO() +id := containerapps.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +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: `ContainerAppsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsClient.ListSecrets` + +```go +ctx := context.TODO() +id := containerapps.NewContainerAppID("12345678-1234-9876-4563-123456789012", "containerAppValue") + +read, err := client.ListSecrets(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/web/2023-12-01/containerapps/client.go b/resource-manager/web/2023-12-01/containerapps/client.go new file mode 100644 index 00000000000..65599ae354f --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/client.go @@ -0,0 +1,26 @@ +package containerapps + +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 ContainerAppsClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsClient: %+v", err) + } + + return &ContainerAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/containerapps/constants.go b/resource-manager/web/2023-12-01/containerapps/constants.go new file mode 100644 index 00000000000..f6e8265656f --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/constants.go @@ -0,0 +1,142 @@ +package containerapps + +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 ActiveRevisionsMode string + +const ( + ActiveRevisionsModeMultiple ActiveRevisionsMode = "multiple" + ActiveRevisionsModeSingle ActiveRevisionsMode = "single" +) + +func PossibleValuesForActiveRevisionsMode() []string { + return []string{ + string(ActiveRevisionsModeMultiple), + string(ActiveRevisionsModeSingle), + } +} + +func (s *ActiveRevisionsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActiveRevisionsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActiveRevisionsMode(input string) (*ActiveRevisionsMode, error) { + vals := map[string]ActiveRevisionsMode{ + "multiple": ActiveRevisionsModeMultiple, + "single": ActiveRevisionsModeSingle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActiveRevisionsMode(input) + return &out, nil +} + +type ContainerAppProvisioningState string + +const ( + ContainerAppProvisioningStateCanceled ContainerAppProvisioningState = "Canceled" + ContainerAppProvisioningStateFailed ContainerAppProvisioningState = "Failed" + ContainerAppProvisioningStateInProgress ContainerAppProvisioningState = "InProgress" + ContainerAppProvisioningStateSucceeded ContainerAppProvisioningState = "Succeeded" +) + +func PossibleValuesForContainerAppProvisioningState() []string { + return []string{ + string(ContainerAppProvisioningStateCanceled), + string(ContainerAppProvisioningStateFailed), + string(ContainerAppProvisioningStateInProgress), + string(ContainerAppProvisioningStateSucceeded), + } +} + +func (s *ContainerAppProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerAppProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerAppProvisioningState(input string) (*ContainerAppProvisioningState, error) { + vals := map[string]ContainerAppProvisioningState{ + "canceled": ContainerAppProvisioningStateCanceled, + "failed": ContainerAppProvisioningStateFailed, + "inprogress": ContainerAppProvisioningStateInProgress, + "succeeded": ContainerAppProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerAppProvisioningState(input) + return &out, nil +} + +type IngressTransportMethod string + +const ( + IngressTransportMethodAuto IngressTransportMethod = "auto" + IngressTransportMethodHTTP IngressTransportMethod = "http" + IngressTransportMethodHTTPTwo IngressTransportMethod = "http2" +) + +func PossibleValuesForIngressTransportMethod() []string { + return []string{ + string(IngressTransportMethodAuto), + string(IngressTransportMethodHTTP), + string(IngressTransportMethodHTTPTwo), + } +} + +func (s *IngressTransportMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIngressTransportMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIngressTransportMethod(input string) (*IngressTransportMethod, error) { + vals := map[string]IngressTransportMethod{ + "auto": IngressTransportMethodAuto, + "http": IngressTransportMethodHTTP, + "http2": IngressTransportMethodHTTPTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IngressTransportMethod(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/containerapps/id_containerapp.go b/resource-manager/web/2023-12-01/containerapps/id_containerapp.go new file mode 100644 index 00000000000..c7991c1dbc4 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/id_containerapp.go @@ -0,0 +1,121 @@ +package containerapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContainerAppId{}) +} + +var _ resourceids.ResourceId = &ContainerAppId{} + +// ContainerAppId is a struct representing the Resource ID for a Container App +type ContainerAppId struct { + SubscriptionId string + ContainerAppName string +} + +// NewContainerAppID returns a new ContainerAppId struct +func NewContainerAppID(subscriptionId string, containerAppName string) ContainerAppId { + return ContainerAppId{ + SubscriptionId: subscriptionId, + ContainerAppName: containerAppName, + } +} + +// ParseContainerAppID parses 'input' into a ContainerAppId +func ParseContainerAppID(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContainerAppIDInsensitively parses 'input' case-insensitively into a ContainerAppId +// note: this method should only be used for API response data and not user input +func ParseContainerAppIDInsensitively(input string) (*ContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContainerAppId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateContainerAppID checks that 'input' can be parsed as a Container App ID +func ValidateContainerAppID(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 := ParseContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Container App ID +func (id ContainerAppId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Container App ID +func (id ContainerAppId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Container App ID +func (id ContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/containerapps/id_containerapp_test.go b/resource-manager/web/2023-12-01/containerapps/id_containerapp_test.go new file mode 100644 index 00000000000..808e6952274 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/id_containerapp_test.go @@ -0,0 +1,237 @@ +package containerapps + +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 = &ContainerAppId{} + +func TestNewContainerAppID(t *testing.T) { + id := NewContainerAppID("12345678-1234-9876-4563-123456789012", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatContainerAppID(t *testing.T) { + actual := NewContainerAppID("12345678-1234-9876-4563-123456789012", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContainerAppId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppValue", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForContainerAppId(t *testing.T) { + segments := ContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContainerAppId 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/web/2023-12-01/containerapps/id_providercontainerapp.go b/resource-manager/web/2023-12-01/containerapps/id_providercontainerapp.go new file mode 100644 index 00000000000..6493d543e2b --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/id_providercontainerapp.go @@ -0,0 +1,130 @@ +package containerapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderContainerAppId{}) +} + +var _ resourceids.ResourceId = &ProviderContainerAppId{} + +// ProviderContainerAppId is a struct representing the Resource ID for a Provider Container App +type ProviderContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewProviderContainerAppID returns a new ProviderContainerAppId struct +func NewProviderContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ProviderContainerAppId { + return ProviderContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseProviderContainerAppID parses 'input' into a ProviderContainerAppId +func ParseProviderContainerAppID(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderContainerAppIDInsensitively parses 'input' case-insensitively into a ProviderContainerAppId +// note: this method should only be used for API response data and not user input +func ParseProviderContainerAppIDInsensitively(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateProviderContainerAppID checks that 'input' can be parsed as a Provider Container App ID +func ValidateProviderContainerAppID(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 := ParseProviderContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Container App ID +func (id ProviderContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Container App ID +func (id ProviderContainerAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Provider Container App ID +func (id ProviderContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Provider Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/containerapps/id_providercontainerapp_test.go b/resource-manager/web/2023-12-01/containerapps/id_providercontainerapp_test.go new file mode 100644 index 00000000000..e8077df9e15 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/id_providercontainerapp_test.go @@ -0,0 +1,282 @@ +package containerapps + +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 = &ProviderContainerAppId{} + +func TestNewProviderContainerAppID(t *testing.T) { + id := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatProviderContainerAppID(t *testing.T) { + actual := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseProviderContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // 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.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForProviderContainerAppId(t *testing.T) { + segments := ProviderContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderContainerAppId 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/web/2023-12-01/containerapps/method_createorupdate.go b/resource-manager/web/2023-12-01/containerapps/method_createorupdate.go new file mode 100644 index 00000000000..606408a054d --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/method_createorupdate.go @@ -0,0 +1,75 @@ +package containerapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ContainerApp +} + +// CreateOrUpdate ... +func (c ContainerAppsClient) CreateOrUpdate(ctx context.Context, id ProviderContainerAppId, input ContainerApp) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ContainerAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id ProviderContainerAppId, input ContainerApp) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/containerapps/method_delete.go b/resource-manager/web/2023-12-01/containerapps/method_delete.go new file mode 100644 index 00000000000..6cdd45058e6 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/method_delete.go @@ -0,0 +1,71 @@ +package containerapps + +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 ContainerAppsClient) Delete(ctx context.Context, id ProviderContainerAppId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 ContainerAppsClient) DeleteThenPoll(ctx context.Context, id ProviderContainerAppId) 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/web/2023-12-01/containerapps/method_get.go b/resource-manager/web/2023-12-01/containerapps/method_get.go new file mode 100644 index 00000000000..def3a75c5e8 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/method_get.go @@ -0,0 +1,54 @@ +package containerapps + +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 *ContainerApp +} + +// Get ... +func (c ContainerAppsClient) Get(ctx context.Context, id ProviderContainerAppId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContainerApp + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/containerapps/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/containerapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..49f9df32335 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package containerapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContainerApp +} + +// ListByResourceGroup ... +func (c ContainerAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", 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 *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ContainerAppOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/containerapps/method_listbysubscription.go b/resource-manager/web/2023-12-01/containerapps/method_listbysubscription.go new file mode 100644 index 00000000000..f8c0f30fef4 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/method_listbysubscription.go @@ -0,0 +1,92 @@ +package containerapps + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContainerApp +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContainerApp +} + +// ListBySubscription ... +func (c ContainerAppsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/containerApps", 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 *[]ContainerApp `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c ContainerAppsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, ContainerAppOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ContainerAppOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]ContainerApp, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/containerapps/method_listsecrets.go b/resource-manager/web/2023-12-01/containerapps/method_listsecrets.go new file mode 100644 index 00000000000..2981767594f --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/method_listsecrets.go @@ -0,0 +1,55 @@ +package containerapps + +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 ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecretsCollection +} + +// ListSecrets ... +func (c ContainerAppsClient) ListSecrets(ctx context.Context, id ContainerAppId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecretsCollection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_configuration.go b/resource-manager/web/2023-12-01/containerapps/model_configuration.go new file mode 100644 index 00000000000..b4b5ca6c61f --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_configuration.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Configuration struct { + ActiveRevisionsMode *ActiveRevisionsMode `json:"activeRevisionsMode,omitempty"` + Ingress *Ingress `json:"ingress,omitempty"` + Registries *[]RegistryCredentials `json:"registries,omitempty"` + Secrets *[]Secret `json:"secrets,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_container.go b/resource-manager/web/2023-12-01/containerapps/model_container.go new file mode 100644 index 00000000000..c0f124d72bb --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_container.go @@ -0,0 +1,13 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_containerapp.go b/resource-manager/web/2023-12-01/containerapps/model_containerapp.go new file mode 100644 index 00000000000..51cd1800cce --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_containerapp.go @@ -0,0 +1,14 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerApp struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ContainerAppProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_containerappproperties.go b/resource-manager/web/2023-12-01/containerapps/model_containerappproperties.go new file mode 100644 index 00000000000..e0a892de046 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_containerappproperties.go @@ -0,0 +1,13 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppProperties struct { + Configuration *Configuration `json:"configuration,omitempty"` + KubeEnvironmentId *string `json:"kubeEnvironmentId,omitempty"` + LatestRevisionFqdn *string `json:"latestRevisionFqdn,omitempty"` + LatestRevisionName *string `json:"latestRevisionName,omitempty"` + ProvisioningState *ContainerAppProvisioningState `json:"provisioningState,omitempty"` + Template *Template `json:"template,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_containerappsecret.go b/resource-manager/web/2023-12-01/containerapps/model_containerappsecret.go new file mode 100644 index 00000000000..a2ca83f001b --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_containerappsecret.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppSecret struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_containerresources.go b/resource-manager/web/2023-12-01/containerapps/model_containerresources.go new file mode 100644 index 00000000000..5ce6649a3f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_containerresources.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_customscalerule.go b/resource-manager/web/2023-12-01/containerapps/model_customscalerule.go new file mode 100644 index 00000000000..6b51d48a3e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_customscalerule.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_dapr.go b/resource-manager/web/2023-12-01/containerapps/model_dapr.go new file mode 100644 index 00000000000..f00ddc94ea1 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_dapr.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dapr struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + Components *[]DaprComponent `json:"components,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_daprcomponent.go b/resource-manager/web/2023-12-01/containerapps/model_daprcomponent.go new file mode 100644 index 00000000000..fafbbaa3a5c --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_daprcomponent.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprComponent struct { + Metadata *[]DaprMetadata `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_daprmetadata.go b/resource-manager/web/2023-12-01/containerapps/model_daprmetadata.go new file mode 100644 index 00000000000..9e86a8f6bf3 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_daprmetadata.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprMetadata struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_environmentvar.go b/resource-manager/web/2023-12-01/containerapps/model_environmentvar.go new file mode 100644 index 00000000000..e25ec6c8bc8 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_environmentvar.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_httpscalerule.go b/resource-manager/web/2023-12-01/containerapps/model_httpscalerule.go new file mode 100644 index 00000000000..429b7ee2303 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_httpscalerule.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_ingress.go b/resource-manager/web/2023-12-01/containerapps/model_ingress.go new file mode 100644 index 00000000000..a36b7a2cb83 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_ingress.go @@ -0,0 +1,13 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Ingress struct { + AllowInsecure *bool `json:"allowInsecure,omitempty"` + External *bool `json:"external,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + TargetPort *int64 `json:"targetPort,omitempty"` + Traffic *[]TrafficWeight `json:"traffic,omitempty"` + Transport *IngressTransportMethod `json:"transport,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_queuescalerule.go b/resource-manager/web/2023-12-01/containerapps/model_queuescalerule.go new file mode 100644 index 00000000000..b8cbc96d3a0 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_queuescalerule.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + QueueLength *int64 `json:"queueLength,omitempty"` + QueueName *string `json:"queueName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_registrycredentials.go b/resource-manager/web/2023-12-01/containerapps/model_registrycredentials.go new file mode 100644 index 00000000000..1931c41d6e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_registrycredentials.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCredentials struct { + PasswordSecretRef *string `json:"passwordSecretRef,omitempty"` + Server *string `json:"server,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_scale.go b/resource-manager/web/2023-12-01/containerapps/model_scale.go new file mode 100644 index 00000000000..a8f54d89b3f --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_scale.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Scale struct { + MaxReplicas *int64 `json:"maxReplicas,omitempty"` + MinReplicas *int64 `json:"minReplicas,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_scalerule.go b/resource-manager/web/2023-12-01/containerapps/model_scalerule.go new file mode 100644 index 00000000000..4fc43100461 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_scalerule.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRule struct { + AzureQueue *QueueScaleRule `json:"azureQueue,omitempty"` + Custom *CustomScaleRule `json:"custom,omitempty"` + HTTP *HTTPScaleRule `json:"http,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_scaleruleauth.go b/resource-manager/web/2023-12-01/containerapps/model_scaleruleauth.go new file mode 100644 index 00000000000..46e5a92ad03 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_secret.go b/resource-manager/web/2023-12-01/containerapps/model_secret.go new file mode 100644 index 00000000000..172aa1e71e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_secret.go @@ -0,0 +1,9 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Secret struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_secretscollection.go b/resource-manager/web/2023-12-01/containerapps/model_secretscollection.go new file mode 100644 index 00000000000..5244f0aabe7 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_secretscollection.go @@ -0,0 +1,8 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecretsCollection struct { + Value []ContainerAppSecret `json:"value"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_template.go b/resource-manager/web/2023-12-01/containerapps/model_template.go new file mode 100644 index 00000000000..e9bb1c65c4b --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_template.go @@ -0,0 +1,11 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Template struct { + Containers *[]Container `json:"containers,omitempty"` + Dapr *Dapr `json:"dapr,omitempty"` + RevisionSuffix *string `json:"revisionSuffix,omitempty"` + Scale *Scale `json:"scale,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/model_trafficweight.go b/resource-manager/web/2023-12-01/containerapps/model_trafficweight.go new file mode 100644 index 00000000000..ffefd180a54 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/model_trafficweight.go @@ -0,0 +1,10 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficWeight struct { + LatestRevision *bool `json:"latestRevision,omitempty"` + RevisionName *string `json:"revisionName,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerapps/predicates.go b/resource-manager/web/2023-12-01/containerapps/predicates.go new file mode 100644 index 00000000000..21173ca2726 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/predicates.go @@ -0,0 +1,37 @@ +package containerapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p ContainerAppOperationPredicate) Matches(input ContainerApp) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2023-12-01/containerapps/version.go b/resource-manager/web/2023-12-01/containerapps/version.go new file mode 100644 index 00000000000..e090bd220b7 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerapps/version.go @@ -0,0 +1,12 @@ +package containerapps + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/containerapps/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/README.md b/resource-manager/web/2023-12-01/containerappsrevisions/README.md new file mode 100644 index 00000000000..a00f524bfd6 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/README.md @@ -0,0 +1,101 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/containerappsrevisions` Documentation + +The `containerappsrevisions` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/containerappsrevisions" +``` + + +### Client Initialization + +```go +client := containerappsrevisions.NewContainerAppsRevisionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ContainerAppsRevisionsClient.ActivateRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.ActivateRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.DeactivateRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.DeactivateRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.GetRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.GetRevision(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.ListRevisions` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + +// alternatively `client.ListRevisions(ctx, id)` can be used to do batched pagination +items, err := client.ListRevisionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ContainerAppsRevisionsClient.RestartRevision` + +```go +ctx := context.TODO() +id := containerappsrevisions.NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + +read, err := client.RestartRevision(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/web/2023-12-01/containerappsrevisions/client.go b/resource-manager/web/2023-12-01/containerappsrevisions/client.go new file mode 100644 index 00000000000..6dd288e2fae --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/client.go @@ -0,0 +1,26 @@ +package containerappsrevisions + +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 ContainerAppsRevisionsClient struct { + Client *resourcemanager.Client +} + +func NewContainerAppsRevisionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ContainerAppsRevisionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "containerappsrevisions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ContainerAppsRevisionsClient: %+v", err) + } + + return &ContainerAppsRevisionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/constants.go b/resource-manager/web/2023-12-01/containerappsrevisions/constants.go new file mode 100644 index 00000000000..0405b958db3 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/constants.go @@ -0,0 +1,104 @@ +package containerappsrevisions + +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 RevisionHealthState string + +const ( + RevisionHealthStateHealthy RevisionHealthState = "Healthy" + RevisionHealthStateNone RevisionHealthState = "None" + RevisionHealthStateUnhealthy RevisionHealthState = "Unhealthy" +) + +func PossibleValuesForRevisionHealthState() []string { + return []string{ + string(RevisionHealthStateHealthy), + string(RevisionHealthStateNone), + string(RevisionHealthStateUnhealthy), + } +} + +func (s *RevisionHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionHealthState(input string) (*RevisionHealthState, error) { + vals := map[string]RevisionHealthState{ + "healthy": RevisionHealthStateHealthy, + "none": RevisionHealthStateNone, + "unhealthy": RevisionHealthStateUnhealthy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionHealthState(input) + return &out, nil +} + +type RevisionProvisioningState string + +const ( + RevisionProvisioningStateDeprovisioned RevisionProvisioningState = "Deprovisioned" + RevisionProvisioningStateDeprovisioning RevisionProvisioningState = "Deprovisioning" + RevisionProvisioningStateFailed RevisionProvisioningState = "Failed" + RevisionProvisioningStateProvisioned RevisionProvisioningState = "Provisioned" + RevisionProvisioningStateProvisioning RevisionProvisioningState = "Provisioning" +) + +func PossibleValuesForRevisionProvisioningState() []string { + return []string{ + string(RevisionProvisioningStateDeprovisioned), + string(RevisionProvisioningStateDeprovisioning), + string(RevisionProvisioningStateFailed), + string(RevisionProvisioningStateProvisioned), + string(RevisionProvisioningStateProvisioning), + } +} + +func (s *RevisionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRevisionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRevisionProvisioningState(input string) (*RevisionProvisioningState, error) { + vals := map[string]RevisionProvisioningState{ + "deprovisioned": RevisionProvisioningStateDeprovisioned, + "deprovisioning": RevisionProvisioningStateDeprovisioning, + "failed": RevisionProvisioningStateFailed, + "provisioned": RevisionProvisioningStateProvisioned, + "provisioning": RevisionProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RevisionProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp.go b/resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp.go new file mode 100644 index 00000000000..f9d222c17f9 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp.go @@ -0,0 +1,130 @@ +package containerappsrevisions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderContainerAppId{}) +} + +var _ resourceids.ResourceId = &ProviderContainerAppId{} + +// ProviderContainerAppId is a struct representing the Resource ID for a Provider Container App +type ProviderContainerAppId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string +} + +// NewProviderContainerAppID returns a new ProviderContainerAppId struct +func NewProviderContainerAppID(subscriptionId string, resourceGroupName string, containerAppName string) ProviderContainerAppId { + return ProviderContainerAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + } +} + +// ParseProviderContainerAppID parses 'input' into a ProviderContainerAppId +func ParseProviderContainerAppID(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderContainerAppIDInsensitively parses 'input' case-insensitively into a ProviderContainerAppId +// note: this method should only be used for API response data and not user input +func ParseProviderContainerAppIDInsensitively(input string) (*ProviderContainerAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderContainerAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderContainerAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderContainerAppId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + return nil +} + +// ValidateProviderContainerAppID checks that 'input' can be parsed as a Provider Container App ID +func ValidateProviderContainerAppID(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 := ParseProviderContainerAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Container App ID +func (id ProviderContainerAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/containerApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Container App ID +func (id ProviderContainerAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + } +} + +// String returns a human-readable description of this Provider Container App ID +func (id ProviderContainerAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + } + return fmt.Sprintf("Provider Container App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp_test.go b/resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp_test.go new file mode 100644 index 00000000000..f88bd3f5c54 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/id_providercontainerapp_test.go @@ -0,0 +1,282 @@ +package containerappsrevisions + +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 = &ProviderContainerAppId{} + +func TestNewProviderContainerAppID(t *testing.T) { + id := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } +} + +func TestFormatProviderContainerAppID(t *testing.T) { + actual := NewProviderContainerAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderContainerAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestParseProviderContainerAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderContainerAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe", + Expected: &ProviderContainerAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + }, + }, + { + // 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.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderContainerAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + } +} + +func TestSegmentsForProviderContainerAppId(t *testing.T) { + segments := ProviderContainerAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderContainerAppId 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/web/2023-12-01/containerappsrevisions/id_revision.go b/resource-manager/web/2023-12-01/containerappsrevisions/id_revision.go new file mode 100644 index 00000000000..9c531d6051b --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/id_revision.go @@ -0,0 +1,139 @@ +package containerappsrevisions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RevisionId{}) +} + +var _ resourceids.ResourceId = &RevisionId{} + +// RevisionId is a struct representing the Resource ID for a Revision +type RevisionId struct { + SubscriptionId string + ResourceGroupName string + ContainerAppName string + RevisionName string +} + +// NewRevisionID returns a new RevisionId struct +func NewRevisionID(subscriptionId string, resourceGroupName string, containerAppName string, revisionName string) RevisionId { + return RevisionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ContainerAppName: containerAppName, + RevisionName: revisionName, + } +} + +// ParseRevisionID parses 'input' into a RevisionId +func ParseRevisionID(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRevisionIDInsensitively parses 'input' case-insensitively into a RevisionId +// note: this method should only be used for API response data and not user input +func ParseRevisionIDInsensitively(input string) (*RevisionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RevisionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RevisionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RevisionId) 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.ContainerAppName, ok = input.Parsed["containerAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "containerAppName", input) + } + + if id.RevisionName, ok = input.Parsed["revisionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "revisionName", input) + } + + return nil +} + +// ValidateRevisionID checks that 'input' can be parsed as a Revision ID +func ValidateRevisionID(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 := ParseRevisionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Revision ID +func (id RevisionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/containerApps/%s/revisions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ContainerAppName, id.RevisionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Revision ID +func (id RevisionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticContainerApps", "containerApps", "containerApps"), + resourceids.UserSpecifiedSegment("containerAppName", "containerAppValue"), + resourceids.StaticSegment("staticRevisions", "revisions", "revisions"), + resourceids.UserSpecifiedSegment("revisionName", "revisionValue"), + } +} + +// String returns a human-readable description of this Revision ID +func (id RevisionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Container App Name: %q", id.ContainerAppName), + fmt.Sprintf("Revision Name: %q", id.RevisionName), + } + return fmt.Sprintf("Revision (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/id_revision_test.go b/resource-manager/web/2023-12-01/containerappsrevisions/id_revision_test.go new file mode 100644 index 00000000000..e26040d11bf --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/id_revision_test.go @@ -0,0 +1,327 @@ +package containerappsrevisions + +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 = &RevisionId{} + +func TestNewRevisionID(t *testing.T) { + id := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue") + + 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.ContainerAppName != "containerAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContainerAppName'", id.ContainerAppName, "containerAppValue") + } + + if id.RevisionName != "revisionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RevisionName'", id.RevisionName, "revisionValue") + } +} + +func TestFormatRevisionID(t *testing.T) { + actual := NewRevisionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "containerAppValue", "revisionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/revisions/revisionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRevisionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/revisions/revisionValue", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/revisions/revisionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestParseRevisionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RevisionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/revisions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/revisions/revisionValue", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ContainerAppName: "containerAppValue", + RevisionName: "revisionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/containerApps/containerAppValue/revisions/revisionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe", + Expected: &RevisionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ContainerAppName: "cOnTaInErApPvAlUe", + RevisionName: "rEvIsIoNvAlUe", + }, + }, + { + // 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.wEb/cOnTaInErApPs/cOnTaInErApPvAlUe/rEvIsIoNs/rEvIsIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRevisionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ContainerAppName != v.Expected.ContainerAppName { + t.Fatalf("Expected %q but got %q for ContainerAppName", v.Expected.ContainerAppName, actual.ContainerAppName) + } + + if actual.RevisionName != v.Expected.RevisionName { + t.Fatalf("Expected %q but got %q for RevisionName", v.Expected.RevisionName, actual.RevisionName) + } + + } +} + +func TestSegmentsForRevisionId(t *testing.T) { + segments := RevisionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RevisionId 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/web/2023-12-01/containerappsrevisions/method_activaterevision.go b/resource-manager/web/2023-12-01/containerappsrevisions/method_activaterevision.go new file mode 100644 index 00000000000..1745777ac96 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/method_activaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +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 ActivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ActivateRevision ... +func (c ContainerAppsRevisionsClient) ActivateRevision(ctx context.Context, id RevisionId) (result ActivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/activate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/method_deactivaterevision.go b/resource-manager/web/2023-12-01/containerappsrevisions/method_deactivaterevision.go new file mode 100644 index 00000000000..46be1cffefd --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/method_deactivaterevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +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 DeactivateRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeactivateRevision ... +func (c ContainerAppsRevisionsClient) DeactivateRevision(ctx context.Context, id RevisionId) (result DeactivateRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deactivate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/method_getrevision.go b/resource-manager/web/2023-12-01/containerappsrevisions/method_getrevision.go new file mode 100644 index 00000000000..f2d02c1605e --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/method_getrevision.go @@ -0,0 +1,54 @@ +package containerappsrevisions + +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 GetRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Revision +} + +// GetRevision ... +func (c ContainerAppsRevisionsClient) GetRevision(ctx context.Context, id RevisionId) (result GetRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Revision + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/method_listrevisions.go b/resource-manager/web/2023-12-01/containerappsrevisions/method_listrevisions.go new file mode 100644 index 00000000000..133021d8cc7 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/method_listrevisions.go @@ -0,0 +1,91 @@ +package containerappsrevisions + +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 ListRevisionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Revision +} + +type ListRevisionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Revision +} + +// ListRevisions ... +func (c ContainerAppsRevisionsClient) ListRevisions(ctx context.Context, id ProviderContainerAppId) (result ListRevisionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/revisions", 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 *[]Revision `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRevisionsComplete retrieves all the results into a single object +func (c ContainerAppsRevisionsClient) ListRevisionsComplete(ctx context.Context, id ProviderContainerAppId) (ListRevisionsCompleteResult, error) { + return c.ListRevisionsCompleteMatchingPredicate(ctx, id, RevisionOperationPredicate{}) +} + +// ListRevisionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ContainerAppsRevisionsClient) ListRevisionsCompleteMatchingPredicate(ctx context.Context, id ProviderContainerAppId, predicate RevisionOperationPredicate) (result ListRevisionsCompleteResult, err error) { + items := make([]Revision, 0) + + resp, err := c.ListRevisions(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 = ListRevisionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/method_restartrevision.go b/resource-manager/web/2023-12-01/containerappsrevisions/method_restartrevision.go new file mode 100644 index 00000000000..e228b363490 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/method_restartrevision.go @@ -0,0 +1,47 @@ +package containerappsrevisions + +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 RestartRevisionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RestartRevision ... +func (c ContainerAppsRevisionsClient) RestartRevision(ctx context.Context, id RevisionId) (result RestartRevisionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_container.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_container.go new file mode 100644 index 00000000000..862350bdd50 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_container.go @@ -0,0 +1,13 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Container struct { + Args *[]string `json:"args,omitempty"` + Command *[]string `json:"command,omitempty"` + Env *[]EnvironmentVar `json:"env,omitempty"` + Image *string `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Resources *ContainerResources `json:"resources,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_containerresources.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_containerresources.go new file mode 100644 index 00000000000..a62495954a4 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_containerresources.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResources struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_customscalerule.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_customscalerule.go new file mode 100644 index 00000000000..601fb82b559 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_customscalerule.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_dapr.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_dapr.go new file mode 100644 index 00000000000..bf56c0864ed --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_dapr.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Dapr struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + Components *[]DaprComponent `json:"components,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_daprcomponent.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_daprcomponent.go new file mode 100644 index 00000000000..84f86e5b325 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_daprcomponent.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprComponent struct { + Metadata *[]DaprMetadata `json:"metadata,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_daprmetadata.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_daprmetadata.go new file mode 100644 index 00000000000..35d8790d331 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_daprmetadata.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprMetadata struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_environmentvar.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_environmentvar.go new file mode 100644 index 00000000000..1b4d78fc7ed --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_environmentvar.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVar struct { + Name *string `json:"name,omitempty"` + SecretRef *string `json:"secretRef,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_httpscalerule.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_httpscalerule.go new file mode 100644 index 00000000000..17656fa5908 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_httpscalerule.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_queuescalerule.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_queuescalerule.go new file mode 100644 index 00000000000..016cc178897 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_queuescalerule.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueScaleRule struct { + Auth *[]ScaleRuleAuth `json:"auth,omitempty"` + QueueLength *int64 `json:"queueLength,omitempty"` + QueueName *string `json:"queueName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_revision.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_revision.go new file mode 100644 index 00000000000..21661910d51 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_revision.go @@ -0,0 +1,14 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Revision struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *RevisionProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_revisionproperties.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_revisionproperties.go new file mode 100644 index 00000000000..60753fcac96 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_revisionproperties.go @@ -0,0 +1,34 @@ +package containerappsrevisions + +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 RevisionProperties struct { + Active *bool `json:"active,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + HealthState *RevisionHealthState `json:"healthState,omitempty"` + ProvisioningError *string `json:"provisioningError,omitempty"` + ProvisioningState *RevisionProvisioningState `json:"provisioningState,omitempty"` + Replicas *int64 `json:"replicas,omitempty"` + Template *Template `json:"template,omitempty"` + TrafficWeight *int64 `json:"trafficWeight,omitempty"` +} + +func (o *RevisionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RevisionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_scale.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_scale.go new file mode 100644 index 00000000000..f6e99c4b779 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_scale.go @@ -0,0 +1,10 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Scale struct { + MaxReplicas *int64 `json:"maxReplicas,omitempty"` + MinReplicas *int64 `json:"minReplicas,omitempty"` + Rules *[]ScaleRule `json:"rules,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_scalerule.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_scalerule.go new file mode 100644 index 00000000000..4bcd2c4a29e --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_scalerule.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRule struct { + AzureQueue *QueueScaleRule `json:"azureQueue,omitempty"` + Custom *CustomScaleRule `json:"custom,omitempty"` + HTTP *HTTPScaleRule `json:"http,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_scaleruleauth.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_scaleruleauth.go new file mode 100644 index 00000000000..2135985725a --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_scaleruleauth.go @@ -0,0 +1,9 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleRuleAuth struct { + SecretRef *string `json:"secretRef,omitempty"` + TriggerParameter *string `json:"triggerParameter,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/model_template.go b/resource-manager/web/2023-12-01/containerappsrevisions/model_template.go new file mode 100644 index 00000000000..fa5011317db --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/model_template.go @@ -0,0 +1,11 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Template struct { + Containers *[]Container `json:"containers,omitempty"` + Dapr *Dapr `json:"dapr,omitempty"` + RevisionSuffix *string `json:"revisionSuffix,omitempty"` + Scale *Scale `json:"scale,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/predicates.go b/resource-manager/web/2023-12-01/containerappsrevisions/predicates.go new file mode 100644 index 00000000000..863ff2fcae7 --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/predicates.go @@ -0,0 +1,37 @@ +package containerappsrevisions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RevisionOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p RevisionOperationPredicate) Matches(input Revision) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2023-12-01/containerappsrevisions/version.go b/resource-manager/web/2023-12-01/containerappsrevisions/version.go new file mode 100644 index 00000000000..47e5dc0261e --- /dev/null +++ b/resource-manager/web/2023-12-01/containerappsrevisions/version.go @@ -0,0 +1,12 @@ +package containerappsrevisions + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/containerappsrevisions/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/README.md b/resource-manager/web/2023-12-01/deletedwebapps/README.md new file mode 100644 index 00000000000..f137c13bebf --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/README.md @@ -0,0 +1,71 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/deletedwebapps` Documentation + +The `deletedwebapps` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/deletedwebapps" +``` + + +### Client Initialization + +```go +client := deletedwebapps.NewDeletedWebAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DeletedWebAppsClient.GetDeletedWebAppByLocation` + +```go +ctx := context.TODO() +id := deletedwebapps.NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedSiteIdValue") + +read, err := client.GetDeletedWebAppByLocation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DeletedWebAppsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `DeletedWebAppsClient.ListByLocation` + +```go +ctx := context.TODO() +id := deletedwebapps.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/deletedwebapps/client.go b/resource-manager/web/2023-12-01/deletedwebapps/client.go new file mode 100644 index 00000000000..7627ffe88fa --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/client.go @@ -0,0 +1,26 @@ +package deletedwebapps + +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 DeletedWebAppsClient struct { + Client *resourcemanager.Client +} + +func NewDeletedWebAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*DeletedWebAppsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "deletedwebapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeletedWebAppsClient: %+v", err) + } + + return &DeletedWebAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite.go b/resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite.go new file mode 100644 index 00000000000..38e9300d296 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite.go @@ -0,0 +1,130 @@ +package deletedwebapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationDeletedSiteId{}) +} + +var _ resourceids.ResourceId = &LocationDeletedSiteId{} + +// LocationDeletedSiteId is a struct representing the Resource ID for a Location Deleted Site +type LocationDeletedSiteId struct { + SubscriptionId string + LocationName string + DeletedSiteId string +} + +// NewLocationDeletedSiteID returns a new LocationDeletedSiteId struct +func NewLocationDeletedSiteID(subscriptionId string, locationName string, deletedSiteId string) LocationDeletedSiteId { + return LocationDeletedSiteId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + DeletedSiteId: deletedSiteId, + } +} + +// ParseLocationDeletedSiteID parses 'input' into a LocationDeletedSiteId +func ParseLocationDeletedSiteID(input string) (*LocationDeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationDeletedSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationDeletedSiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationDeletedSiteIDInsensitively parses 'input' case-insensitively into a LocationDeletedSiteId +// note: this method should only be used for API response data and not user input +func ParseLocationDeletedSiteIDInsensitively(input string) (*LocationDeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationDeletedSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationDeletedSiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationDeletedSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.DeletedSiteId, ok = input.Parsed["deletedSiteId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deletedSiteId", input) + } + + return nil +} + +// ValidateLocationDeletedSiteID checks that 'input' can be parsed as a Location Deleted Site ID +func ValidateLocationDeletedSiteID(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 := ParseLocationDeletedSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location Deleted Site ID +func (id LocationDeletedSiteId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s/deletedSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DeletedSiteId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location Deleted Site ID +func (id LocationDeletedSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticDeletedSites", "deletedSites", "deletedSites"), + resourceids.UserSpecifiedSegment("deletedSiteId", "deletedSiteIdValue"), + } +} + +// String returns a human-readable description of this Location Deleted Site ID +func (id LocationDeletedSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Deleted Site: %q", id.DeletedSiteId), + } + return fmt.Sprintf("Location Deleted Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite_test.go b/resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite_test.go new file mode 100644 index 00000000000..fc3a0df5835 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/id_locationdeletedsite_test.go @@ -0,0 +1,282 @@ +package deletedwebapps + +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 = &LocationDeletedSiteId{} + +func TestNewLocationDeletedSiteID(t *testing.T) { + id := NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedSiteIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } + + if id.DeletedSiteId != "deletedSiteIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'DeletedSiteId'", id.DeletedSiteId, "deletedSiteIdValue") + } +} + +func TestFormatLocationDeletedSiteID(t *testing.T) { + actual := NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationValue", "deletedSiteIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/deletedSites/deletedSiteIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationDeletedSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationDeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/deletedSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/deletedSites/deletedSiteIdValue", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DeletedSiteId: "deletedSiteIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/deletedSites/deletedSiteIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationDeletedSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestParseLocationDeletedSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationDeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/deletedSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/deletedSites/deletedSiteIdValue", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + DeletedSiteId: "deletedSiteIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/deletedSites/deletedSiteIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdSiTeS/dElEtEdSiTeIdVaLuE", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + DeletedSiteId: "dElEtEdSiTeIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe/dElEtEdSiTeS/dElEtEdSiTeIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationDeletedSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestSegmentsForLocationDeletedSiteId(t *testing.T) { + segments := LocationDeletedSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationDeletedSiteId 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/web/2023-12-01/deletedwebapps/id_providerlocation.go b/resource-manager/web/2023-12-01/deletedwebapps/id_providerlocation.go new file mode 100644 index 00000000000..34206ea2e60 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/id_providerlocation.go @@ -0,0 +1,121 @@ +package deletedwebapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/id_providerlocation_test.go b/resource-manager/web/2023-12-01/deletedwebapps/id_providerlocation_test.go new file mode 100644 index 00000000000..28b8c33c390 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package deletedwebapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/method_getdeletedwebappbylocation.go b/resource-manager/web/2023-12-01/deletedwebapps/method_getdeletedwebappbylocation.go new file mode 100644 index 00000000000..c3b5013c659 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/method_getdeletedwebappbylocation.go @@ -0,0 +1,54 @@ +package deletedwebapps + +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 GetDeletedWebAppByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebAppByLocation ... +func (c DeletedWebAppsClient) GetDeletedWebAppByLocation(ctx context.Context, id LocationDeletedSiteId) (result GetDeletedWebAppByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeletedSite + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/method_list.go b/resource-manager/web/2023-12-01/deletedwebapps/method_list.go new file mode 100644 index 00000000000..ea938ea0fec --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/method_list.go @@ -0,0 +1,92 @@ +package deletedwebapps + +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 *[]DeletedSite +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedSite +} + +// List ... +func (c DeletedWebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (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.Web/deletedSites", 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 *[]DeletedSite `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 DeletedWebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedSiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DeletedSite, 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/web/2023-12-01/deletedwebapps/method_listbylocation.go b/resource-manager/web/2023-12-01/deletedwebapps/method_listbylocation.go new file mode 100644 index 00000000000..2220ebed330 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/method_listbylocation.go @@ -0,0 +1,91 @@ +package deletedwebapps + +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 ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedSite +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedSite +} + +// ListByLocation ... +func (c DeletedWebAppsClient) ListByLocation(ctx context.Context, id ProviderLocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deletedSites", 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 *[]DeletedSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c DeletedWebAppsClient) ListByLocationComplete(ctx context.Context, id ProviderLocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate DeletedSiteOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]DeletedSite, 0) + + resp, err := c.ListByLocation(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 = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/model_deletedsite.go b/resource-manager/web/2023-12-01/deletedwebapps/model_deletedsite.go new file mode 100644 index 00000000000..680051fe469 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/model_deletedsite.go @@ -0,0 +1,12 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSite struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedSiteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/model_deletedsiteproperties.go b/resource-manager/web/2023-12-01/deletedwebapps/model_deletedsiteproperties.go new file mode 100644 index 00000000000..0afbf334a61 --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/model_deletedsiteproperties.go @@ -0,0 +1,15 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteProperties struct { + DeletedSiteId *int64 `json:"deletedSiteId,omitempty"` + DeletedSiteName *string `json:"deletedSiteName,omitempty"` + DeletedTimestamp *string `json:"deletedTimestamp,omitempty"` + GeoRegionName *string `json:"geoRegionName,omitempty"` + Kind *string `json:"kind,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Slot *string `json:"slot,omitempty"` + Subscription *string `json:"subscription,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/deletedwebapps/predicates.go b/resource-manager/web/2023-12-01/deletedwebapps/predicates.go new file mode 100644 index 00000000000..5db9392a06f --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/predicates.go @@ -0,0 +1,32 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DeletedSiteOperationPredicate) Matches(input DeletedSite) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/deletedwebapps/version.go b/resource-manager/web/2023-12-01/deletedwebapps/version.go new file mode 100644 index 00000000000..9f2a179e82e --- /dev/null +++ b/resource-manager/web/2023-12-01/deletedwebapps/version.go @@ -0,0 +1,12 @@ +package deletedwebapps + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/deletedwebapps/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/README.md b/resource-manager/web/2023-12-01/diagnostics/README.md new file mode 100644 index 00000000000..23b4106633e --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/README.md @@ -0,0 +1,382 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/diagnostics` Documentation + +The `diagnostics` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/diagnostics" +``` + + +### Client Initialization + +```go +client := diagnostics.NewDiagnosticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteAnalysis` + +```go +ctx := context.TODO() +id := diagnostics.NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "analysisValue") + +read, err := client.ExecuteSiteAnalysis(ctx, id, diagnostics.DefaultExecuteSiteAnalysisOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteAnalysisSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "analysisValue") + +read, err := client.ExecuteSiteAnalysisSlot(ctx, id, diagnostics.DefaultExecuteSiteAnalysisSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "detectorValue") + +read, err := client.ExecuteSiteDetector(ctx, id, diagnostics.DefaultExecuteSiteDetectorOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteDetectorSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "detectorValue") + +read, err := client.ExecuteSiteDetectorSlot(ctx, id, diagnostics.DefaultExecuteSiteDetectorSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetHostingEnvironmentDetectorResponse` + +```go +ctx := context.TODO() +id := diagnostics.NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "detectorValue") + +read, err := client.GetHostingEnvironmentDetectorResponse(ctx, id, diagnostics.DefaultGetHostingEnvironmentDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteAnalysis` + +```go +ctx := context.TODO() +id := diagnostics.NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "analysisValue") + +read, err := client.GetSiteAnalysis(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteAnalysisSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "analysisValue") + +read, err := client.GetSiteAnalysisSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "detectorValue") + +read, err := client.GetSiteDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorResponse` + +```go +ctx := context.TODO() +id := diagnostics.NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "detectorValue") + +read, err := client.GetSiteDetectorResponse(ctx, id, diagnostics.DefaultGetSiteDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorResponseSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "detectorValue") + +read, err := client.GetSiteDetectorResponseSlot(ctx, id, diagnostics.DefaultGetSiteDetectorResponseSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "detectorValue") + +read, err := client.GetSiteDetectorSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDiagnosticCategory` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue") + +read, err := client.GetSiteDiagnosticCategory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDiagnosticCategorySlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue") + +read, err := client.GetSiteDiagnosticCategorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ListHostingEnvironmentDetectorResponses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListHostingEnvironmentDetectorResponses(ctx, id)` can be used to do batched pagination +items, err := client.ListHostingEnvironmentDetectorResponsesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteAnalyses` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue") + +// alternatively `client.ListSiteAnalyses(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteAnalysesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteAnalysesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue") + +// alternatively `client.ListSiteAnalysesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteAnalysesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorResponses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSiteDetectorResponses(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorResponsesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorResponsesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSiteDetectorResponsesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorResponsesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectors` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue") + +// alternatively `client.ListSiteDetectors(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorsSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue") + +// alternatively `client.ListSiteDetectorsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDiagnosticCategories` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSiteDiagnosticCategories(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDiagnosticCategoriesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDiagnosticCategoriesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSiteDiagnosticCategoriesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDiagnosticCategoriesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/diagnostics/client.go b/resource-manager/web/2023-12-01/diagnostics/client.go new file mode 100644 index 00000000000..134561e1c49 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/client.go @@ -0,0 +1,26 @@ +package diagnostics + +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 DiagnosticsClient struct { + Client *resourcemanager.Client +} + +func NewDiagnosticsClientWithBaseURI(sdkApi sdkEnv.Api) (*DiagnosticsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "diagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticsClient: %+v", err) + } + + return &DiagnosticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/diagnostics/constants.go b/resource-manager/web/2023-12-01/diagnostics/constants.go new file mode 100644 index 00000000000..47006b35190 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/constants.go @@ -0,0 +1,317 @@ +package diagnostics + +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 DetectorType string + +const ( + DetectorTypeAnalysis DetectorType = "Analysis" + DetectorTypeCategoryOverview DetectorType = "CategoryOverview" + DetectorTypeDetector DetectorType = "Detector" +) + +func PossibleValuesForDetectorType() []string { + return []string{ + string(DetectorTypeAnalysis), + string(DetectorTypeCategoryOverview), + string(DetectorTypeDetector), + } +} + +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDetectorType(input string) (*DetectorType, error) { + vals := map[string]DetectorType{ + "analysis": DetectorTypeAnalysis, + "categoryoverview": DetectorTypeCategoryOverview, + "detector": DetectorTypeDetector, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DetectorType(input) + return &out, nil +} + +type InsightStatus string + +const ( + InsightStatusCritical InsightStatus = "Critical" + InsightStatusInfo InsightStatus = "Info" + InsightStatusNone InsightStatus = "None" + InsightStatusSuccess InsightStatus = "Success" + InsightStatusWarning InsightStatus = "Warning" +) + +func PossibleValuesForInsightStatus() []string { + return []string{ + string(InsightStatusCritical), + string(InsightStatusInfo), + string(InsightStatusNone), + string(InsightStatusSuccess), + string(InsightStatusWarning), + } +} + +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInsightStatus(input string) (*InsightStatus, error) { + vals := map[string]InsightStatus{ + "critical": InsightStatusCritical, + "info": InsightStatusInfo, + "none": InsightStatusNone, + "success": InsightStatusSuccess, + "warning": InsightStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InsightStatus(input) + return &out, nil +} + +type IssueType string + +const ( + IssueTypeAppCrash IssueType = "AppCrash" + IssueTypeAppDeployment IssueType = "AppDeployment" + IssueTypeAseDeployment IssueType = "AseDeployment" + IssueTypeOther IssueType = "Other" + IssueTypePlatformIssue IssueType = "PlatformIssue" + IssueTypeRuntimeIssueDetected IssueType = "RuntimeIssueDetected" + IssueTypeServiceIncident IssueType = "ServiceIncident" + IssueTypeUserIssue IssueType = "UserIssue" +) + +func PossibleValuesForIssueType() []string { + return []string{ + string(IssueTypeAppCrash), + string(IssueTypeAppDeployment), + string(IssueTypeAseDeployment), + string(IssueTypeOther), + string(IssueTypePlatformIssue), + string(IssueTypeRuntimeIssueDetected), + string(IssueTypeServiceIncident), + string(IssueTypeUserIssue), + } +} + +func (s *IssueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIssueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIssueType(input string) (*IssueType, error) { + vals := map[string]IssueType{ + "appcrash": IssueTypeAppCrash, + "appdeployment": IssueTypeAppDeployment, + "asedeployment": IssueTypeAseDeployment, + "other": IssueTypeOther, + "platformissue": IssueTypePlatformIssue, + "runtimeissuedetected": IssueTypeRuntimeIssueDetected, + "serviceincident": IssueTypeServiceIncident, + "userissue": IssueTypeUserIssue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IssueType(input) + return &out, nil +} + +type RenderingType string + +const ( + RenderingTypeAppInsight RenderingType = "AppInsight" + RenderingTypeAppInsightEnablement RenderingType = "AppInsightEnablement" + RenderingTypeCard RenderingType = "Card" + RenderingTypeChangeAnalysisOnboarding RenderingType = "ChangeAnalysisOnboarding" + RenderingTypeChangeSets RenderingType = "ChangeSets" + RenderingTypeChangesView RenderingType = "ChangesView" + RenderingTypeDataSummary RenderingType = "DataSummary" + RenderingTypeDependencyGraph RenderingType = "DependencyGraph" + RenderingTypeDetector RenderingType = "Detector" + RenderingTypeDownTime RenderingType = "DownTime" + RenderingTypeDropDown RenderingType = "DropDown" + RenderingTypeDynamicInsight RenderingType = "DynamicInsight" + RenderingTypeEmail RenderingType = "Email" + RenderingTypeForm RenderingType = "Form" + RenderingTypeGuage RenderingType = "Guage" + RenderingTypeInsights RenderingType = "Insights" + RenderingTypeMarkdown RenderingType = "Markdown" + RenderingTypeNoGraph RenderingType = "NoGraph" + RenderingTypePieChart RenderingType = "PieChart" + RenderingTypeSearchComponent RenderingType = "SearchComponent" + RenderingTypeSolution RenderingType = "Solution" + RenderingTypeSummaryCard RenderingType = "SummaryCard" + RenderingTypeTable RenderingType = "Table" + RenderingTypeTimeSeries RenderingType = "TimeSeries" + RenderingTypeTimeSeriesPerInstance RenderingType = "TimeSeriesPerInstance" +) + +func PossibleValuesForRenderingType() []string { + return []string{ + string(RenderingTypeAppInsight), + string(RenderingTypeAppInsightEnablement), + string(RenderingTypeCard), + string(RenderingTypeChangeAnalysisOnboarding), + string(RenderingTypeChangeSets), + string(RenderingTypeChangesView), + string(RenderingTypeDataSummary), + string(RenderingTypeDependencyGraph), + string(RenderingTypeDetector), + string(RenderingTypeDownTime), + string(RenderingTypeDropDown), + string(RenderingTypeDynamicInsight), + string(RenderingTypeEmail), + string(RenderingTypeForm), + string(RenderingTypeGuage), + string(RenderingTypeInsights), + string(RenderingTypeMarkdown), + string(RenderingTypeNoGraph), + string(RenderingTypePieChart), + string(RenderingTypeSearchComponent), + string(RenderingTypeSolution), + string(RenderingTypeSummaryCard), + string(RenderingTypeTable), + string(RenderingTypeTimeSeries), + string(RenderingTypeTimeSeriesPerInstance), + } +} + +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRenderingType(input string) (*RenderingType, error) { + vals := map[string]RenderingType{ + "appinsight": RenderingTypeAppInsight, + "appinsightenablement": RenderingTypeAppInsightEnablement, + "card": RenderingTypeCard, + "changeanalysisonboarding": RenderingTypeChangeAnalysisOnboarding, + "changesets": RenderingTypeChangeSets, + "changesview": RenderingTypeChangesView, + "datasummary": RenderingTypeDataSummary, + "dependencygraph": RenderingTypeDependencyGraph, + "detector": RenderingTypeDetector, + "downtime": RenderingTypeDownTime, + "dropdown": RenderingTypeDropDown, + "dynamicinsight": RenderingTypeDynamicInsight, + "email": RenderingTypeEmail, + "form": RenderingTypeForm, + "guage": RenderingTypeGuage, + "insights": RenderingTypeInsights, + "markdown": RenderingTypeMarkdown, + "nograph": RenderingTypeNoGraph, + "piechart": RenderingTypePieChart, + "searchcomponent": RenderingTypeSearchComponent, + "solution": RenderingTypeSolution, + "summarycard": RenderingTypeSummaryCard, + "table": RenderingTypeTable, + "timeseries": RenderingTypeTimeSeries, + "timeseriesperinstance": RenderingTypeTimeSeriesPerInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RenderingType(input) + return &out, nil +} + +type SolutionType string + +const ( + SolutionTypeBestPractices SolutionType = "BestPractices" + SolutionTypeDeepInvestigation SolutionType = "DeepInvestigation" + SolutionTypeQuickSolution SolutionType = "QuickSolution" +) + +func PossibleValuesForSolutionType() []string { + return []string{ + string(SolutionTypeBestPractices), + string(SolutionTypeDeepInvestigation), + string(SolutionTypeQuickSolution), + } +} + +func (s *SolutionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSolutionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSolutionType(input string) (*SolutionType, error) { + vals := map[string]SolutionType{ + "bestpractices": SolutionTypeBestPractices, + "deepinvestigation": SolutionTypeDeepInvestigation, + "quicksolution": SolutionTypeQuickSolution, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SolutionType(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_analysis.go b/resource-manager/web/2023-12-01/diagnostics/id_analysis.go new file mode 100644 index 00000000000..cf164a66cd5 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_analysis.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AnalysisId{}) +} + +var _ resourceids.ResourceId = &AnalysisId{} + +// AnalysisId is a struct representing the Resource ID for a Analysis +type AnalysisId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string + AnalysisName string +} + +// NewAnalysisID returns a new AnalysisId struct +func NewAnalysisID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string, analysisName string) AnalysisId { + return AnalysisId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + AnalysisName: analysisName, + } +} + +// ParseAnalysisID parses 'input' into a AnalysisId +func ParseAnalysisID(input string) (*AnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&AnalysisId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AnalysisId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAnalysisIDInsensitively parses 'input' case-insensitively into a AnalysisId +// note: this method should only be used for API response data and not user input +func ParseAnalysisIDInsensitively(input string) (*AnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&AnalysisId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AnalysisId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AnalysisId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.AnalysisName, ok = input.Parsed["analysisName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "analysisName", input) + } + + return nil +} + +// ValidateAnalysisID checks that 'input' can be parsed as a Analysis ID +func ValidateAnalysisID(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 := ParseAnalysisID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Analysis ID +func (id AnalysisId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s/analyses/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName, id.AnalysisName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Analysis ID +func (id AnalysisId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticValue"), + resourceids.StaticSegment("staticAnalyses", "analyses", "analyses"), + resourceids.UserSpecifiedSegment("analysisName", "analysisValue"), + } +} + +// String returns a human-readable description of this Analysis ID +func (id AnalysisId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Analysis Name: %q", id.AnalysisName), + } + return fmt.Sprintf("Analysis (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_analysis_test.go b/resource-manager/web/2023-12-01/diagnostics/id_analysis_test.go new file mode 100644 index 00000000000..7a48f79a43e --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_analysis_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &AnalysisId{} + +func TestNewAnalysisID(t *testing.T) { + id := NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "analysisValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.DiagnosticName != "diagnosticValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticValue") + } + + if id.AnalysisName != "analysisValue" { + t.Fatalf("Expected %q but got %q for Segment 'AnalysisName'", id.AnalysisName, "analysisValue") + } +} + +func TestFormatAnalysisID(t *testing.T) { + actual := NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "analysisValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/analyses/analysisValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAnalysisID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/analyses", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/analyses/analysisValue", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DiagnosticName: "diagnosticValue", + AnalysisName: "analysisValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/analyses/analysisValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAnalysisID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestParseAnalysisIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/analyses", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/aNaLySeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/analyses/analysisValue", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DiagnosticName: "diagnosticValue", + AnalysisName: "analysisValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/analyses/analysisValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/aNaLySeS/aNaLySiSvAlUe", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + DiagnosticName: "dIaGnOsTiCvAlUe", + AnalysisName: "aNaLySiSvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/aNaLySeS/aNaLySiSvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAnalysisIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestSegmentsForAnalysisId(t *testing.T) { + segments := AnalysisId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AnalysisId 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/web/2023-12-01/diagnostics/id_detector.go b/resource-manager/web/2023-12-01/diagnostics/id_detector.go new file mode 100644 index 00000000000..89042fab54f --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_detector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DetectorId{}) +} + +var _ resourceids.ResourceId = &DetectorId{} + +// DetectorId is a struct representing the Resource ID for a Detector +type DetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DetectorName string +} + +// NewDetectorID returns a new DetectorId struct +func NewDetectorID(subscriptionId string, resourceGroupName string, siteName string, detectorName string) DetectorId { + return DetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DetectorName: detectorName, + } +} + +// ParseDetectorID parses 'input' into a DetectorId +func ParseDetectorID(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorIDInsensitively parses 'input' case-insensitively into a DetectorId +// note: this method should only be used for API response data and not user input +func ParseDetectorIDInsensitively(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDetectorID checks that 'input' can be parsed as a Detector ID +func ValidateDetectorID(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 := ParseDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector ID +func (id DetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector ID +func (id DetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Detector ID +func (id DetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_detector_test.go b/resource-manager/web/2023-12-01/diagnostics/id_detector_test.go new file mode 100644 index 00000000000..70338f6e72f --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_detector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &DetectorId{} + +func TestNewDetectorID(t *testing.T) { + id := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "detectorValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatDetectorID(t *testing.T) { + actual := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/detectors/detectorValue", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDetectorId(t *testing.T) { + segments := DetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorId 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/web/2023-12-01/diagnostics/id_diagnostic.go b/resource-manager/web/2023-12-01/diagnostics/id_diagnostic.go new file mode 100644 index 00000000000..156adb806c7 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_diagnostic.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DiagnosticId{}) +} + +var _ resourceids.ResourceId = &DiagnosticId{} + +// DiagnosticId is a struct representing the Resource ID for a Diagnostic +type DiagnosticId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string +} + +// NewDiagnosticID returns a new DiagnosticId struct +func NewDiagnosticID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string) DiagnosticId { + return DiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + } +} + +// ParseDiagnosticID parses 'input' into a DiagnosticId +func ParseDiagnosticID(input string) (*DiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticIDInsensitively parses 'input' case-insensitively into a DiagnosticId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticIDInsensitively(input string) (*DiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateDiagnosticID checks that 'input' can be parsed as a Diagnostic ID +func ValidateDiagnosticID(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 := ParseDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic ID +func (id DiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic ID +func (id DiagnosticId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticValue"), + } +} + +// String returns a human-readable description of this Diagnostic ID +func (id DiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_diagnostic_test.go b/resource-manager/web/2023-12-01/diagnostics/id_diagnostic_test.go new file mode 100644 index 00000000000..3caa707164b --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_diagnostic_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &DiagnosticId{} + +func TestNewDiagnosticID(t *testing.T) { + id := NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.DiagnosticName != "diagnosticValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticValue") + } +} + +func TestFormatDiagnosticID(t *testing.T) { + actual := NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DiagnosticName: "diagnosticValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DiagnosticName: "diagnosticValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + DiagnosticName: "dIaGnOsTiCvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForDiagnosticId(t *testing.T) { + segments := DiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticId 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/web/2023-12-01/diagnostics/id_diagnosticanalysis.go b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticanalysis.go new file mode 100644 index 00000000000..28ed452f661 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticanalysis.go @@ -0,0 +1,157 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DiagnosticAnalysisId{}) +} + +var _ resourceids.ResourceId = &DiagnosticAnalysisId{} + +// DiagnosticAnalysisId is a struct representing the Resource ID for a Diagnostic Analysis +type DiagnosticAnalysisId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string + AnalysisName string +} + +// NewDiagnosticAnalysisID returns a new DiagnosticAnalysisId struct +func NewDiagnosticAnalysisID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string, analysisName string) DiagnosticAnalysisId { + return DiagnosticAnalysisId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + AnalysisName: analysisName, + } +} + +// ParseDiagnosticAnalysisID parses 'input' into a DiagnosticAnalysisId +func ParseDiagnosticAnalysisID(input string) (*DiagnosticAnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticAnalysisId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticAnalysisId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticAnalysisIDInsensitively parses 'input' case-insensitively into a DiagnosticAnalysisId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticAnalysisIDInsensitively(input string) (*DiagnosticAnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticAnalysisId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticAnalysisId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticAnalysisId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.AnalysisName, ok = input.Parsed["analysisName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "analysisName", input) + } + + return nil +} + +// ValidateDiagnosticAnalysisID checks that 'input' can be parsed as a Diagnostic Analysis ID +func ValidateDiagnosticAnalysisID(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 := ParseDiagnosticAnalysisID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic Analysis ID +func (id DiagnosticAnalysisId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s/analyses/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName, id.AnalysisName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic Analysis ID +func (id DiagnosticAnalysisId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticValue"), + resourceids.StaticSegment("staticAnalyses", "analyses", "analyses"), + resourceids.UserSpecifiedSegment("analysisName", "analysisValue"), + } +} + +// String returns a human-readable description of this Diagnostic Analysis ID +func (id DiagnosticAnalysisId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Analysis Name: %q", id.AnalysisName), + } + return fmt.Sprintf("Diagnostic Analysis (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_diagnosticanalysis_test.go b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticanalysis_test.go new file mode 100644 index 00000000000..74de1feaaba --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticanalysis_test.go @@ -0,0 +1,417 @@ +package diagnostics + +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 = &DiagnosticAnalysisId{} + +func TestNewDiagnosticAnalysisID(t *testing.T) { + id := NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "analysisValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.DiagnosticName != "diagnosticValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticValue") + } + + if id.AnalysisName != "analysisValue" { + t.Fatalf("Expected %q but got %q for Segment 'AnalysisName'", id.AnalysisName, "analysisValue") + } +} + +func TestFormatDiagnosticAnalysisID(t *testing.T) { + actual := NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "analysisValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/analyses/analysisValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticAnalysisID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticAnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/analyses", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/analyses/analysisValue", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DiagnosticName: "diagnosticValue", + AnalysisName: "analysisValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/analyses/analysisValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticAnalysisID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestParseDiagnosticAnalysisIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticAnalysisId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/analyses", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/aNaLySeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/analyses/analysisValue", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DiagnosticName: "diagnosticValue", + AnalysisName: "analysisValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/analyses/analysisValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/aNaLySeS/aNaLySiSvAlUe", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + DiagnosticName: "dIaGnOsTiCvAlUe", + AnalysisName: "aNaLySiSvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/aNaLySeS/aNaLySiSvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticAnalysisIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestSegmentsForDiagnosticAnalysisId(t *testing.T) { + segments := DiagnosticAnalysisId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticAnalysisId 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/web/2023-12-01/diagnostics/id_diagnosticdetector.go b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticdetector.go new file mode 100644 index 00000000000..a6d345670d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticdetector.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DiagnosticDetectorId{}) +} + +var _ resourceids.ResourceId = &DiagnosticDetectorId{} + +// DiagnosticDetectorId is a struct representing the Resource ID for a Diagnostic Detector +type DiagnosticDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string + DetectorName string +} + +// NewDiagnosticDetectorID returns a new DiagnosticDetectorId struct +func NewDiagnosticDetectorID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string, detectorName string) DiagnosticDetectorId { + return DiagnosticDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + DetectorName: detectorName, + } +} + +// ParseDiagnosticDetectorID parses 'input' into a DiagnosticDetectorId +func ParseDiagnosticDetectorID(input string) (*DiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticDetectorIDInsensitively parses 'input' case-insensitively into a DiagnosticDetectorId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticDetectorIDInsensitively(input string) (*DiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticDetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDiagnosticDetectorID checks that 'input' can be parsed as a Diagnostic Detector ID +func ValidateDiagnosticDetectorID(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 := ParseDiagnosticDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic Detector ID +func (id DiagnosticDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic Detector ID +func (id DiagnosticDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Diagnostic Detector ID +func (id DiagnosticDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Diagnostic Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_diagnosticdetector_test.go b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticdetector_test.go new file mode 100644 index 00000000000..33db9a24eab --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_diagnosticdetector_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &DiagnosticDetectorId{} + +func TestNewDiagnosticDetectorID(t *testing.T) { + id := NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "detectorValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.DiagnosticName != "diagnosticValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatDiagnosticDetectorID(t *testing.T) { + actual := NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "diagnosticValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/detectors/detectorValue", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DiagnosticName: "diagnosticValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDiagnosticDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/detectors/detectorValue", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DiagnosticName: "diagnosticValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/diagnostics/diagnosticValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + DiagnosticName: "dIaGnOsTiCvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDiagnosticDetectorId(t *testing.T) { + segments := DiagnosticDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticDetectorId 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/web/2023-12-01/diagnostics/id_hostingenvironmentdetector.go b/resource-manager/web/2023-12-01/diagnostics/id_hostingenvironmentdetector.go new file mode 100644 index 00000000000..7bf33585a6a --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_hostingenvironmentdetector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentDetectorId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentDetectorId{} + +// HostingEnvironmentDetectorId is a struct representing the Resource ID for a Hosting Environment Detector +type HostingEnvironmentDetectorId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + DetectorName string +} + +// NewHostingEnvironmentDetectorID returns a new HostingEnvironmentDetectorId struct +func NewHostingEnvironmentDetectorID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, detectorName string) HostingEnvironmentDetectorId { + return HostingEnvironmentDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + DetectorName: detectorName, + } +} + +// ParseHostingEnvironmentDetectorID parses 'input' into a HostingEnvironmentDetectorId +func ParseHostingEnvironmentDetectorID(input string) (*HostingEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentDetectorIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentDetectorId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentDetectorIDInsensitively(input string) (*HostingEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentDetectorId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateHostingEnvironmentDetectorID checks that 'input' can be parsed as a Hosting Environment Detector ID +func ValidateHostingEnvironmentDetectorID(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 := ParseHostingEnvironmentDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Hosting Environment Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_hostingenvironmentdetector_test.go b/resource-manager/web/2023-12-01/diagnostics/id_hostingenvironmentdetector_test.go new file mode 100644 index 00000000000..c75c62721e9 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_hostingenvironmentdetector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &HostingEnvironmentDetectorId{} + +func TestNewHostingEnvironmentDetectorID(t *testing.T) { + id := NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "detectorValue") + + 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.HostingEnvironmentName != "hostingEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatHostingEnvironmentDetectorID(t *testing.T) { + actual := NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/detectors/detectorValue", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseHostingEnvironmentDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/detectors/detectorValue", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForHostingEnvironmentDetectorId(t *testing.T) { + segments := HostingEnvironmentDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentDetectorId 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/web/2023-12-01/diagnostics/id_slot.go b/resource-manager/web/2023-12-01/diagnostics/id_slot.go new file mode 100644 index 00000000000..3a3f6dcbfba --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slot.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(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 := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_slot_test.go b/resource-manager/web/2023-12-01/diagnostics/id_slot_test.go new file mode 100644 index 00000000000..9b1c6de0508 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slot_test.go @@ -0,0 +1,327 @@ +package diagnostics + +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 = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId 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/web/2023-12-01/diagnostics/id_slotdetector.go b/resource-manager/web/2023-12-01/diagnostics/id_slotdetector.go new file mode 100644 index 00000000000..bc38b43b06a --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slotdetector.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDetectorId{}) +} + +var _ resourceids.ResourceId = &SlotDetectorId{} + +// SlotDetectorId is a struct representing the Resource ID for a Slot Detector +type SlotDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DetectorName string +} + +// NewSlotDetectorID returns a new SlotDetectorId struct +func NewSlotDetectorID(subscriptionId string, resourceGroupName string, siteName string, slotName string, detectorName string) SlotDetectorId { + return SlotDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DetectorName: detectorName, + } +} + +// ParseSlotDetectorID parses 'input' into a SlotDetectorId +func ParseSlotDetectorID(input string) (*SlotDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDetectorIDInsensitively parses 'input' case-insensitively into a SlotDetectorId +// note: this method should only be used for API response data and not user input +func ParseSlotDetectorIDInsensitively(input string) (*SlotDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateSlotDetectorID checks that 'input' can be parsed as a Slot Detector ID +func ValidateSlotDetectorID(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 := ParseSlotDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Detector ID +func (id SlotDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Detector ID +func (id SlotDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Slot Detector ID +func (id SlotDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Slot Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_slotdetector_test.go b/resource-manager/web/2023-12-01/diagnostics/id_slotdetector_test.go new file mode 100644 index 00000000000..20b9964af9f --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slotdetector_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &SlotDetectorId{} + +func TestNewSlotDetectorID(t *testing.T) { + id := NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "detectorValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatSlotDetectorID(t *testing.T) { + actual := NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/detectors/detectorValue", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseSlotDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/detectors/detectorValue", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForSlotDetectorId(t *testing.T) { + segments := SlotDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDetectorId 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/web/2023-12-01/diagnostics/id_slotdiagnostic.go b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnostic.go new file mode 100644 index 00000000000..3dc67da36a9 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnostic.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDiagnosticId{}) +} + +var _ resourceids.ResourceId = &SlotDiagnosticId{} + +// SlotDiagnosticId is a struct representing the Resource ID for a Slot Diagnostic +type SlotDiagnosticId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string +} + +// NewSlotDiagnosticID returns a new SlotDiagnosticId struct +func NewSlotDiagnosticID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string) SlotDiagnosticId { + return SlotDiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + } +} + +// ParseSlotDiagnosticID parses 'input' into a SlotDiagnosticId +func ParseSlotDiagnosticID(input string) (*SlotDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDiagnosticIDInsensitively parses 'input' case-insensitively into a SlotDiagnosticId +// note: this method should only be used for API response data and not user input +func ParseSlotDiagnosticIDInsensitively(input string) (*SlotDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDiagnosticId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateSlotDiagnosticID checks that 'input' can be parsed as a Slot Diagnostic ID +func ValidateSlotDiagnosticID(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 := ParseSlotDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Diagnostic ID +func (id SlotDiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Diagnostic ID +func (id SlotDiagnosticId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticValue"), + } +} + +// String returns a human-readable description of this Slot Diagnostic ID +func (id SlotDiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Slot Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnostic_test.go b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnostic_test.go new file mode 100644 index 00000000000..581067b04ae --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnostic_test.go @@ -0,0 +1,372 @@ +package diagnostics + +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 = &SlotDiagnosticId{} + +func TestNewSlotDiagnosticID(t *testing.T) { + id := NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.DiagnosticName != "diagnosticValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticValue") + } +} + +func TestFormatSlotDiagnosticID(t *testing.T) { + actual := NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DiagnosticName: "diagnosticValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseSlotDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DiagnosticName: "diagnosticValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + DiagnosticName: "dIaGnOsTiCvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForSlotDiagnosticId(t *testing.T) { + segments := SlotDiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDiagnosticId 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/web/2023-12-01/diagnostics/id_slotdiagnosticdetector.go b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnosticdetector.go new file mode 100644 index 00000000000..73d9c680c8f --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnosticdetector.go @@ -0,0 +1,157 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDiagnosticDetectorId{}) +} + +var _ resourceids.ResourceId = &SlotDiagnosticDetectorId{} + +// SlotDiagnosticDetectorId is a struct representing the Resource ID for a Slot Diagnostic Detector +type SlotDiagnosticDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string + DetectorName string +} + +// NewSlotDiagnosticDetectorID returns a new SlotDiagnosticDetectorId struct +func NewSlotDiagnosticDetectorID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string, detectorName string) SlotDiagnosticDetectorId { + return SlotDiagnosticDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + DetectorName: detectorName, + } +} + +// ParseSlotDiagnosticDetectorID parses 'input' into a SlotDiagnosticDetectorId +func ParseSlotDiagnosticDetectorID(input string) (*SlotDiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDiagnosticDetectorIDInsensitively parses 'input' case-insensitively into a SlotDiagnosticDetectorId +// note: this method should only be used for API response data and not user input +func ParseSlotDiagnosticDetectorIDInsensitively(input string) (*SlotDiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticDetectorId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDiagnosticDetectorId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateSlotDiagnosticDetectorID checks that 'input' can be parsed as a Slot Diagnostic Detector ID +func ValidateSlotDiagnosticDetectorID(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 := ParseSlotDiagnosticDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticValue"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorValue"), + } +} + +// String returns a human-readable description of this Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Slot Diagnostic Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnosticdetector_test.go b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnosticdetector_test.go new file mode 100644 index 00000000000..217fe8cd667 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/id_slotdiagnosticdetector_test.go @@ -0,0 +1,417 @@ +package diagnostics + +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 = &SlotDiagnosticDetectorId{} + +func TestNewSlotDiagnosticDetectorID(t *testing.T) { + id := NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "detectorValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.DiagnosticName != "diagnosticValue" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticValue") + } + + if id.DetectorName != "detectorValue" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorValue") + } +} + +func TestFormatSlotDiagnosticDetectorID(t *testing.T) { + actual := NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "diagnosticValue", "detectorValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/detectors/detectorValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDiagnosticDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/detectors/detectorValue", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DiagnosticName: "diagnosticValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/detectors/detectorValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseSlotDiagnosticDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticDetectorId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/detectors/detectorValue", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DiagnosticName: "diagnosticValue", + DetectorName: "detectorValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/diagnostics/diagnosticValue/detectors/detectorValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/dEtEcToRs/dEtEcToRvAlUe", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + DiagnosticName: "dIaGnOsTiCvAlUe", + DetectorName: "dEtEcToRvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dIaGnOsTiCs/dIaGnOsTiCvAlUe/dEtEcToRs/dEtEcToRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForSlotDiagnosticDetectorId(t *testing.T) { + segments := SlotDiagnosticDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDiagnosticDetectorId 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/web/2023-12-01/diagnostics/method_executesiteanalysis.go b/resource-manager/web/2023-12-01/diagnostics/method_executesiteanalysis.go new file mode 100644 index 00000000000..bc5d3b93098 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_executesiteanalysis.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ExecuteSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisOperationOptions() ExecuteSiteAnalysisOperationOptions { + return ExecuteSiteAnalysisOperationOptions{} +} + +func (o ExecuteSiteAnalysisOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysis ... +func (c DiagnosticsClient) ExecuteSiteAnalysis(ctx context.Context, id AnalysisId, options ExecuteSiteAnalysisOperationOptions) (result ExecuteSiteAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticAnalysis + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_executesiteanalysisslot.go b/resource-manager/web/2023-12-01/diagnostics/method_executesiteanalysisslot.go new file mode 100644 index 00000000000..9c46ec6e7c0 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_executesiteanalysisslot.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ExecuteSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisSlotOperationOptions() ExecuteSiteAnalysisSlotOperationOptions { + return ExecuteSiteAnalysisSlotOperationOptions{} +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysisSlot ... +func (c DiagnosticsClient) ExecuteSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId, options ExecuteSiteAnalysisSlotOperationOptions) (result ExecuteSiteAnalysisSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticAnalysis + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_executesitedetector.go b/resource-manager/web/2023-12-01/diagnostics/method_executesitedetector.go new file mode 100644 index 00000000000..d5921adb000 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_executesitedetector.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ExecuteSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorOperationOptions() ExecuteSiteDetectorOperationOptions { + return ExecuteSiteDetectorOperationOptions{} +} + +func (o ExecuteSiteDetectorOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetector ... +func (c DiagnosticsClient) ExecuteSiteDetector(ctx context.Context, id DiagnosticDetectorId, options ExecuteSiteDetectorOperationOptions) (result ExecuteSiteDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticDetectorResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_executesitedetectorslot.go b/resource-manager/web/2023-12-01/diagnostics/method_executesitedetectorslot.go new file mode 100644 index 00000000000..57d36c6f2bd --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_executesitedetectorslot.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ExecuteSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorSlotOperationOptions() ExecuteSiteDetectorSlotOperationOptions { + return ExecuteSiteDetectorSlotOperationOptions{} +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetectorSlot ... +func (c DiagnosticsClient) ExecuteSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId, options ExecuteSiteDetectorSlotOperationOptions) (result ExecuteSiteDetectorSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/execute", 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 + } + + var model DiagnosticDetectorResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_gethostingenvironmentdetectorresponse.go b/resource-manager/web/2023-12-01/diagnostics/method_gethostingenvironmentdetectorresponse.go new file mode 100644 index 00000000000..5c07b3a16ac --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_gethostingenvironmentdetectorresponse.go @@ -0,0 +1,91 @@ +package diagnostics + +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 GetHostingEnvironmentDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetHostingEnvironmentDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetHostingEnvironmentDetectorResponseOperationOptions() GetHostingEnvironmentDetectorResponseOperationOptions { + return GetHostingEnvironmentDetectorResponseOperationOptions{} +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetHostingEnvironmentDetectorResponse ... +func (c DiagnosticsClient) GetHostingEnvironmentDetectorResponse(ctx context.Context, id HostingEnvironmentDetectorId, options GetHostingEnvironmentDetectorResponseOperationOptions) (result GetHostingEnvironmentDetectorResponseOperationResponse, 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 + } + + var model DetectorResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysis.go b/resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysis.go new file mode 100644 index 00000000000..9f71be3deb5 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysis.go @@ -0,0 +1,54 @@ +package diagnostics + +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 GetSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysis ... +func (c DiagnosticsClient) GetSiteAnalysis(ctx context.Context, id AnalysisId) (result GetSiteAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AnalysisDefinition + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysisslot.go b/resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysisslot.go new file mode 100644 index 00000000000..045dd22a086 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsiteanalysisslot.go @@ -0,0 +1,54 @@ +package diagnostics + +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 GetSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysisSlot ... +func (c DiagnosticsClient) GetSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId) (result GetSiteAnalysisSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AnalysisDefinition + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsitedetector.go b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetector.go new file mode 100644 index 00000000000..bd8a5d0fd1b --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetector.go @@ -0,0 +1,54 @@ +package diagnostics + +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 GetSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetector ... +func (c DiagnosticsClient) GetSiteDetector(ctx context.Context, id DiagnosticDetectorId) (result GetSiteDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorDefinitionResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponse.go b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponse.go new file mode 100644 index 00000000000..2bb7b20c482 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponse.go @@ -0,0 +1,91 @@ +package diagnostics + +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 GetSiteDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseOperationOptions() GetSiteDetectorResponseOperationOptions { + return GetSiteDetectorResponseOperationOptions{} +} + +func (o GetSiteDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponse ... +func (c DiagnosticsClient) GetSiteDetectorResponse(ctx context.Context, id DetectorId, options GetSiteDetectorResponseOperationOptions) (result GetSiteDetectorResponseOperationResponse, 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 + } + + var model DetectorResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponseslot.go b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponseslot.go new file mode 100644 index 00000000000..18b8359de69 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorresponseslot.go @@ -0,0 +1,91 @@ +package diagnostics + +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 GetSiteDetectorResponseSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseSlotOperationOptions() GetSiteDetectorResponseSlotOperationOptions { + return GetSiteDetectorResponseSlotOperationOptions{} +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponseSlot ... +func (c DiagnosticsClient) GetSiteDetectorResponseSlot(ctx context.Context, id SlotDetectorId, options GetSiteDetectorResponseSlotOperationOptions) (result GetSiteDetectorResponseSlotOperationResponse, 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 + } + + var model DetectorResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorslot.go b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorslot.go new file mode 100644 index 00000000000..53ae2cc819c --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsitedetectorslot.go @@ -0,0 +1,54 @@ +package diagnostics + +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 GetSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetectorSlot ... +func (c DiagnosticsClient) GetSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId) (result GetSiteDetectorSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorDefinitionResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategory.go b/resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategory.go new file mode 100644 index 00000000000..450eb557042 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategory.go @@ -0,0 +1,54 @@ +package diagnostics + +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 GetSiteDiagnosticCategoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategory ... +func (c DiagnosticsClient) GetSiteDiagnosticCategory(ctx context.Context, id DiagnosticId) (result GetSiteDiagnosticCategoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticCategory + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategoryslot.go b/resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategoryslot.go new file mode 100644 index 00000000000..fb8ac9e2176 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_getsitediagnosticcategoryslot.go @@ -0,0 +1,54 @@ +package diagnostics + +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 GetSiteDiagnosticCategorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategorySlot ... +func (c DiagnosticsClient) GetSiteDiagnosticCategorySlot(ctx context.Context, id SlotDiagnosticId) (result GetSiteDiagnosticCategorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticCategory + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listhostingenvironmentdetectorresponses.go b/resource-manager/web/2023-12-01/diagnostics/method_listhostingenvironmentdetectorresponses.go new file mode 100644 index 00000000000..89aa0516697 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listhostingenvironmentdetectorresponses.go @@ -0,0 +1,92 @@ +package diagnostics + +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 ListHostingEnvironmentDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListHostingEnvironmentDetectorResponsesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +// ListHostingEnvironmentDetectorResponses ... +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponses(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostingEnvironmentDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListHostingEnvironmentDetectorResponsesCompleteResult, error) { + return c.ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate DetectorResponseOperationPredicate) (result ListHostingEnvironmentDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListHostingEnvironmentDetectorResponses(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 = ListHostingEnvironmentDetectorResponsesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsiteanalyses.go b/resource-manager/web/2023-12-01/diagnostics/method_listsiteanalyses.go new file mode 100644 index 00000000000..3e900561513 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsiteanalyses.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ListSiteAnalysesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AnalysisDefinition +} + +// ListSiteAnalyses ... +func (c DiagnosticsClient) ListSiteAnalyses(ctx context.Context, id DiagnosticId) (result ListSiteAnalysesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyses", 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 *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesComplete(ctx context.Context, id DiagnosticId) (ListSiteAnalysesCompleteResult, error) { + return c.ListSiteAnalysesCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalyses(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 = ListSiteAnalysesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsiteanalysesslot.go b/resource-manager/web/2023-12-01/diagnostics/method_listsiteanalysesslot.go new file mode 100644 index 00000000000..afc36f37ede --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsiteanalysesslot.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ListSiteAnalysesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []AnalysisDefinition +} + +// ListSiteAnalysesSlot ... +func (c DiagnosticsClient) ListSiteAnalysesSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteAnalysesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyses", 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 *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteAnalysesSlotCompleteResult, error) { + return c.ListSiteAnalysesSlotCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesSlotCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalysesSlot(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 = ListSiteAnalysesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponses.go b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponses.go new file mode 100644 index 00000000000..8c71c3c21a7 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponses.go @@ -0,0 +1,92 @@ +package diagnostics + +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 ListSiteDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +// ListSiteDetectorResponses ... +func (c DiagnosticsClient) ListSiteDetectorResponses(ctx context.Context, id commonids.AppServiceId) (result ListSiteDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteDetectorResponsesCompleteResult, error) { + return c.ListSiteDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponses(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 = ListSiteDetectorResponsesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponsesslot.go b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponsesslot.go new file mode 100644 index 00000000000..93f8caa0dea --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorresponsesslot.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ListSiteDetectorResponsesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +// ListSiteDetectorResponsesSlot ... +func (c DiagnosticsClient) ListSiteDetectorResponsesSlot(ctx context.Context, id SlotId) (result ListSiteDetectorResponsesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotComplete(ctx context.Context, id SlotId) (ListSiteDetectorResponsesSlotCompleteResult, error) { + return c.ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesSlotCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponsesSlot(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 = ListSiteDetectorResponsesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectors.go b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectors.go new file mode 100644 index 00000000000..28424068fda --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectors.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ListSiteDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorDefinitionResource +} + +// ListSiteDetectors ... +func (c DiagnosticsClient) ListSiteDetectors(ctx context.Context, id DiagnosticId) (result ListSiteDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsComplete(ctx context.Context, id DiagnosticId) (ListSiteDetectorsCompleteResult, error) { + return c.ListSiteDetectorsCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectors(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 = ListSiteDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorsslot.go b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorsslot.go new file mode 100644 index 00000000000..065e1cf9ec3 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsitedetectorsslot.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ListSiteDetectorsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorDefinitionResource +} + +// ListSiteDetectorsSlot ... +func (c DiagnosticsClient) ListSiteDetectorsSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteDetectorsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/detectors", 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 *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteDetectorsSlotCompleteResult, error) { + return c.ListSiteDetectorsSlotCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsSlotCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectorsSlot(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 = ListSiteDetectorsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategories.go b/resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategories.go new file mode 100644 index 00000000000..2d5b81c43be --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategories.go @@ -0,0 +1,92 @@ +package diagnostics + +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 ListSiteDiagnosticCategoriesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiagnosticCategory +} + +// ListSiteDiagnosticCategories ... +func (c DiagnosticsClient) ListSiteDiagnosticCategories(ctx context.Context, id commonids.AppServiceId) (result ListSiteDiagnosticCategoriesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", 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 *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteDiagnosticCategoriesCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategories(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 = ListSiteDiagnosticCategoriesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategoriesslot.go b/resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategoriesslot.go new file mode 100644 index 00000000000..9abb067ee9b --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/method_listsitediagnosticcategoriesslot.go @@ -0,0 +1,91 @@ +package diagnostics + +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 ListSiteDiagnosticCategoriesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiagnosticCategory +} + +// ListSiteDiagnosticCategoriesSlot ... +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlot(ctx context.Context, id SlotId) (result ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", 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 *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotComplete(ctx context.Context, id SlotId) (ListSiteDiagnosticCategoriesSlotCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesSlotCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategoriesSlot(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 = ListSiteDiagnosticCategoriesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_abnormaltimeperiod.go b/resource-manager/web/2023-12-01/diagnostics/model_abnormaltimeperiod.go new file mode 100644 index 00000000000..a6df9ee83ab --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_abnormaltimeperiod.go @@ -0,0 +1,41 @@ +package diagnostics + +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 AbnormalTimePeriod struct { + EndTime *string `json:"endTime,omitempty"` + Events *[]DetectorAbnormalTimePeriod `json:"events,omitempty"` + Solutions *[]Solution `json:"solutions,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *AbnormalTimePeriod) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AbnormalTimePeriod) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AbnormalTimePeriod) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AbnormalTimePeriod) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_analysisdata.go b/resource-manager/web/2023-12-01/diagnostics/model_analysisdata.go new file mode 100644 index 00000000000..58dc2411c1b --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_analysisdata.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisData struct { + Data *[][]NameValuePair `json:"data,omitempty"` + DetectorDefinition *DetectorDefinition `json:"detectorDefinition,omitempty"` + DetectorMetaData *ResponseMetaData `json:"detectorMetaData,omitempty"` + Metrics *[]DiagnosticMetricSet `json:"metrics,omitempty"` + Source *string `json:"source,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_analysisdefinition.go b/resource-manager/web/2023-12-01/diagnostics/model_analysisdefinition.go new file mode 100644 index 00000000000..08e03e1c0a0 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_analysisdefinition.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinition struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AnalysisDefinitionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_analysisdefinitionproperties.go b/resource-manager/web/2023-12-01/diagnostics/model_analysisdefinitionproperties.go new file mode 100644 index 00000000000..8a0e57964d3 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_analysisdefinitionproperties.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinitionProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_dataprovidermetadata.go b/resource-manager/web/2023-12-01/diagnostics/model_dataprovidermetadata.go new file mode 100644 index 00000000000..c6f80aabe5f --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_dataprovidermetadata.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProviderMetadata struct { + PropertyBag *[]KeyValuePairStringObject `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_datasource.go b/resource-manager/web/2023-12-01/diagnostics/model_datasource.go new file mode 100644 index 00000000000..5843559ebf5 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_datasource.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataSource struct { + DataSourceUri *[]NameValuePair `json:"dataSourceUri,omitempty"` + Instructions *[]string `json:"instructions,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_datatableresponsecolumn.go b/resource-manager/web/2023-12-01/diagnostics/model_datatableresponsecolumn.go new file mode 100644 index 00000000000..7ff0fb87216 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_datatableresponsecolumn.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_datatableresponseobject.go b/resource-manager/web/2023-12-01/diagnostics/model_datatableresponseobject.go new file mode 100644 index 00000000000..579ce5cc5d2 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_datatableresponseobject.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseObject struct { + Columns *[]DataTableResponseColumn `json:"columns,omitempty"` + Rows *[][]string `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_detectorabnormaltimeperiod.go b/resource-manager/web/2023-12-01/diagnostics/model_detectorabnormaltimeperiod.go new file mode 100644 index 00000000000..e0f1933477a --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_detectorabnormaltimeperiod.go @@ -0,0 +1,45 @@ +package diagnostics + +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 DetectorAbnormalTimePeriod struct { + EndTime *string `json:"endTime,omitempty"` + Message *string `json:"message,omitempty"` + MetaData *[][]NameValuePair `json:"metaData,omitempty"` + Priority *float64 `json:"priority,omitempty"` + Solutions *[]Solution `json:"solutions,omitempty"` + Source *string `json:"source,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Type *IssueType `json:"type,omitempty"` +} + +func (o *DetectorAbnormalTimePeriod) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DetectorAbnormalTimePeriod) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DetectorAbnormalTimePeriod) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DetectorAbnormalTimePeriod) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_detectordefinition.go b/resource-manager/web/2023-12-01/diagnostics/model_detectordefinition.go new file mode 100644 index 00000000000..8bd10bf28f2 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_detectordefinition.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorDefinition struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Rank *float64 `json:"rank,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_detectordefinitionresource.go b/resource-manager/web/2023-12-01/diagnostics/model_detectordefinitionresource.go new file mode 100644 index 00000000000..3493647c958 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_detectordefinitionresource.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorDefinitionResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorDefinition `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_detectorinfo.go b/resource-manager/web/2023-12-01/diagnostics/model_detectorinfo.go new file mode 100644 index 00000000000..153af1a6eec --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_detectorinfo.go @@ -0,0 +1,16 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorInfo struct { + AnalysisType *[]string `json:"analysisType,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]SupportTopic `json:"supportTopicList,omitempty"` + Type *DetectorType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_detectorresponse.go b/resource-manager/web/2023-12-01/diagnostics/model_detectorresponse.go new file mode 100644 index 00000000000..3f2ea2b54a4 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_detectorresponse.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_detectorresponseproperties.go b/resource-manager/web/2023-12-01/diagnostics/model_detectorresponseproperties.go new file mode 100644 index 00000000000..dbad1bb6b3c --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_detectorresponseproperties.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseProperties struct { + DataProvidersMetadata *[]DataProviderMetadata `json:"dataProvidersMetadata,omitempty"` + Dataset *[]DiagnosticData `json:"dataset,omitempty"` + Metadata *DetectorInfo `json:"metadata,omitempty"` + Status *Status `json:"status,omitempty"` + SuggestedUtterances *QueryUtterancesResults `json:"suggestedUtterances,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysis.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysis.go new file mode 100644 index 00000000000..86feeab70a5 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysis.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticAnalysis struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticAnalysisProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysisproperties.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysisproperties.go new file mode 100644 index 00000000000..e60f737dd9c --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticanalysisproperties.go @@ -0,0 +1,42 @@ +package diagnostics + +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 DiagnosticAnalysisProperties struct { + AbnormalTimePeriods *[]AbnormalTimePeriod `json:"abnormalTimePeriods,omitempty"` + EndTime *string `json:"endTime,omitempty"` + NonCorrelatedDetectors *[]DetectorDefinition `json:"nonCorrelatedDetectors,omitempty"` + Payload *[]AnalysisData `json:"payload,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *DiagnosticAnalysisProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticAnalysisProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticAnalysisProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticAnalysisProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategory.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategory.go new file mode 100644 index 00000000000..edcfc1a5905 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategory.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticCategory struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticCategoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategoryproperties.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategoryproperties.go new file mode 100644 index 00000000000..d00339539f9 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticcategoryproperties.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticCategoryProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdata.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdata.go new file mode 100644 index 00000000000..86888b44d22 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdata.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticData struct { + RenderingProperties *Rendering `json:"renderingProperties,omitempty"` + Table *DataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponse.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponse.go new file mode 100644 index 00000000000..7cdae4bd506 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponse.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticDetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponseproperties.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponseproperties.go new file mode 100644 index 00000000000..b936047e0c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticdetectorresponseproperties.go @@ -0,0 +1,45 @@ +package diagnostics + +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 DiagnosticDetectorResponseProperties struct { + AbnormalTimePeriods *[]DetectorAbnormalTimePeriod `json:"abnormalTimePeriods,omitempty"` + Data *[][]NameValuePair `json:"data,omitempty"` + DetectorDefinition *DetectorDefinition `json:"detectorDefinition,omitempty"` + EndTime *string `json:"endTime,omitempty"` + IssueDetected *bool `json:"issueDetected,omitempty"` + Metrics *[]DiagnosticMetricSet `json:"metrics,omitempty"` + ResponseMetaData *ResponseMetaData `json:"responseMetaData,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *DiagnosticDetectorResponseProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticDetectorResponseProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticDetectorResponseProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticDetectorResponseProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricsample.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricsample.go new file mode 100644 index 00000000000..1d0bb623c41 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricsample.go @@ -0,0 +1,31 @@ +package diagnostics + +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 DiagnosticMetricSample struct { + IsAggregated *bool `json:"isAggregated,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + RoleInstance *string `json:"roleInstance,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Total *float64 `json:"total,omitempty"` +} + +func (o *DiagnosticMetricSample) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSample) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricset.go b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricset.go new file mode 100644 index 00000000000..b1331ff017b --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_diagnosticmetricset.go @@ -0,0 +1,43 @@ +package diagnostics + +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 DiagnosticMetricSet struct { + EndTime *string `json:"endTime,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Unit *string `json:"unit,omitempty"` + Values *[]DiagnosticMetricSample `json:"values,omitempty"` +} + +func (o *DiagnosticMetricSet) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSet) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticMetricSet) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSet) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_keyvaluepairstringobject.go b/resource-manager/web/2023-12-01/diagnostics/model_keyvaluepairstringobject.go new file mode 100644 index 00000000000..f1376667ff2 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_keyvaluepairstringobject.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyValuePairStringObject struct { + Key *string `json:"key,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_namevaluepair.go b/resource-manager/web/2023-12-01/diagnostics/model_namevaluepair.go new file mode 100644 index 00000000000..78a664c6c65 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_namevaluepair.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresult.go b/resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresult.go new file mode 100644 index 00000000000..e2f31e703c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresult.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResult struct { + SampleUtterance *SampleUtterance `json:"sampleUtterance,omitempty"` + Score *float64 `json:"score,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresults.go b/resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresults.go new file mode 100644 index 00000000000..3a4443fd8f5 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_queryutterancesresults.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResults struct { + Query *string `json:"query,omitempty"` + Results *[]QueryUtterancesResult `json:"results,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_rendering.go b/resource-manager/web/2023-12-01/diagnostics/model_rendering.go new file mode 100644 index 00000000000..a5a796665bc --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_rendering.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rendering struct { + Description *string `json:"description,omitempty"` + Title *string `json:"title,omitempty"` + Type *RenderingType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_responsemetadata.go b/resource-manager/web/2023-12-01/diagnostics/model_responsemetadata.go new file mode 100644 index 00000000000..e887117c071 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_responsemetadata.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseMetaData struct { + DataSource *DataSource `json:"dataSource,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_sampleutterance.go b/resource-manager/web/2023-12-01/diagnostics/model_sampleutterance.go new file mode 100644 index 00000000000..a6d9970ed40 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_sampleutterance.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SampleUtterance struct { + Links *[]string `json:"links,omitempty"` + Qid *string `json:"qid,omitempty"` + Text *string `json:"text,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_solution.go b/resource-manager/web/2023-12-01/diagnostics/model_solution.go new file mode 100644 index 00000000000..c19e80a66a9 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_solution.go @@ -0,0 +1,14 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Solution struct { + Data *[][]NameValuePair `json:"data,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Id *float64 `json:"id,omitempty"` + Metadata *[][]NameValuePair `json:"metadata,omitempty"` + Order *float64 `json:"order,omitempty"` + Type *SolutionType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_status.go b/resource-manager/web/2023-12-01/diagnostics/model_status.go new file mode 100644 index 00000000000..3f71907964e --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_status.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Status struct { + Message *string `json:"message,omitempty"` + StatusId *InsightStatus `json:"statusId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/model_supporttopic.go b/resource-manager/web/2023-12-01/diagnostics/model_supporttopic.go new file mode 100644 index 00000000000..096120c069d --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/model_supporttopic.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/diagnostics/predicates.go b/resource-manager/web/2023-12-01/diagnostics/predicates.go new file mode 100644 index 00000000000..660a1c908be --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/predicates.go @@ -0,0 +1,116 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinitionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p AnalysisDefinitionOperationPredicate) Matches(input AnalysisDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type DetectorDefinitionResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorDefinitionResourceOperationPredicate) Matches(input DetectorDefinitionResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type DetectorResponseOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorResponseOperationPredicate) Matches(input DetectorResponse) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type DiagnosticCategoryOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DiagnosticCategoryOperationPredicate) Matches(input DiagnosticCategory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/diagnostics/version.go b/resource-manager/web/2023-12-01/diagnostics/version.go new file mode 100644 index 00000000000..d89e29f2e65 --- /dev/null +++ b/resource-manager/web/2023-12-01/diagnostics/version.go @@ -0,0 +1,12 @@ +package diagnostics + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/diagnostics/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/domains/README.md b/resource-manager/web/2023-12-01/domains/README.md new file mode 100644 index 00000000000..c94acff3879 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/README.md @@ -0,0 +1,307 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/domains` Documentation + +The `domains` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/domains" +``` + + +### Client Initialization + +```go +client := domains.NewDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DomainsClient.CheckAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := domains.NameIdentifier{ + // ... +} + + +read, err := client.CheckAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + +payload := domains.Domain{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DomainsClient.CreateOrUpdateOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue", "domainOwnershipIdentifierValue") + +payload := domains.DomainOwnershipIdentifier{ + // ... +} + + +read, err := client.CreateOrUpdateOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Delete` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + +read, err := client.Delete(ctx, id, domains.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.DeleteOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue", "domainOwnershipIdentifierValue") + +read, err := client.DeleteOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Get` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + +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: `DomainsClient.GetControlCenterSsoRequest` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.GetControlCenterSsoRequest(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.GetOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue", "domainOwnershipIdentifierValue") + +read, err := client.GetOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `DomainsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.ListOwnershipIdentifiers` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + +// alternatively `client.ListOwnershipIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListOwnershipIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.ListRecommendations` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := domains.DomainRecommendationSearchParameters{ + // ... +} + + +// alternatively `client.ListRecommendations(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListRecommendationsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.Renew` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + +read, err := client.Renew(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.TransferOut` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + +read, err := client.TransferOut(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Update` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + +payload := domains.DomainPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.UpdateOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue", "domainOwnershipIdentifierValue") + +payload := domains.DomainOwnershipIdentifier{ + // ... +} + + +read, err := client.UpdateOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2023-12-01/domains/client.go b/resource-manager/web/2023-12-01/domains/client.go new file mode 100644 index 00000000000..2ce822d248f --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/client.go @@ -0,0 +1,26 @@ +package domains + +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 DomainsClient struct { + Client *resourcemanager.Client +} + +func NewDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*DomainsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "domains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DomainsClient: %+v", err) + } + + return &DomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/domains/constants.go b/resource-manager/web/2023-12-01/domains/constants.go new file mode 100644 index 00000000000..a2302025ac5 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/constants.go @@ -0,0 +1,407 @@ +package domains + +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 AzureResourceType string + +const ( + AzureResourceTypeTrafficManager AzureResourceType = "TrafficManager" + AzureResourceTypeWebsite AzureResourceType = "Website" +) + +func PossibleValuesForAzureResourceType() []string { + return []string{ + string(AzureResourceTypeTrafficManager), + string(AzureResourceTypeWebsite), + } +} + +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceType(input string) (*AzureResourceType, error) { + vals := map[string]AzureResourceType{ + "trafficmanager": AzureResourceTypeTrafficManager, + "website": AzureResourceTypeWebsite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceType(input) + return &out, nil +} + +type CustomHostNameDnsRecordType string + +const ( + CustomHostNameDnsRecordTypeA CustomHostNameDnsRecordType = "A" + CustomHostNameDnsRecordTypeCName CustomHostNameDnsRecordType = "CName" +) + +func PossibleValuesForCustomHostNameDnsRecordType() []string { + return []string{ + string(CustomHostNameDnsRecordTypeA), + string(CustomHostNameDnsRecordTypeCName), + } +} + +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { + vals := map[string]CustomHostNameDnsRecordType{ + "a": CustomHostNameDnsRecordTypeA, + "cname": CustomHostNameDnsRecordTypeCName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHostNameDnsRecordType(input) + return &out, nil +} + +type DnsType string + +const ( + DnsTypeAzureDns DnsType = "AzureDns" + DnsTypeDefaultDomainRegistrarDns DnsType = "DefaultDomainRegistrarDns" +) + +func PossibleValuesForDnsType() []string { + return []string{ + string(DnsTypeAzureDns), + string(DnsTypeDefaultDomainRegistrarDns), + } +} + +func (s *DnsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsType(input string) (*DnsType, error) { + vals := map[string]DnsType{ + "azuredns": DnsTypeAzureDns, + "defaultdomainregistrardns": DnsTypeDefaultDomainRegistrarDns, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsType(input) + return &out, nil +} + +type DomainStatus string + +const ( + DomainStatusActive DomainStatus = "Active" + DomainStatusAwaiting DomainStatus = "Awaiting" + DomainStatusCancelled DomainStatus = "Cancelled" + DomainStatusConfiscated DomainStatus = "Confiscated" + DomainStatusDisabled DomainStatus = "Disabled" + DomainStatusExcluded DomainStatus = "Excluded" + DomainStatusExpired DomainStatus = "Expired" + DomainStatusFailed DomainStatus = "Failed" + DomainStatusHeld DomainStatus = "Held" + DomainStatusJsonConverterFailed DomainStatus = "JsonConverterFailed" + DomainStatusLocked DomainStatus = "Locked" + DomainStatusParked DomainStatus = "Parked" + DomainStatusPending DomainStatus = "Pending" + DomainStatusReserved DomainStatus = "Reserved" + DomainStatusReverted DomainStatus = "Reverted" + DomainStatusSuspended DomainStatus = "Suspended" + DomainStatusTransferred DomainStatus = "Transferred" + DomainStatusUnknown DomainStatus = "Unknown" + DomainStatusUnlocked DomainStatus = "Unlocked" + DomainStatusUnparked DomainStatus = "Unparked" + DomainStatusUpdated DomainStatus = "Updated" +) + +func PossibleValuesForDomainStatus() []string { + return []string{ + string(DomainStatusActive), + string(DomainStatusAwaiting), + string(DomainStatusCancelled), + string(DomainStatusConfiscated), + string(DomainStatusDisabled), + string(DomainStatusExcluded), + string(DomainStatusExpired), + string(DomainStatusFailed), + string(DomainStatusHeld), + string(DomainStatusJsonConverterFailed), + string(DomainStatusLocked), + string(DomainStatusParked), + string(DomainStatusPending), + string(DomainStatusReserved), + string(DomainStatusReverted), + string(DomainStatusSuspended), + string(DomainStatusTransferred), + string(DomainStatusUnknown), + string(DomainStatusUnlocked), + string(DomainStatusUnparked), + string(DomainStatusUpdated), + } +} + +func (s *DomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainStatus(input string) (*DomainStatus, error) { + vals := map[string]DomainStatus{ + "active": DomainStatusActive, + "awaiting": DomainStatusAwaiting, + "cancelled": DomainStatusCancelled, + "confiscated": DomainStatusConfiscated, + "disabled": DomainStatusDisabled, + "excluded": DomainStatusExcluded, + "expired": DomainStatusExpired, + "failed": DomainStatusFailed, + "held": DomainStatusHeld, + "jsonconverterfailed": DomainStatusJsonConverterFailed, + "locked": DomainStatusLocked, + "parked": DomainStatusParked, + "pending": DomainStatusPending, + "reserved": DomainStatusReserved, + "reverted": DomainStatusReverted, + "suspended": DomainStatusSuspended, + "transferred": DomainStatusTransferred, + "unknown": DomainStatusUnknown, + "unlocked": DomainStatusUnlocked, + "unparked": DomainStatusUnparked, + "updated": DomainStatusUpdated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainStatus(input) + return &out, nil +} + +type DomainType string + +const ( + DomainTypeRegular DomainType = "Regular" + DomainTypeSoftDeleted DomainType = "SoftDeleted" +) + +func PossibleValuesForDomainType() []string { + return []string{ + string(DomainTypeRegular), + string(DomainTypeSoftDeleted), + } +} + +func (s *DomainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainType(input string) (*DomainType, error) { + vals := map[string]DomainType{ + "regular": DomainTypeRegular, + "softdeleted": DomainTypeSoftDeleted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainType(input) + return &out, nil +} + +type HostNameType string + +const ( + HostNameTypeManaged HostNameType = "Managed" + HostNameTypeVerified HostNameType = "Verified" +) + +func PossibleValuesForHostNameType() []string { + return []string{ + string(HostNameTypeManaged), + string(HostNameTypeVerified), + } +} + +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameType(input string) (*HostNameType, error) { + vals := map[string]HostNameType{ + "managed": HostNameTypeManaged, + "verified": HostNameTypeVerified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/domains/id_domain.go b/resource-manager/web/2023-12-01/domains/id_domain.go new file mode 100644 index 00000000000..a3841009671 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/id_domain.go @@ -0,0 +1,130 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DomainId{}) +} + +var _ resourceids.ResourceId = &DomainId{} + +// DomainId is a struct representing the Resource ID for a Domain +type DomainId struct { + SubscriptionId string + ResourceGroupName string + DomainName string +} + +// NewDomainID returns a new DomainId struct +func NewDomainID(subscriptionId string, resourceGroupName string, domainName string) DomainId { + return DomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DomainName: domainName, + } +} + +// ParseDomainID parses 'input' into a DomainId +func ParseDomainID(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainIDInsensitively parses 'input' case-insensitively into a DomainId +// note: this method should only be used for API response data and not user input +func ParseDomainIDInsensitively(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainId) 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.DomainName, ok = input.Parsed["domainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainName", input) + } + + return nil +} + +// ValidateDomainID checks that 'input' can be parsed as a Domain ID +func ValidateDomainID(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 := ParseDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain ID +func (id DomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DomainRegistration/domains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain ID +func (id DomainId) 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("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticDomains", "domains", "domains"), + resourceids.UserSpecifiedSegment("domainName", "domainValue"), + } +} + +// String returns a human-readable description of this Domain ID +func (id DomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Domain Name: %q", id.DomainName), + } + return fmt.Sprintf("Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/domains/id_domain_test.go b/resource-manager/web/2023-12-01/domains/id_domain_test.go new file mode 100644 index 00000000000..5684b2ee57d --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/id_domain_test.go @@ -0,0 +1,282 @@ +package domains + +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 = &DomainId{} + +func TestNewDomainID(t *testing.T) { + id := NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue") + + 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.DomainName != "domainValue" { + t.Fatalf("Expected %q but got %q for Segment 'DomainName'", id.DomainName, "domainValue") + } +} + +func TestFormatDomainID(t *testing.T) { + actual := NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + } +} + +func TestParseDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNvAlUe", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DomainName: "dOmAiNvAlUe", + }, + }, + { + // 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.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + } +} + +func TestSegmentsForDomainId(t *testing.T) { + segments := DomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DomainId 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/web/2023-12-01/domains/id_domainownershipidentifier.go b/resource-manager/web/2023-12-01/domains/id_domainownershipidentifier.go new file mode 100644 index 00000000000..a4600242107 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/id_domainownershipidentifier.go @@ -0,0 +1,139 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &DomainOwnershipIdentifierId{} + +// DomainOwnershipIdentifierId is a struct representing the Resource ID for a Domain Ownership Identifier +type DomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + DomainName string + DomainOwnershipIdentifierName string +} + +// NewDomainOwnershipIdentifierID returns a new DomainOwnershipIdentifierId struct +func NewDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, domainName string, domainOwnershipIdentifierName string) DomainOwnershipIdentifierId { + return DomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DomainName: domainName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseDomainOwnershipIdentifierID parses 'input' into a DomainOwnershipIdentifierId +func ParseDomainOwnershipIdentifierID(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a DomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseDomainOwnershipIdentifierIDInsensitively(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainOwnershipIdentifierId) 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.DomainName, ok = input.Parsed["domainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateDomainOwnershipIdentifierID checks that 'input' can be parsed as a Domain Ownership Identifier ID +func ValidateDomainOwnershipIdentifierID(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 := ParseDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DomainRegistration/domains/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DomainName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) 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("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticDomains", "domains", "domains"), + resourceids.UserSpecifiedSegment("domainName", "domainValue"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierValue"), + } +} + +// String returns a human-readable description of this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Domain Name: %q", id.DomainName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/domains/id_domainownershipidentifier_test.go b/resource-manager/web/2023-12-01/domains/id_domainownershipidentifier_test.go new file mode 100644 index 00000000000..73c36fa1872 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/id_domainownershipidentifier_test.go @@ -0,0 +1,327 @@ +package domains + +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 = &DomainOwnershipIdentifierId{} + +func TestNewDomainOwnershipIdentifierID(t *testing.T) { + id := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue", "domainOwnershipIdentifierValue") + + 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.DomainName != "domainValue" { + t.Fatalf("Expected %q but got %q for Segment 'DomainName'", id.DomainName, "domainValue") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierValue" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierValue") + } +} + +func TestFormatDomainOwnershipIdentifierID(t *testing.T) { + actual := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainValue", "domainOwnershipIdentifierValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainValue", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // 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.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNvAlUe/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainValue", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNvAlUe/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErVaLuE", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DomainName: "dOmAiNvAlUe", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErVaLuE", + }, + }, + { + // 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.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNvAlUe/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForDomainOwnershipIdentifierId(t *testing.T) { + segments := DomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DomainOwnershipIdentifierId 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/web/2023-12-01/domains/method_checkavailability.go b/resource-manager/web/2023-12-01/domains/method_checkavailability.go new file mode 100644 index 00000000000..2e69c2d6caa --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_checkavailability.go @@ -0,0 +1,60 @@ +package domains + +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 CheckAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainAvailabilityCheckResult +} + +// CheckAvailability ... +func (c DomainsClient) CheckAvailability(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result CheckAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/checkDomainAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainAvailabilityCheckResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_createorupdate.go b/resource-manager/web/2023-12-01/domains/method_createorupdate.go new file mode 100644 index 00000000000..42b7775e27c --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_createorupdate.go @@ -0,0 +1,75 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// CreateOrUpdate ... +func (c DomainsClient) CreateOrUpdate(ctx context.Context, id DomainId, input Domain) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DomainsClient) CreateOrUpdateThenPoll(ctx context.Context, id DomainId, input Domain) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/domains/method_createorupdateownershipidentifier.go b/resource-manager/web/2023-12-01/domains/method_createorupdateownershipidentifier.go new file mode 100644 index 00000000000..65cf4646521 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_createorupdateownershipidentifier.go @@ -0,0 +1,58 @@ +package domains + +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 CreateOrUpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// CreateOrUpdateOwnershipIdentifier ... +func (c DomainsClient) CreateOrUpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result CreateOrUpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainOwnershipIdentifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_delete.go b/resource-manager/web/2023-12-01/domains/method_delete.go new file mode 100644 index 00000000000..67ba404cd4b --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_delete.go @@ -0,0 +1,76 @@ +package domains + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + ForceHardDeleteDomain *bool +} + +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.ForceHardDeleteDomain != nil { + out.Append("forceHardDeleteDomain", fmt.Sprintf("%v", *o.ForceHardDeleteDomain)) + } + return &out +} + +// Delete ... +func (c DomainsClient) Delete(ctx context.Context, id DomainId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_deleteownershipidentifier.go b/resource-manager/web/2023-12-01/domains/method_deleteownershipidentifier.go new file mode 100644 index 00000000000..d1367d2232d --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_deleteownershipidentifier.go @@ -0,0 +1,47 @@ +package domains + +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 DeleteOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteOwnershipIdentifier ... +func (c DomainsClient) DeleteOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_get.go b/resource-manager/web/2023-12-01/domains/method_get.go new file mode 100644 index 00000000000..b35fd82d944 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_get.go @@ -0,0 +1,54 @@ +package domains + +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 *Domain +} + +// Get ... +func (c DomainsClient) Get(ctx context.Context, id DomainId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Domain + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_getcontrolcenterssorequest.go b/resource-manager/web/2023-12-01/domains/method_getcontrolcenterssorequest.go new file mode 100644 index 00000000000..7bcdf455156 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_getcontrolcenterssorequest.go @@ -0,0 +1,56 @@ +package domains + +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 GetControlCenterSsoRequestOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainControlCenterSsoRequest +} + +// GetControlCenterSsoRequest ... +func (c DomainsClient) GetControlCenterSsoRequest(ctx context.Context, id commonids.SubscriptionId) (result GetControlCenterSsoRequestOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/generateSsoRequest", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainControlCenterSsoRequest + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_getownershipidentifier.go b/resource-manager/web/2023-12-01/domains/method_getownershipidentifier.go new file mode 100644 index 00000000000..d38f9734728 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_getownershipidentifier.go @@ -0,0 +1,54 @@ +package domains + +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 GetOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// GetOwnershipIdentifier ... +func (c DomainsClient) GetOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainOwnershipIdentifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_list.go b/resource-manager/web/2023-12-01/domains/method_list.go new file mode 100644 index 00000000000..cff6f4553d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_list.go @@ -0,0 +1,92 @@ +package domains + +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 *[]Domain +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Domain +} + +// List ... +func (c DomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (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.DomainRegistration/domains", 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 *[]Domain `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 DomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Domain, 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/web/2023-12-01/domains/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/domains/method_listbyresourcegroup.go new file mode 100644 index 00000000000..c02986bf4fd --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Domain +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Domain +} + +// ListByResourceGroup ... +func (c DomainsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", 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 *[]Domain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DomainsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DomainOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Domain, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_listownershipidentifiers.go b/resource-manager/web/2023-12-01/domains/method_listownershipidentifiers.go new file mode 100644 index 00000000000..3dc3000828d --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_listownershipidentifiers.go @@ -0,0 +1,91 @@ +package domains + +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 ListOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DomainOwnershipIdentifier +} + +type ListOwnershipIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []DomainOwnershipIdentifier +} + +// ListOwnershipIdentifiers ... +func (c DomainsClient) ListOwnershipIdentifiers(ctx context.Context, id DomainId) (result ListOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", 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 *[]DomainOwnershipIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListOwnershipIdentifiersComplete retrieves all the results into a single object +func (c DomainsClient) ListOwnershipIdentifiersComplete(ctx context.Context, id DomainId) (ListOwnershipIdentifiersCompleteResult, error) { + return c.ListOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, DomainOwnershipIdentifierOperationPredicate{}) +} + +// ListOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id DomainId, predicate DomainOwnershipIdentifierOperationPredicate) (result ListOwnershipIdentifiersCompleteResult, err error) { + items := make([]DomainOwnershipIdentifier, 0) + + resp, err := c.ListOwnershipIdentifiers(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 = ListOwnershipIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_listrecommendations.go b/resource-manager/web/2023-12-01/domains/method_listrecommendations.go new file mode 100644 index 00000000000..148c7af4de3 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_listrecommendations.go @@ -0,0 +1,92 @@ +package domains + +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 ListRecommendationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NameIdentifier +} + +type ListRecommendationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []NameIdentifier +} + +// ListRecommendations ... +func (c DomainsClient) ListRecommendations(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (result ListRecommendationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/listDomainRecommendations", 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 *[]NameIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendationsComplete retrieves all the results into a single object +func (c DomainsClient) ListRecommendationsComplete(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (ListRecommendationsCompleteResult, error) { + return c.ListRecommendationsCompleteMatchingPredicate(ctx, id, input, NameIdentifierOperationPredicate{}) +} + +// ListRecommendationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListRecommendationsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters, predicate NameIdentifierOperationPredicate) (result ListRecommendationsCompleteResult, err error) { + items := make([]NameIdentifier, 0) + + resp, err := c.ListRecommendations(ctx, id, input) + 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 = ListRecommendationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_renew.go b/resource-manager/web/2023-12-01/domains/method_renew.go new file mode 100644 index 00000000000..e3a9b6abefd --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_renew.go @@ -0,0 +1,49 @@ +package domains + +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 RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c DomainsClient) Renew(ctx context.Context, id DomainId) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_transferout.go b/resource-manager/web/2023-12-01/domains/method_transferout.go new file mode 100644 index 00000000000..e45926e87d5 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_transferout.go @@ -0,0 +1,55 @@ +package domains + +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 TransferOutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// TransferOut ... +func (c DomainsClient) TransferOut(ctx context.Context, id DomainId) (result TransferOutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/transferOut", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Domain + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_update.go b/resource-manager/web/2023-12-01/domains/method_update.go new file mode 100644 index 00000000000..f5705bd286a --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_update.go @@ -0,0 +1,59 @@ +package domains + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// Update ... +func (c DomainsClient) Update(ctx context.Context, id DomainId, input DomainPatchResource) (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 + } + + var model Domain + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/method_updateownershipidentifier.go b/resource-manager/web/2023-12-01/domains/method_updateownershipidentifier.go new file mode 100644 index 00000000000..3c23bdeecfc --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/method_updateownershipidentifier.go @@ -0,0 +1,58 @@ +package domains + +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 UpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// UpdateOwnershipIdentifier ... +func (c DomainsClient) UpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result UpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DomainOwnershipIdentifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/domains/model_address.go b/resource-manager/web/2023-12-01/domains/model_address.go new file mode 100644 index 00000000000..7d9d06d5e19 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_address.go @@ -0,0 +1,13 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Address struct { + Address1 string `json:"address1"` + Address2 *string `json:"address2,omitempty"` + City string `json:"city"` + Country string `json:"country"` + PostalCode string `json:"postalCode"` + State string `json:"state"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_contact.go b/resource-manager/web/2023-12-01/domains/model_contact.go new file mode 100644 index 00000000000..742a9691f02 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_contact.go @@ -0,0 +1,16 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Contact struct { + AddressMailing *Address `json:"addressMailing,omitempty"` + Email string `json:"email"` + Fax *string `json:"fax,omitempty"` + JobTitle *string `json:"jobTitle,omitempty"` + NameFirst string `json:"nameFirst"` + NameLast string `json:"nameLast"` + NameMiddle *string `json:"nameMiddle,omitempty"` + Organization *string `json:"organization,omitempty"` + Phone string `json:"phone"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_domain.go b/resource-manager/web/2023-12-01/domains/model_domain.go new file mode 100644 index 00000000000..2befd74efa0 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domain.go @@ -0,0 +1,14 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Domain struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DomainProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainavailabilitycheckresult.go b/resource-manager/web/2023-12-01/domains/model_domainavailabilitycheckresult.go new file mode 100644 index 00000000000..5e189d049c2 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainavailabilitycheckresult.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainAvailabilityCheckResult struct { + Available *bool `json:"available,omitempty"` + DomainType *DomainType `json:"domainType,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_domaincontrolcenterssorequest.go b/resource-manager/web/2023-12-01/domains/model_domaincontrolcenterssorequest.go new file mode 100644 index 00000000000..cddf04a4702 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domaincontrolcenterssorequest.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainControlCenterSsoRequest struct { + PostParameterKey *string `json:"postParameterKey,omitempty"` + PostParameterValue *string `json:"postParameterValue,omitempty"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainownershipidentifier.go b/resource-manager/web/2023-12-01/domains/model_domainownershipidentifier.go new file mode 100644 index 00000000000..b5ef7bbb733 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainownershipidentifier.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOwnershipIdentifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DomainOwnershipIdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainownershipidentifierproperties.go b/resource-manager/web/2023-12-01/domains/model_domainownershipidentifierproperties.go new file mode 100644 index 00000000000..64cd1600998 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainownershipidentifierproperties.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOwnershipIdentifierProperties struct { + OwnershipId *string `json:"ownershipId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainpatchresource.go b/resource-manager/web/2023-12-01/domains/model_domainpatchresource.go new file mode 100644 index 00000000000..3a744cc4328 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainpatchresource.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DomainPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainpatchresourceproperties.go b/resource-manager/web/2023-12-01/domains/model_domainpatchresourceproperties.go new file mode 100644 index 00000000000..aaec61895f2 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainpatchresourceproperties.go @@ -0,0 +1,69 @@ +package domains + +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 DomainPatchResourceProperties struct { + AuthCode *string `json:"authCode,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Consent DomainPurchaseConsent `json:"consent"` + ContactAdmin Contact `json:"contactAdmin"` + ContactBilling Contact `json:"contactBilling"` + ContactRegistrant Contact `json:"contactRegistrant"` + ContactTech Contact `json:"contactTech"` + CreatedTime *string `json:"createdTime,omitempty"` + DnsType *DnsType `json:"dnsType,omitempty"` + DnsZoneId *string `json:"dnsZoneId,omitempty"` + DomainNotRenewableReasons *[]ResourceNotRenewableReason `json:"domainNotRenewableReasons,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + LastRenewedTime *string `json:"lastRenewedTime,omitempty"` + ManagedHostNames *[]HostName `json:"managedHostNames,omitempty"` + NameServers *[]string `json:"nameServers,omitempty"` + Privacy *bool `json:"privacy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReadyForDnsRecordManagement *bool `json:"readyForDnsRecordManagement,omitempty"` + RegistrationStatus *DomainStatus `json:"registrationStatus,omitempty"` + TargetDnsType *DnsType `json:"targetDnsType,omitempty"` +} + +func (o *DomainPatchResourceProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *DomainPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *DomainPatchResourceProperties) GetLastRenewedTimeAsTime() (*time.Time, error) { + if o.LastRenewedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRenewedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetLastRenewedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRenewedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainproperties.go b/resource-manager/web/2023-12-01/domains/model_domainproperties.go new file mode 100644 index 00000000000..860ae366326 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainproperties.go @@ -0,0 +1,69 @@ +package domains + +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 DomainProperties struct { + AuthCode *string `json:"authCode,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Consent DomainPurchaseConsent `json:"consent"` + ContactAdmin Contact `json:"contactAdmin"` + ContactBilling Contact `json:"contactBilling"` + ContactRegistrant Contact `json:"contactRegistrant"` + ContactTech Contact `json:"contactTech"` + CreatedTime *string `json:"createdTime,omitempty"` + DnsType *DnsType `json:"dnsType,omitempty"` + DnsZoneId *string `json:"dnsZoneId,omitempty"` + DomainNotRenewableReasons *[]ResourceNotRenewableReason `json:"domainNotRenewableReasons,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + LastRenewedTime *string `json:"lastRenewedTime,omitempty"` + ManagedHostNames *[]HostName `json:"managedHostNames,omitempty"` + NameServers *[]string `json:"nameServers,omitempty"` + Privacy *bool `json:"privacy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReadyForDnsRecordManagement *bool `json:"readyForDnsRecordManagement,omitempty"` + RegistrationStatus *DomainStatus `json:"registrationStatus,omitempty"` + TargetDnsType *DnsType `json:"targetDnsType,omitempty"` +} + +func (o *DomainProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *DomainProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *DomainProperties) GetLastRenewedTimeAsTime() (*time.Time, error) { + if o.LastRenewedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRenewedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetLastRenewedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRenewedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainpurchaseconsent.go b/resource-manager/web/2023-12-01/domains/model_domainpurchaseconsent.go new file mode 100644 index 00000000000..afc6cdb7d25 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainpurchaseconsent.go @@ -0,0 +1,28 @@ +package domains + +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 DomainPurchaseConsent struct { + AgreedAt *string `json:"agreedAt,omitempty"` + AgreedBy *string `json:"agreedBy,omitempty"` + AgreementKeys *[]string `json:"agreementKeys,omitempty"` +} + +func (o *DomainPurchaseConsent) GetAgreedAtAsTime() (*time.Time, error) { + if o.AgreedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgreedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPurchaseConsent) SetAgreedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgreedAt = &formatted +} diff --git a/resource-manager/web/2023-12-01/domains/model_domainrecommendationsearchparameters.go b/resource-manager/web/2023-12-01/domains/model_domainrecommendationsearchparameters.go new file mode 100644 index 00000000000..161e93dc3aa --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_domainrecommendationsearchparameters.go @@ -0,0 +1,9 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainRecommendationSearchParameters struct { + Keywords *string `json:"keywords,omitempty"` + MaxDomainRecommendations *int64 `json:"maxDomainRecommendations,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_hostname.go b/resource-manager/web/2023-12-01/domains/model_hostname.go new file mode 100644 index 00000000000..e81ea21cc80 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_hostname.go @@ -0,0 +1,13 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostName struct { + AzureResourceName *string `json:"azureResourceName,omitempty"` + AzureResourceType *AzureResourceType `json:"azureResourceType,omitempty"` + CustomHostNameDnsRecordType *CustomHostNameDnsRecordType `json:"customHostNameDnsRecordType,omitempty"` + HostNameType *HostNameType `json:"hostNameType,omitempty"` + Name *string `json:"name,omitempty"` + SiteNames *[]string `json:"siteNames,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/model_nameidentifier.go b/resource-manager/web/2023-12-01/domains/model_nameidentifier.go new file mode 100644 index 00000000000..8602a243966 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/model_nameidentifier.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/domains/predicates.go b/resource-manager/web/2023-12-01/domains/predicates.go new file mode 100644 index 00000000000..dcd7e69873b --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/predicates.go @@ -0,0 +1,78 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p DomainOperationPredicate) Matches(input Domain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type DomainOwnershipIdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DomainOwnershipIdentifierOperationPredicate) Matches(input DomainOwnershipIdentifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type NameIdentifierOperationPredicate struct { + Name *string +} + +func (p NameIdentifierOperationPredicate) Matches(input NameIdentifier) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/web/2023-12-01/domains/version.go b/resource-manager/web/2023-12-01/domains/version.go new file mode 100644 index 00000000000..a8ce49cd186 --- /dev/null +++ b/resource-manager/web/2023-12-01/domains/version.go @@ -0,0 +1,12 @@ +package domains + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/domains/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/global/README.md b/resource-manager/web/2023-12-01/global/README.md new file mode 100644 index 00000000000..80330d420f0 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/global` Documentation + +The `global` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/global" +``` + + +### Client Initialization + +```go +client := global.NewGlobalClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GlobalClient.GetDeletedWebApp` + +```go +ctx := context.TODO() +id := global.NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteIdValue") + +read, err := client.GetDeletedWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `GlobalClient.GetDeletedWebAppSnapshots` + +```go +ctx := context.TODO() +id := global.NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteIdValue") + +read, err := client.GetDeletedWebAppSnapshots(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/web/2023-12-01/global/client.go b/resource-manager/web/2023-12-01/global/client.go new file mode 100644 index 00000000000..5fbdd990766 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/client.go @@ -0,0 +1,26 @@ +package global + +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 GlobalClient struct { + Client *resourcemanager.Client +} + +func NewGlobalClientWithBaseURI(sdkApi sdkEnv.Api) (*GlobalClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "global", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GlobalClient: %+v", err) + } + + return &GlobalClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/global/id_deletedsite.go b/resource-manager/web/2023-12-01/global/id_deletedsite.go new file mode 100644 index 00000000000..d227d82af96 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/id_deletedsite.go @@ -0,0 +1,121 @@ +package global + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeletedSiteId{}) +} + +var _ resourceids.ResourceId = &DeletedSiteId{} + +// DeletedSiteId is a struct representing the Resource ID for a Deleted Site +type DeletedSiteId struct { + SubscriptionId string + DeletedSiteId string +} + +// NewDeletedSiteID returns a new DeletedSiteId struct +func NewDeletedSiteID(subscriptionId string, deletedSiteId string) DeletedSiteId { + return DeletedSiteId{ + SubscriptionId: subscriptionId, + DeletedSiteId: deletedSiteId, + } +} + +// ParseDeletedSiteID parses 'input' into a DeletedSiteId +func ParseDeletedSiteID(input string) (*DeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedSiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeletedSiteIDInsensitively parses 'input' case-insensitively into a DeletedSiteId +// note: this method should only be used for API response data and not user input +func ParseDeletedSiteIDInsensitively(input string) (*DeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedSiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeletedSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.DeletedSiteId, ok = input.Parsed["deletedSiteId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deletedSiteId", input) + } + + return nil +} + +// ValidateDeletedSiteID checks that 'input' can be parsed as a Deleted Site ID +func ValidateDeletedSiteID(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 := ParseDeletedSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deleted Site ID +func (id DeletedSiteId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/deletedSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.DeletedSiteId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deleted Site ID +func (id DeletedSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticDeletedSites", "deletedSites", "deletedSites"), + resourceids.UserSpecifiedSegment("deletedSiteId", "deletedSiteIdValue"), + } +} + +// String returns a human-readable description of this Deleted Site ID +func (id DeletedSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Deleted Site: %q", id.DeletedSiteId), + } + return fmt.Sprintf("Deleted Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/global/id_deletedsite_test.go b/resource-manager/web/2023-12-01/global/id_deletedsite_test.go new file mode 100644 index 00000000000..79efd277a3a --- /dev/null +++ b/resource-manager/web/2023-12-01/global/id_deletedsite_test.go @@ -0,0 +1,237 @@ +package global + +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 = &DeletedSiteId{} + +func TestNewDeletedSiteID(t *testing.T) { + id := NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteIdValue") + + 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.DeletedSiteId != "deletedSiteIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'DeletedSiteId'", id.DeletedSiteId, "deletedSiteIdValue") + } +} + +func TestFormatDeletedSiteID(t *testing.T) { + actual := NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeletedSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteIdValue", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "deletedSiteIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestParseDeletedSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteIdValue", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "deletedSiteIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS/dElEtEdSiTeIdVaLuE", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "dElEtEdSiTeIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS/dElEtEdSiTeIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestSegmentsForDeletedSiteId(t *testing.T) { + segments := DeletedSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeletedSiteId 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/web/2023-12-01/global/method_getdeletedwebapp.go b/resource-manager/web/2023-12-01/global/method_getdeletedwebapp.go new file mode 100644 index 00000000000..52e449413d5 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/method_getdeletedwebapp.go @@ -0,0 +1,54 @@ +package global + +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 GetDeletedWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebApp ... +func (c GlobalClient) GetDeletedWebApp(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeletedSite + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/global/method_getdeletedwebappsnapshots.go b/resource-manager/web/2023-12-01/global/method_getdeletedwebappsnapshots.go new file mode 100644 index 00000000000..4b84e9cb927 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/method_getdeletedwebappsnapshots.go @@ -0,0 +1,55 @@ +package global + +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 GetDeletedWebAppSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +// GetDeletedWebAppSnapshots ... +func (c GlobalClient) GetDeletedWebAppSnapshots(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []Snapshot + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/global/model_deletedsite.go b/resource-manager/web/2023-12-01/global/model_deletedsite.go new file mode 100644 index 00000000000..99e49e47843 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/model_deletedsite.go @@ -0,0 +1,12 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSite struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedSiteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/global/model_deletedsiteproperties.go b/resource-manager/web/2023-12-01/global/model_deletedsiteproperties.go new file mode 100644 index 00000000000..3c42017baf5 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/model_deletedsiteproperties.go @@ -0,0 +1,15 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteProperties struct { + DeletedSiteId *int64 `json:"deletedSiteId,omitempty"` + DeletedSiteName *string `json:"deletedSiteName,omitempty"` + DeletedTimestamp *string `json:"deletedTimestamp,omitempty"` + GeoRegionName *string `json:"geoRegionName,omitempty"` + Kind *string `json:"kind,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Slot *string `json:"slot,omitempty"` + Subscription *string `json:"subscription,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/global/model_snapshot.go b/resource-manager/web/2023-12-01/global/model_snapshot.go new file mode 100644 index 00000000000..6bd24519f97 --- /dev/null +++ b/resource-manager/web/2023-12-01/global/model_snapshot.go @@ -0,0 +1,12 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snapshot struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/global/model_snapshotproperties.go b/resource-manager/web/2023-12-01/global/model_snapshotproperties.go new file mode 100644 index 00000000000..bbae9a0171c --- /dev/null +++ b/resource-manager/web/2023-12-01/global/model_snapshotproperties.go @@ -0,0 +1,8 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotProperties struct { + Time *string `json:"time,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/global/version.go b/resource-manager/web/2023-12-01/global/version.go new file mode 100644 index 00000000000..492bc81141b --- /dev/null +++ b/resource-manager/web/2023-12-01/global/version.go @@ -0,0 +1,12 @@ +package global + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/global/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/README.md b/resource-manager/web/2023-12-01/kubeenvironments/README.md new file mode 100644 index 00000000000..e8009b47d84 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/kubeenvironments` Documentation + +The `kubeenvironments` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/kubeenvironments" +``` + + +### Client Initialization + +```go +client := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `KubeEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentValue") + +payload := kubeenvironments.KubeEnvironment{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentValue") + +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: `KubeEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `KubeEnvironmentsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentValue") + +payload := kubeenvironments.KubeEnvironmentPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2023-12-01/kubeenvironments/client.go b/resource-manager/web/2023-12-01/kubeenvironments/client.go new file mode 100644 index 00000000000..a2db5e1aad1 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/client.go @@ -0,0 +1,26 @@ +package kubeenvironments + +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 KubeEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewKubeEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*KubeEnvironmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "kubeenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating KubeEnvironmentsClient: %+v", err) + } + + return &KubeEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/constants.go b/resource-manager/web/2023-12-01/kubeenvironments/constants.go new file mode 100644 index 00000000000..7aaae27eece --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/constants.go @@ -0,0 +1,157 @@ +package kubeenvironments + +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 FrontEndServiceType string + +const ( + FrontEndServiceTypeLoadBalancer FrontEndServiceType = "LoadBalancer" + FrontEndServiceTypeNodePort FrontEndServiceType = "NodePort" +) + +func PossibleValuesForFrontEndServiceType() []string { + return []string{ + string(FrontEndServiceTypeLoadBalancer), + string(FrontEndServiceTypeNodePort), + } +} + +func (s *FrontEndServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrontEndServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFrontEndServiceType(input string) (*FrontEndServiceType, error) { + vals := map[string]FrontEndServiceType{ + "loadbalancer": FrontEndServiceTypeLoadBalancer, + "nodeport": FrontEndServiceTypeNodePort, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FrontEndServiceType(input) + return &out, nil +} + +type KubeEnvironmentProvisioningState string + +const ( + KubeEnvironmentProvisioningStateCanceled KubeEnvironmentProvisioningState = "Canceled" + KubeEnvironmentProvisioningStateFailed KubeEnvironmentProvisioningState = "Failed" + KubeEnvironmentProvisioningStateInfrastructureSetupComplete KubeEnvironmentProvisioningState = "InfrastructureSetupComplete" + KubeEnvironmentProvisioningStateInfrastructureSetupInProgress KubeEnvironmentProvisioningState = "InfrastructureSetupInProgress" + KubeEnvironmentProvisioningStateInitializationInProgress KubeEnvironmentProvisioningState = "InitializationInProgress" + KubeEnvironmentProvisioningStateScheduledForDelete KubeEnvironmentProvisioningState = "ScheduledForDelete" + KubeEnvironmentProvisioningStateSucceeded KubeEnvironmentProvisioningState = "Succeeded" + KubeEnvironmentProvisioningStateUpgradeFailed KubeEnvironmentProvisioningState = "UpgradeFailed" + KubeEnvironmentProvisioningStateUpgradeRequested KubeEnvironmentProvisioningState = "UpgradeRequested" + KubeEnvironmentProvisioningStateWaiting KubeEnvironmentProvisioningState = "Waiting" +) + +func PossibleValuesForKubeEnvironmentProvisioningState() []string { + return []string{ + string(KubeEnvironmentProvisioningStateCanceled), + string(KubeEnvironmentProvisioningStateFailed), + string(KubeEnvironmentProvisioningStateInfrastructureSetupComplete), + string(KubeEnvironmentProvisioningStateInfrastructureSetupInProgress), + string(KubeEnvironmentProvisioningStateInitializationInProgress), + string(KubeEnvironmentProvisioningStateScheduledForDelete), + string(KubeEnvironmentProvisioningStateSucceeded), + string(KubeEnvironmentProvisioningStateUpgradeFailed), + string(KubeEnvironmentProvisioningStateUpgradeRequested), + string(KubeEnvironmentProvisioningStateWaiting), + } +} + +func (s *KubeEnvironmentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeEnvironmentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubeEnvironmentProvisioningState(input string) (*KubeEnvironmentProvisioningState, error) { + vals := map[string]KubeEnvironmentProvisioningState{ + "canceled": KubeEnvironmentProvisioningStateCanceled, + "failed": KubeEnvironmentProvisioningStateFailed, + "infrastructuresetupcomplete": KubeEnvironmentProvisioningStateInfrastructureSetupComplete, + "infrastructuresetupinprogress": KubeEnvironmentProvisioningStateInfrastructureSetupInProgress, + "initializationinprogress": KubeEnvironmentProvisioningStateInitializationInProgress, + "scheduledfordelete": KubeEnvironmentProvisioningStateScheduledForDelete, + "succeeded": KubeEnvironmentProvisioningStateSucceeded, + "upgradefailed": KubeEnvironmentProvisioningStateUpgradeFailed, + "upgraderequested": KubeEnvironmentProvisioningStateUpgradeRequested, + "waiting": KubeEnvironmentProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubeEnvironmentProvisioningState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeLocalNode StorageType = "LocalNode" + StorageTypeNetworkFileSystem StorageType = "NetworkFileSystem" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeLocalNode), + string(StorageTypeNetworkFileSystem), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "localnode": StorageTypeLocalNode, + "networkfilesystem": StorageTypeNetworkFileSystem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment.go b/resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment.go new file mode 100644 index 00000000000..020e8fa0f30 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment.go @@ -0,0 +1,130 @@ +package kubeenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&KubeEnvironmentId{}) +} + +var _ resourceids.ResourceId = &KubeEnvironmentId{} + +// KubeEnvironmentId is a struct representing the Resource ID for a Kube Environment +type KubeEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + KubeEnvironmentName string +} + +// NewKubeEnvironmentID returns a new KubeEnvironmentId struct +func NewKubeEnvironmentID(subscriptionId string, resourceGroupName string, kubeEnvironmentName string) KubeEnvironmentId { + return KubeEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + KubeEnvironmentName: kubeEnvironmentName, + } +} + +// ParseKubeEnvironmentID parses 'input' into a KubeEnvironmentId +func ParseKubeEnvironmentID(input string) (*KubeEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubeEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubeEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKubeEnvironmentIDInsensitively parses 'input' case-insensitively into a KubeEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseKubeEnvironmentIDInsensitively(input string) (*KubeEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubeEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubeEnvironmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KubeEnvironmentId) 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.KubeEnvironmentName, ok = input.Parsed["kubeEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "kubeEnvironmentName", input) + } + + return nil +} + +// ValidateKubeEnvironmentID checks that 'input' can be parsed as a Kube Environment ID +func ValidateKubeEnvironmentID(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 := ParseKubeEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Kube Environment ID +func (id KubeEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/kubeEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.KubeEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Kube Environment ID +func (id KubeEnvironmentId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticKubeEnvironments", "kubeEnvironments", "kubeEnvironments"), + resourceids.UserSpecifiedSegment("kubeEnvironmentName", "kubeEnvironmentValue"), + } +} + +// String returns a human-readable description of this Kube Environment ID +func (id KubeEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Kube Environment Name: %q", id.KubeEnvironmentName), + } + return fmt.Sprintf("Kube Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment_test.go b/resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment_test.go new file mode 100644 index 00000000000..9c2d04b8567 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/id_kubeenvironment_test.go @@ -0,0 +1,282 @@ +package kubeenvironments + +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 = &KubeEnvironmentId{} + +func TestNewKubeEnvironmentID(t *testing.T) { + id := NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentValue") + + 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.KubeEnvironmentName != "kubeEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'KubeEnvironmentName'", id.KubeEnvironmentName, "kubeEnvironmentValue") + } +} + +func TestFormatKubeEnvironmentID(t *testing.T) { + actual := NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKubeEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubeEnvironmentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentValue", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubeEnvironmentName: "kubeEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubeEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.KubeEnvironmentName != v.Expected.KubeEnvironmentName { + t.Fatalf("Expected %q but got %q for KubeEnvironmentName", v.Expected.KubeEnvironmentName, actual.KubeEnvironmentName) + } + + } +} + +func TestParseKubeEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubeEnvironmentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/kUbEeNvIrOnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentValue", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubeEnvironmentName: "kubeEnvironmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/kUbEeNvIrOnMeNtS/kUbEeNvIrOnMeNtVaLuE", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + KubeEnvironmentName: "kUbEeNvIrOnMeNtVaLuE", + }, + }, + { + // 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.wEb/kUbEeNvIrOnMeNtS/kUbEeNvIrOnMeNtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubeEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.KubeEnvironmentName != v.Expected.KubeEnvironmentName { + t.Fatalf("Expected %q but got %q for KubeEnvironmentName", v.Expected.KubeEnvironmentName, actual.KubeEnvironmentName) + } + + } +} + +func TestSegmentsForKubeEnvironmentId(t *testing.T) { + segments := KubeEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KubeEnvironmentId 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/web/2023-12-01/kubeenvironments/method_createorupdate.go b/resource-manager/web/2023-12-01/kubeenvironments/method_createorupdate.go new file mode 100644 index 00000000000..e6af85b34b3 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/method_createorupdate.go @@ -0,0 +1,75 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// CreateOrUpdate ... +func (c KubeEnvironmentsClient) CreateOrUpdate(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c KubeEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/method_delete.go b/resource-manager/web/2023-12-01/kubeenvironments/method_delete.go new file mode 100644 index 00000000000..9a86ed36127 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/method_delete.go @@ -0,0 +1,71 @@ +package kubeenvironments + +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 KubeEnvironmentsClient) Delete(ctx context.Context, id KubeEnvironmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 KubeEnvironmentsClient) DeleteThenPoll(ctx context.Context, id KubeEnvironmentId) 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/web/2023-12-01/kubeenvironments/method_get.go b/resource-manager/web/2023-12-01/kubeenvironments/method_get.go new file mode 100644 index 00000000000..9c19f1d0522 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/method_get.go @@ -0,0 +1,54 @@ +package kubeenvironments + +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 *KubeEnvironment +} + +// Get ... +func (c KubeEnvironmentsClient) Get(ctx context.Context, id KubeEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KubeEnvironment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/kubeenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..91dd33670fb --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubeEnvironment +} + +// ListByResourceGroup ... +func (c KubeEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", 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 *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate KubeEnvironmentOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/method_listbysubscription.go b/resource-manager/web/2023-12-01/kubeenvironments/method_listbysubscription.go new file mode 100644 index 00000000000..2d275a36792 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/method_listbysubscription.go @@ -0,0 +1,92 @@ +package kubeenvironments + +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 ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubeEnvironment +} + +// ListBySubscription ... +func (c KubeEnvironmentsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", 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 *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate KubeEnvironmentOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/method_update.go b/resource-manager/web/2023-12-01/kubeenvironments/method_update.go new file mode 100644 index 00000000000..5af2a9f0da9 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/method_update.go @@ -0,0 +1,59 @@ +package kubeenvironments + +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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// Update ... +func (c KubeEnvironmentsClient) Update(ctx context.Context, id KubeEnvironmentId, input KubeEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + 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 + } + + var model KubeEnvironment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_applogsconfiguration.go b/resource-manager/web/2023-12-01/kubeenvironments/model_applogsconfiguration.go new file mode 100644 index 00000000000..1d001f4eb4b --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_applogsconfiguration.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppLogsConfiguration struct { + Destination *string `json:"destination,omitempty"` + LogAnalyticsConfiguration *LogAnalyticsConfiguration `json:"logAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_arcconfiguration.go b/resource-manager/web/2023-12-01/kubeenvironments/model_arcconfiguration.go new file mode 100644 index 00000000000..a3340b2ff85 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_arcconfiguration.go @@ -0,0 +1,14 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArcConfiguration struct { + ArtifactStorageAccessMode *string `json:"artifactStorageAccessMode,omitempty"` + ArtifactStorageClassName *string `json:"artifactStorageClassName,omitempty"` + ArtifactStorageMountPath *string `json:"artifactStorageMountPath,omitempty"` + ArtifactStorageNodeName *string `json:"artifactStorageNodeName,omitempty"` + ArtifactsStorageType *StorageType `json:"artifactsStorageType,omitempty"` + FrontEndServiceConfiguration *FrontEndConfiguration `json:"frontEndServiceConfiguration,omitempty"` + KubeConfig *string `json:"kubeConfig,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_containerappsconfiguration.go b/resource-manager/web/2023-12-01/kubeenvironments/model_containerappsconfiguration.go new file mode 100644 index 00000000000..8d72c14cee2 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_containerappsconfiguration.go @@ -0,0 +1,13 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppsConfiguration struct { + AppSubnetResourceId *string `json:"appSubnetResourceId,omitempty"` + ControlPlaneSubnetResourceId *string `json:"controlPlaneSubnetResourceId,omitempty"` + DaprAIInstrumentationKey *string `json:"daprAIInstrumentationKey,omitempty"` + DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"` + PlatformReservedCidr *string `json:"platformReservedCidr,omitempty"` + PlatformReservedDnsIP *string `json:"platformReservedDnsIP,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_extendedlocation.go b/resource-manager/web/2023-12-01/kubeenvironments/model_extendedlocation.go new file mode 100644 index 00000000000..616cec03daa --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_extendedlocation.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_frontendconfiguration.go b/resource-manager/web/2023-12-01/kubeenvironments/model_frontendconfiguration.go new file mode 100644 index 00000000000..c19181a1257 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_frontendconfiguration.go @@ -0,0 +1,8 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontEndConfiguration struct { + Kind *FrontEndServiceType `json:"kind,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironment.go b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironment.go new file mode 100644 index 00000000000..d57722efdef --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironment.go @@ -0,0 +1,15 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironment struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *KubeEnvironmentProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresource.go b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresource.go new file mode 100644 index 00000000000..912ea3cb9c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresource.go @@ -0,0 +1,12 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *KubeEnvironmentPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go new file mode 100644 index 00000000000..49c9bfaabc1 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go @@ -0,0 +1,16 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentPatchResourceProperties struct { + AksResourceID *string `json:"aksResourceID,omitempty"` + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + ArcConfiguration *ArcConfiguration `json:"arcConfiguration,omitempty"` + ContainerAppsConfiguration *ContainerAppsConfiguration `json:"containerAppsConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + InternalLoadBalancerEnabled *bool `json:"internalLoadBalancerEnabled,omitempty"` + ProvisioningState *KubeEnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentproperties.go b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentproperties.go new file mode 100644 index 00000000000..c56c83c5220 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_kubeenvironmentproperties.go @@ -0,0 +1,17 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProperties struct { + AksResourceID *string `json:"aksResourceID,omitempty"` + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + ArcConfiguration *ArcConfiguration `json:"arcConfiguration,omitempty"` + ContainerAppsConfiguration *ContainerAppsConfiguration `json:"containerAppsConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + EnvironmentType *string `json:"environmentType,omitempty"` + InternalLoadBalancerEnabled *bool `json:"internalLoadBalancerEnabled,omitempty"` + ProvisioningState *KubeEnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/model_loganalyticsconfiguration.go b/resource-manager/web/2023-12-01/kubeenvironments/model_loganalyticsconfiguration.go new file mode 100644 index 00000000000..0e361710361 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/model_loganalyticsconfiguration.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsConfiguration struct { + CustomerId *string `json:"customerId,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/predicates.go b/resource-manager/web/2023-12-01/kubeenvironments/predicates.go new file mode 100644 index 00000000000..cf25ede1f18 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/predicates.go @@ -0,0 +1,37 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p KubeEnvironmentOperationPredicate) Matches(input KubeEnvironment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2023-12-01/kubeenvironments/version.go b/resource-manager/web/2023-12-01/kubeenvironments/version.go new file mode 100644 index 00000000000..886052ef4b2 --- /dev/null +++ b/resource-manager/web/2023-12-01/kubeenvironments/version.go @@ -0,0 +1,12 @@ +package kubeenvironments + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/kubeenvironments/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/provider/README.md b/resource-manager/web/2023-12-01/provider/README.md new file mode 100644 index 00000000000..b59d05b5811 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/provider` Documentation + +The `provider` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/provider" +``` + + +### Client Initialization + +```go +client := provider.NewProviderClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProviderClient.GetAvailableStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetAvailableStacks(ctx, provider.DefaultGetAvailableStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetAvailableStacksComplete(ctx, provider.DefaultGetAvailableStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetAvailableStacksOnPrem` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.GetAvailableStacksOnPrem(ctx, id, provider.DefaultGetAvailableStacksOnPremOperationOptions())` can be used to do batched pagination +items, err := client.GetAvailableStacksOnPremComplete(ctx, id, provider.DefaultGetAvailableStacksOnPremOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetFunctionAppStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetFunctionAppStacks(ctx, provider.DefaultGetFunctionAppStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetFunctionAppStacksComplete(ctx, provider.DefaultGetFunctionAppStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetFunctionAppStacksForLocation` + +```go +ctx := context.TODO() +id := provider.NewLocationID("locationValue") + +// alternatively `client.GetFunctionAppStacksForLocation(ctx, id, provider.DefaultGetFunctionAppStacksForLocationOperationOptions())` can be used to do batched pagination +items, err := client.GetFunctionAppStacksForLocationComplete(ctx, id, provider.DefaultGetFunctionAppStacksForLocationOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetWebAppStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetWebAppStacks(ctx, provider.DefaultGetWebAppStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetWebAppStacksComplete(ctx, provider.DefaultGetWebAppStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetWebAppStacksForLocation` + +```go +ctx := context.TODO() +id := provider.NewLocationID("locationValue") + +// alternatively `client.GetWebAppStacksForLocation(ctx, id, provider.DefaultGetWebAppStacksForLocationOperationOptions())` can be used to do batched pagination +items, err := client.GetWebAppStacksForLocationComplete(ctx, id, provider.DefaultGetWebAppStacksForLocationOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/provider/client.go b/resource-manager/web/2023-12-01/provider/client.go new file mode 100644 index 00000000000..2128fec9d6f --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/client.go @@ -0,0 +1,26 @@ +package provider + +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 ProviderClient struct { + Client *resourcemanager.Client +} + +func NewProviderClientWithBaseURI(sdkApi sdkEnv.Api) (*ProviderClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "provider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProviderClient: %+v", err) + } + + return &ProviderClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/provider/constants.go b/resource-manager/web/2023-12-01/provider/constants.go new file mode 100644 index 00000000000..27444d5870f --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/constants.go @@ -0,0 +1,145 @@ +package provider + +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 ProviderOsTypeSelected string + +const ( + ProviderOsTypeSelectedAll ProviderOsTypeSelected = "All" + ProviderOsTypeSelectedLinux ProviderOsTypeSelected = "Linux" + ProviderOsTypeSelectedLinuxFunctions ProviderOsTypeSelected = "LinuxFunctions" + ProviderOsTypeSelectedWindows ProviderOsTypeSelected = "Windows" + ProviderOsTypeSelectedWindowsFunctions ProviderOsTypeSelected = "WindowsFunctions" +) + +func PossibleValuesForProviderOsTypeSelected() []string { + return []string{ + string(ProviderOsTypeSelectedAll), + string(ProviderOsTypeSelectedLinux), + string(ProviderOsTypeSelectedLinuxFunctions), + string(ProviderOsTypeSelectedWindows), + string(ProviderOsTypeSelectedWindowsFunctions), + } +} + +func (s *ProviderOsTypeSelected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderOsTypeSelected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProviderOsTypeSelected(input string) (*ProviderOsTypeSelected, error) { + vals := map[string]ProviderOsTypeSelected{ + "all": ProviderOsTypeSelectedAll, + "linux": ProviderOsTypeSelectedLinux, + "linuxfunctions": ProviderOsTypeSelectedLinuxFunctions, + "windows": ProviderOsTypeSelectedWindows, + "windowsfunctions": ProviderOsTypeSelectedWindowsFunctions, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProviderOsTypeSelected(input) + return &out, nil +} + +type ProviderStackOsType string + +const ( + ProviderStackOsTypeAll ProviderStackOsType = "All" + ProviderStackOsTypeLinux ProviderStackOsType = "Linux" + ProviderStackOsTypeWindows ProviderStackOsType = "Windows" +) + +func PossibleValuesForProviderStackOsType() []string { + return []string{ + string(ProviderStackOsTypeAll), + string(ProviderStackOsTypeLinux), + string(ProviderStackOsTypeWindows), + } +} + +func (s *ProviderStackOsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderStackOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProviderStackOsType(input string) (*ProviderStackOsType, error) { + vals := map[string]ProviderStackOsType{ + "all": ProviderStackOsTypeAll, + "linux": ProviderStackOsTypeLinux, + "windows": ProviderStackOsTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProviderStackOsType(input) + return &out, nil +} + +type StackPreferredOs string + +const ( + StackPreferredOsLinux StackPreferredOs = "Linux" + StackPreferredOsWindows StackPreferredOs = "Windows" +) + +func PossibleValuesForStackPreferredOs() []string { + return []string{ + string(StackPreferredOsLinux), + string(StackPreferredOsWindows), + } +} + +func (s *StackPreferredOs) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStackPreferredOs(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStackPreferredOs(input string) (*StackPreferredOs, error) { + vals := map[string]StackPreferredOs{ + "linux": StackPreferredOsLinux, + "windows": StackPreferredOsWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StackPreferredOs(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/provider/id_location.go b/resource-manager/web/2023-12-01/provider/id_location.go new file mode 100644 index 00000000000..e746f1b1c9e --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/id_location.go @@ -0,0 +1,112 @@ +package provider + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(locationName string) LocationId { + return LocationId{ + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/provider/id_location_test.go b/resource-manager/web/2023-12-01/provider/id_location_test.go new file mode 100644 index 00000000000..4027abf1c15 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/id_location_test.go @@ -0,0 +1,192 @@ +package provider + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("locationValue") + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("locationValue").ID() + expected := "/providers/Microsoft.Web/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/locations/locationValue", + Expected: &LocationId{ + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/locations/locationValue", + Expected: &LocationId{ + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2023-12-01/provider/method_getavailablestacks.go b/resource-manager/web/2023-12-01/provider/method_getavailablestacks.go new file mode 100644 index 00000000000..28653d05402 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/method_getavailablestacks.go @@ -0,0 +1,119 @@ +package provider + +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 GetAvailableStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationStackResource +} + +type GetAvailableStacksOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOperationOptions() GetAvailableStacksOperationOptions { + return GetAvailableStacksOperationOptions{} +} + +func (o GetAvailableStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetAvailableStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +// GetAvailableStacks ... +func (c ProviderClient) GetAvailableStacks(ctx context.Context, options GetAvailableStacksOperationOptions) (result GetAvailableStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/availableStacks", + 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 *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksComplete(ctx context.Context, options GetAvailableStacksOperationOptions) (GetAvailableStacksCompleteResult, error) { + return c.GetAvailableStacksCompleteMatchingPredicate(ctx, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksCompleteMatchingPredicate(ctx context.Context, options GetAvailableStacksOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacks(ctx, 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 = GetAvailableStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/provider/method_getavailablestacksonprem.go b/resource-manager/web/2023-12-01/provider/method_getavailablestacksonprem.go new file mode 100644 index 00000000000..80da3d51ad7 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/method_getavailablestacksonprem.go @@ -0,0 +1,120 @@ +package provider + +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 GetAvailableStacksOnPremOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksOnPremCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationStackResource +} + +type GetAvailableStacksOnPremOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOnPremOperationOptions() GetAvailableStacksOnPremOperationOptions { + return GetAvailableStacksOnPremOperationOptions{} +} + +func (o GetAvailableStacksOnPremOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +// GetAvailableStacksOnPrem ... +func (c ProviderClient) GetAvailableStacksOnPrem(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (result GetAvailableStacksOnPremOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/availableStacks", 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 *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksOnPremComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksOnPremComplete(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (GetAvailableStacksOnPremCompleteResult, error) { + return c.GetAvailableStacksOnPremCompleteMatchingPredicate(ctx, id, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksOnPremCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksOnPremCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksOnPremCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacksOnPrem(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 = GetAvailableStacksOnPremCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/provider/method_getfunctionappstacks.go b/resource-manager/web/2023-12-01/provider/method_getfunctionappstacks.go new file mode 100644 index 00000000000..562db9a26cb --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/method_getfunctionappstacks.go @@ -0,0 +1,119 @@ +package provider + +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 GetFunctionAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionAppStack +} + +type GetFunctionAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksOperationOptions() GetFunctionAppStacksOperationOptions { + return GetFunctionAppStacksOperationOptions{} +} + +func (o GetFunctionAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetFunctionAppStacks ... +func (c ProviderClient) GetFunctionAppStacks(ctx context.Context, options GetFunctionAppStacksOperationOptions) (result GetFunctionAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/functionAppStacks", + 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 *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksComplete(ctx context.Context, options GetFunctionAppStacksOperationOptions) (GetFunctionAppStacksCompleteResult, error) { + return c.GetFunctionAppStacksCompleteMatchingPredicate(ctx, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksCompleteMatchingPredicate(ctx context.Context, options GetFunctionAppStacksOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacks(ctx, 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 = GetFunctionAppStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/provider/method_getfunctionappstacksforlocation.go b/resource-manager/web/2023-12-01/provider/method_getfunctionappstacksforlocation.go new file mode 100644 index 00000000000..19e9179c70f --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/method_getfunctionappstacksforlocation.go @@ -0,0 +1,119 @@ +package provider + +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 GetFunctionAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksForLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionAppStack +} + +type GetFunctionAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksForLocationOperationOptions() GetFunctionAppStacksForLocationOperationOptions { + return GetFunctionAppStacksForLocationOperationOptions{} +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetFunctionAppStacksForLocation ... +func (c ProviderClient) GetFunctionAppStacksForLocation(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (result GetFunctionAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functionAppStacks", 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 *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (GetFunctionAppStacksForLocationCompleteResult, error) { + return c.GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksForLocationCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacksForLocation(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 = GetFunctionAppStacksForLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/provider/method_getwebappstacks.go b/resource-manager/web/2023-12-01/provider/method_getwebappstacks.go new file mode 100644 index 00000000000..42aefc173b9 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/method_getwebappstacks.go @@ -0,0 +1,119 @@ +package provider + +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 GetWebAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebAppStack +} + +type GetWebAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksOperationOptions() GetWebAppStacksOperationOptions { + return GetWebAppStacksOperationOptions{} +} + +func (o GetWebAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetWebAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetWebAppStacks ... +func (c ProviderClient) GetWebAppStacks(ctx context.Context, options GetWebAppStacksOperationOptions) (result GetWebAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/webAppStacks", + 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 *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksComplete(ctx context.Context, options GetWebAppStacksOperationOptions) (GetWebAppStacksCompleteResult, error) { + return c.GetWebAppStacksCompleteMatchingPredicate(ctx, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksCompleteMatchingPredicate(ctx context.Context, options GetWebAppStacksOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacks(ctx, 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 = GetWebAppStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/provider/method_getwebappstacksforlocation.go b/resource-manager/web/2023-12-01/provider/method_getwebappstacksforlocation.go new file mode 100644 index 00000000000..ebacd71b695 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/method_getwebappstacksforlocation.go @@ -0,0 +1,119 @@ +package provider + +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 GetWebAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksForLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebAppStack +} + +type GetWebAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksForLocationOperationOptions() GetWebAppStacksForLocationOperationOptions { + return GetWebAppStacksForLocationOperationOptions{} +} + +func (o GetWebAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +// GetWebAppStacksForLocation ... +func (c ProviderClient) GetWebAppStacksForLocation(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (result GetWebAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/webAppStacks", 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 *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (GetWebAppStacksForLocationCompleteResult, error) { + return c.GetWebAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksForLocationCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacksForLocation(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 = GetWebAppStacksForLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/provider/model_appinsightswebappstacksettings.go b/resource-manager/web/2023-12-01/provider/model_appinsightswebappstacksettings.go new file mode 100644 index 00000000000..33c98c5a840 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_appinsightswebappstacksettings.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppInsightsWebAppStackSettings struct { + IsDefaultOff *bool `json:"isDefaultOff,omitempty"` + IsSupported *bool `json:"isSupported,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_applicationstack.go b/resource-manager/web/2023-12-01/provider/model_applicationstack.go new file mode 100644 index 00000000000..2f4a241919a --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_applicationstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStack struct { + Dependency *string `json:"dependency,omitempty"` + Display *string `json:"display,omitempty"` + Frameworks *[]ApplicationStack `json:"frameworks,omitempty"` + IsDeprecated *[]ApplicationStack `json:"isDeprecated,omitempty"` + MajorVersions *[]StackMajorVersion `json:"majorVersions,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_applicationstackresource.go b/resource-manager/web/2023-12-01/provider/model_applicationstackresource.go new file mode 100644 index 00000000000..6257ea657ae --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_applicationstackresource.go @@ -0,0 +1,12 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStackResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationStack `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_functionappmajorversion.go b/resource-manager/web/2023-12-01/provider/model_functionappmajorversion.go new file mode 100644 index 00000000000..b256d10d2d2 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_functionappmajorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppMajorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + MinorVersions *[]FunctionAppMinorVersion `json:"minorVersions,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_functionappminorversion.go b/resource-manager/web/2023-12-01/provider/model_functionappminorversion.go new file mode 100644 index 00000000000..2fdcc030a72 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_functionappminorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppMinorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + StackSettings *FunctionAppRuntimes `json:"stackSettings,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_functionappruntimes.go b/resource-manager/web/2023-12-01/provider/model_functionappruntimes.go new file mode 100644 index 00000000000..8c3b2a595f1 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_functionappruntimes.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppRuntimes struct { + LinuxRuntimeSettings *FunctionAppRuntimeSettings `json:"linuxRuntimeSettings,omitempty"` + WindowsRuntimeSettings *FunctionAppRuntimeSettings `json:"windowsRuntimeSettings,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_functionappruntimesettings.go b/resource-manager/web/2023-12-01/provider/model_functionappruntimesettings.go new file mode 100644 index 00000000000..14b93765b39 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_functionappruntimesettings.go @@ -0,0 +1,39 @@ +package provider + +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 FunctionAppRuntimeSettings struct { + AppInsightsSettings *AppInsightsWebAppStackSettings `json:"appInsightsSettings,omitempty"` + AppSettingsDictionary *map[string]string `json:"appSettingsDictionary,omitempty"` + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + GitHubActionSettings *GitHubActionWebAppStackSettings `json:"gitHubActionSettings,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + RemoteDebuggingSupported *bool `json:"remoteDebuggingSupported,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + SiteConfigPropertiesDictionary *SiteConfigPropertiesDictionary `json:"siteConfigPropertiesDictionary,omitempty"` + SupportedFunctionsExtensionVersions *[]string `json:"supportedFunctionsExtensionVersions,omitempty"` +} + +func (o *FunctionAppRuntimeSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *FunctionAppRuntimeSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2023-12-01/provider/model_functionappstack.go b/resource-manager/web/2023-12-01/provider/model_functionappstack.go new file mode 100644 index 00000000000..e4237db1a8b --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_functionappstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppStack struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FunctionAppStackProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_functionappstackproperties.go b/resource-manager/web/2023-12-01/provider/model_functionappstackproperties.go new file mode 100644 index 00000000000..fdc2ac67ad2 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_functionappstackproperties.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppStackProperties struct { + DisplayText *string `json:"displayText,omitempty"` + MajorVersions *[]FunctionAppMajorVersion `json:"majorVersions,omitempty"` + PreferredOs *StackPreferredOs `json:"preferredOs,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_githubactionwebappstacksettings.go b/resource-manager/web/2023-12-01/provider/model_githubactionwebappstacksettings.go new file mode 100644 index 00000000000..e43a56abbf1 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_githubactionwebappstacksettings.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionWebAppStackSettings struct { + IsSupported *bool `json:"isSupported,omitempty"` + SupportedVersion *string `json:"supportedVersion,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_linuxjavacontainersettings.go b/resource-manager/web/2023-12-01/provider/model_linuxjavacontainersettings.go new file mode 100644 index 00000000000..9f872d51929 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_linuxjavacontainersettings.go @@ -0,0 +1,33 @@ +package provider + +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 LinuxJavaContainerSettings struct { + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + Java11Runtime *string `json:"java11Runtime,omitempty"` + Java8Runtime *string `json:"java8Runtime,omitempty"` +} + +func (o *LinuxJavaContainerSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *LinuxJavaContainerSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2023-12-01/provider/model_siteconfigpropertiesdictionary.go b/resource-manager/web/2023-12-01/provider/model_siteconfigpropertiesdictionary.go new file mode 100644 index 00000000000..a0f34e1f2c6 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_siteconfigpropertiesdictionary.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigPropertiesDictionary struct { + JavaVersion *string `json:"javaVersion,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_stackmajorversion.go b/resource-manager/web/2023-12-01/provider/model_stackmajorversion.go new file mode 100644 index 00000000000..3790b4a134a --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_stackmajorversion.go @@ -0,0 +1,17 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackMajorVersion struct { + AppSettingsDictionary *map[string]interface{} `json:"appSettingsDictionary,omitempty"` + ApplicationInsights *bool `json:"applicationInsights,omitempty"` + DisplayVersion *string `json:"displayVersion,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + MinorVersions *[]StackMinorVersion `json:"minorVersions,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + SiteConfigPropertiesDictionary *map[string]interface{} `json:"siteConfigPropertiesDictionary,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_stackminorversion.go b/resource-manager/web/2023-12-01/provider/model_stackminorversion.go new file mode 100644 index 00000000000..7cd0a233af1 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_stackminorversion.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackMinorVersion struct { + DisplayVersion *string `json:"displayVersion,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsRemoteDebuggingEnabled *bool `json:"isRemoteDebuggingEnabled,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_webappmajorversion.go b/resource-manager/web/2023-12-01/provider/model_webappmajorversion.go new file mode 100644 index 00000000000..14ddab92252 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_webappmajorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppMajorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + MinorVersions *[]WebAppMinorVersion `json:"minorVersions,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_webappminorversion.go b/resource-manager/web/2023-12-01/provider/model_webappminorversion.go new file mode 100644 index 00000000000..c38aae7508d --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_webappminorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppMinorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + StackSettings *WebAppRuntimes `json:"stackSettings,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_webappruntimes.go b/resource-manager/web/2023-12-01/provider/model_webappruntimes.go new file mode 100644 index 00000000000..d5d1d7691d1 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_webappruntimes.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppRuntimes struct { + LinuxContainerSettings *LinuxJavaContainerSettings `json:"linuxContainerSettings,omitempty"` + LinuxRuntimeSettings *WebAppRuntimeSettings `json:"linuxRuntimeSettings,omitempty"` + WindowsContainerSettings *WindowsJavaContainerSettings `json:"windowsContainerSettings,omitempty"` + WindowsRuntimeSettings *WebAppRuntimeSettings `json:"windowsRuntimeSettings,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_webappruntimesettings.go b/resource-manager/web/2023-12-01/provider/model_webappruntimesettings.go new file mode 100644 index 00000000000..f828522456d --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_webappruntimesettings.go @@ -0,0 +1,35 @@ +package provider + +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 WebAppRuntimeSettings struct { + AppInsightsSettings *AppInsightsWebAppStackSettings `json:"appInsightsSettings,omitempty"` + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + GitHubActionSettings *GitHubActionWebAppStackSettings `json:"gitHubActionSettings,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + RemoteDebuggingSupported *bool `json:"remoteDebuggingSupported,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} + +func (o *WebAppRuntimeSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *WebAppRuntimeSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2023-12-01/provider/model_webappstack.go b/resource-manager/web/2023-12-01/provider/model_webappstack.go new file mode 100644 index 00000000000..6d111339d6d --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_webappstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppStack struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebAppStackProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_webappstackproperties.go b/resource-manager/web/2023-12-01/provider/model_webappstackproperties.go new file mode 100644 index 00000000000..a37e8588aae --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_webappstackproperties.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppStackProperties struct { + DisplayText *string `json:"displayText,omitempty"` + MajorVersions *[]WebAppMajorVersion `json:"majorVersions,omitempty"` + PreferredOs *StackPreferredOs `json:"preferredOs,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/provider/model_windowsjavacontainersettings.go b/resource-manager/web/2023-12-01/provider/model_windowsjavacontainersettings.go new file mode 100644 index 00000000000..0bba076cec7 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/model_windowsjavacontainersettings.go @@ -0,0 +1,33 @@ +package provider + +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 WindowsJavaContainerSettings struct { + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` +} + +func (o *WindowsJavaContainerSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *WindowsJavaContainerSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2023-12-01/provider/predicates.go b/resource-manager/web/2023-12-01/provider/predicates.go new file mode 100644 index 00000000000..152a0bd64bb --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/predicates.go @@ -0,0 +1,98 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStackResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ApplicationStackResourceOperationPredicate) Matches(input ApplicationStackResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type FunctionAppStackOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p FunctionAppStackOperationPredicate) Matches(input FunctionAppStack) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WebAppStackOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p WebAppStackOperationPredicate) Matches(input WebAppStack) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/provider/version.go b/resource-manager/web/2023-12-01/provider/version.go new file mode 100644 index 00000000000..29c0057d6c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/provider/version.go @@ -0,0 +1,12 @@ +package provider + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/provider/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/recommendations/README.md b/resource-manager/web/2023-12-01/recommendations/README.md new file mode 100644 index 00000000000..7d546593541 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/README.md @@ -0,0 +1,266 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/recommendations` Documentation + +The `recommendations` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/recommendations" +``` + + +### Client Initialization + +```go +client := recommendations.NewRecommendationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecommendationsClient.DisableAllForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.DisableAllForHostingEnvironment(ctx, id, recommendations.DefaultDisableAllForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableAllForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.DisableAllForWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForHostingEnvironment` + +```go +ctx := context.TODO() +id := recommendations.NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "recommendationValue") + +read, err := client.DisableRecommendationForHostingEnvironment(ctx, id, recommendations.DefaultDisableRecommendationForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForSite` + +```go +ctx := context.TODO() +id := recommendations.NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "recommendationValue") + +read, err := client.DisableRecommendationForSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForSubscription` + +```go +ctx := context.TODO() +id := recommendations.NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationValue") + +read, err := client.DisableRecommendationForSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.GetRuleDetailsByHostingEnvironment` + +```go +ctx := context.TODO() +id := recommendations.NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "recommendationValue") + +read, err := client.GetRuleDetailsByHostingEnvironment(ctx, id, recommendations.DefaultGetRuleDetailsByHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.GetRuleDetailsByWebApp` + +```go +ctx := context.TODO() +id := recommendations.NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "recommendationValue") + +read, err := client.GetRuleDetailsByWebApp(ctx, id, recommendations.DefaultGetRuleDetailsByWebAppOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, recommendations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, recommendations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListHistoryForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListHistoryForHostingEnvironment(ctx, id, recommendations.DefaultListHistoryForHostingEnvironmentOperationOptions())` can be used to do batched pagination +items, err := client.ListHistoryForHostingEnvironmentComplete(ctx, id, recommendations.DefaultListHistoryForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListHistoryForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListHistoryForWebApp(ctx, id, recommendations.DefaultListHistoryForWebAppOperationOptions())` can be used to do batched pagination +items, err := client.ListHistoryForWebAppComplete(ctx, id, recommendations.DefaultListHistoryForWebAppOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListRecommendedRulesForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +// alternatively `client.ListRecommendedRulesForHostingEnvironment(ctx, id, recommendations.DefaultListRecommendedRulesForHostingEnvironmentOperationOptions())` can be used to do batched pagination +items, err := client.ListRecommendedRulesForHostingEnvironmentComplete(ctx, id, recommendations.DefaultListRecommendedRulesForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListRecommendedRulesForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListRecommendedRulesForWebApp(ctx, id, recommendations.DefaultListRecommendedRulesForWebAppOperationOptions())` can be used to do batched pagination +items, err := client.ListRecommendedRulesForWebAppComplete(ctx, id, recommendations.DefaultListRecommendedRulesForWebAppOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFilters` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ResetAllFilters(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFiltersForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue") + +read, err := client.ResetAllFiltersForHostingEnvironment(ctx, id, recommendations.DefaultResetAllFiltersForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFiltersForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ResetAllFiltersForWebApp(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/web/2023-12-01/recommendations/client.go b/resource-manager/web/2023-12-01/recommendations/client.go new file mode 100644 index 00000000000..c0ae3be9b1d --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/client.go @@ -0,0 +1,26 @@ +package recommendations + +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 RecommendationsClient struct { + Client *resourcemanager.Client +} + +func NewRecommendationsClientWithBaseURI(sdkApi sdkEnv.Api) (*RecommendationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "recommendations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecommendationsClient: %+v", err) + } + + return &RecommendationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/recommendations/constants.go b/resource-manager/web/2023-12-01/recommendations/constants.go new file mode 100644 index 00000000000..207c2a4c8a5 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/constants.go @@ -0,0 +1,151 @@ +package recommendations + +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 Channels string + +const ( + ChannelsAll Channels = "All" + ChannelsApi Channels = "Api" + ChannelsEmail Channels = "Email" + ChannelsNotification Channels = "Notification" + ChannelsWebhook Channels = "Webhook" +) + +func PossibleValuesForChannels() []string { + return []string{ + string(ChannelsAll), + string(ChannelsApi), + string(ChannelsEmail), + string(ChannelsNotification), + string(ChannelsWebhook), + } +} + +func (s *Channels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChannels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChannels(input string) (*Channels, error) { + vals := map[string]Channels{ + "all": ChannelsAll, + "api": ChannelsApi, + "email": ChannelsEmail, + "notification": ChannelsNotification, + "webhook": ChannelsWebhook, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Channels(input) + return &out, nil +} + +type NotificationLevel string + +const ( + NotificationLevelCritical NotificationLevel = "Critical" + NotificationLevelInformation NotificationLevel = "Information" + NotificationLevelNonUrgentSuggestion NotificationLevel = "NonUrgentSuggestion" + NotificationLevelWarning NotificationLevel = "Warning" +) + +func PossibleValuesForNotificationLevel() []string { + return []string{ + string(NotificationLevelCritical), + string(NotificationLevelInformation), + string(NotificationLevelNonUrgentSuggestion), + string(NotificationLevelWarning), + } +} + +func (s *NotificationLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNotificationLevel(input string) (*NotificationLevel, error) { + vals := map[string]NotificationLevel{ + "critical": NotificationLevelCritical, + "information": NotificationLevelInformation, + "nonurgentsuggestion": NotificationLevelNonUrgentSuggestion, + "warning": NotificationLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NotificationLevel(input) + return &out, nil +} + +type ResourceScopeType string + +const ( + ResourceScopeTypeServerFarm ResourceScopeType = "ServerFarm" + ResourceScopeTypeSubscription ResourceScopeType = "Subscription" + ResourceScopeTypeWebSite ResourceScopeType = "WebSite" +) + +func PossibleValuesForResourceScopeType() []string { + return []string{ + string(ResourceScopeTypeServerFarm), + string(ResourceScopeTypeSubscription), + string(ResourceScopeTypeWebSite), + } +} + +func (s *ResourceScopeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceScopeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceScopeType(input string) (*ResourceScopeType, error) { + vals := map[string]ResourceScopeType{ + "serverfarm": ResourceScopeTypeServerFarm, + "subscription": ResourceScopeTypeSubscription, + "website": ResourceScopeTypeWebSite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceScopeType(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation.go b/resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation.go new file mode 100644 index 00000000000..67ff49432d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentRecommendationId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentRecommendationId{} + +// HostingEnvironmentRecommendationId is a struct representing the Resource ID for a Hosting Environment Recommendation +type HostingEnvironmentRecommendationId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + RecommendationName string +} + +// NewHostingEnvironmentRecommendationID returns a new HostingEnvironmentRecommendationId struct +func NewHostingEnvironmentRecommendationID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, recommendationName string) HostingEnvironmentRecommendationId { + return HostingEnvironmentRecommendationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + RecommendationName: recommendationName, + } +} + +// ParseHostingEnvironmentRecommendationID parses 'input' into a HostingEnvironmentRecommendationId +func ParseHostingEnvironmentRecommendationID(input string) (*HostingEnvironmentRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentRecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentRecommendationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentRecommendationIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentRecommendationId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentRecommendationIDInsensitively(input string) (*HostingEnvironmentRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentRecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentRecommendationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentRecommendationId) 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.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateHostingEnvironmentRecommendationID checks that 'input' can be parsed as a Hosting Environment Recommendation ID +func ValidateHostingEnvironmentRecommendationID(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 := ParseHostingEnvironmentRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentValue"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationValue"), + } +} + +// String returns a human-readable description of this Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Hosting Environment Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation_test.go b/resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation_test.go new file mode 100644 index 00000000000..d479a2bdfac --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/id_hostingenvironmentrecommendation_test.go @@ -0,0 +1,327 @@ +package recommendations + +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 = &HostingEnvironmentRecommendationId{} + +func TestNewHostingEnvironmentRecommendationID(t *testing.T) { + id := NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "recommendationValue") + + 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.HostingEnvironmentName != "hostingEnvironmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentValue") + } + + if id.RecommendationName != "recommendationValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationValue") + } +} + +func TestFormatHostingEnvironmentRecommendationID(t *testing.T) { + actual := NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentValue", "recommendationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/recommendations/recommendationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/recommendations/recommendationValue", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + RecommendationName: "recommendationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/recommendations/recommendationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentRecommendationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseHostingEnvironmentRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/recommendations/recommendationValue", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentValue", + RecommendationName: "recommendationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentValue/recommendations/recommendationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNvAlUe", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTvAlUe", + RecommendationName: "rEcOmMeNdAtIoNvAlUe", + }, + }, + { + // 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.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTvAlUe/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentRecommendationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForHostingEnvironmentRecommendationId(t *testing.T) { + segments := HostingEnvironmentRecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentRecommendationId 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/web/2023-12-01/recommendations/id_recommendation.go b/resource-manager/web/2023-12-01/recommendations/id_recommendation.go new file mode 100644 index 00000000000..a1f8446174f --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/id_recommendation.go @@ -0,0 +1,121 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecommendationId{}) +} + +var _ resourceids.ResourceId = &RecommendationId{} + +// RecommendationId is a struct representing the Resource ID for a Recommendation +type RecommendationId struct { + SubscriptionId string + RecommendationName string +} + +// NewRecommendationID returns a new RecommendationId struct +func NewRecommendationID(subscriptionId string, recommendationName string) RecommendationId { + return RecommendationId{ + SubscriptionId: subscriptionId, + RecommendationName: recommendationName, + } +} + +// ParseRecommendationID parses 'input' into a RecommendationId +func ParseRecommendationID(input string) (*RecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecommendationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecommendationIDInsensitively parses 'input' case-insensitively into a RecommendationId +// note: this method should only be used for API response data and not user input +func ParseRecommendationIDInsensitively(input string) (*RecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecommendationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecommendationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateRecommendationID checks that 'input' can be parsed as a Recommendation ID +func ValidateRecommendationID(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 := ParseRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recommendation ID +func (id RecommendationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recommendation ID +func (id RecommendationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationValue"), + } +} + +// String returns a human-readable description of this Recommendation ID +func (id RecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/recommendations/id_recommendation_test.go b/resource-manager/web/2023-12-01/recommendations/id_recommendation_test.go new file mode 100644 index 00000000000..f96e372635c --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/id_recommendation_test.go @@ -0,0 +1,237 @@ +package recommendations + +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 = &RecommendationId{} + +func TestNewRecommendationID(t *testing.T) { + id := NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationValue") + + 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.RecommendationName != "recommendationValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationValue") + } +} + +func TestFormatRecommendationID(t *testing.T) { + actual := NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationValue", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "recommendationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecommendationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationValue", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "recommendationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNvAlUe", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "rEcOmMeNdAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecommendationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForRecommendationId(t *testing.T) { + segments := RecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecommendationId 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/web/2023-12-01/recommendations/id_siterecommendation.go b/resource-manager/web/2023-12-01/recommendations/id_siterecommendation.go new file mode 100644 index 00000000000..cada8a9b36f --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/id_siterecommendation.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteRecommendationId{}) +} + +var _ resourceids.ResourceId = &SiteRecommendationId{} + +// SiteRecommendationId is a struct representing the Resource ID for a Site Recommendation +type SiteRecommendationId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + RecommendationName string +} + +// NewSiteRecommendationID returns a new SiteRecommendationId struct +func NewSiteRecommendationID(subscriptionId string, resourceGroupName string, siteName string, recommendationName string) SiteRecommendationId { + return SiteRecommendationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + RecommendationName: recommendationName, + } +} + +// ParseSiteRecommendationID parses 'input' into a SiteRecommendationId +func ParseSiteRecommendationID(input string) (*SiteRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteRecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteRecommendationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteRecommendationIDInsensitively parses 'input' case-insensitively into a SiteRecommendationId +// note: this method should only be used for API response data and not user input +func ParseSiteRecommendationIDInsensitively(input string) (*SiteRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteRecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteRecommendationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteRecommendationId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateSiteRecommendationID checks that 'input' can be parsed as a Site Recommendation ID +func ValidateSiteRecommendationID(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 := ParseSiteRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Recommendation ID +func (id SiteRecommendationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Recommendation ID +func (id SiteRecommendationId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationValue"), + } +} + +// String returns a human-readable description of this Site Recommendation ID +func (id SiteRecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Site Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/recommendations/id_siterecommendation_test.go b/resource-manager/web/2023-12-01/recommendations/id_siterecommendation_test.go new file mode 100644 index 00000000000..c1b51c38c96 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/id_siterecommendation_test.go @@ -0,0 +1,327 @@ +package recommendations + +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 = &SiteRecommendationId{} + +func TestNewSiteRecommendationID(t *testing.T) { + id := NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "recommendationValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.RecommendationName != "recommendationValue" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationValue") + } +} + +func TestFormatSiteRecommendationID(t *testing.T) { + actual := NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "recommendationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/recommendations/recommendationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/recommendations/recommendationValue", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + RecommendationName: "recommendationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/recommendations/recommendationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteRecommendationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseSiteRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteRecommendationId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/recommendations/recommendationValue", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + RecommendationName: "recommendationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/recommendations/recommendationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNvAlUe", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + RecommendationName: "rEcOmMeNdAtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteRecommendationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForSiteRecommendationId(t *testing.T) { + segments := SiteRecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteRecommendationId 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/web/2023-12-01/recommendations/method_disableallforhostingenvironment.go b/resource-manager/web/2023-12-01/recommendations/method_disableallforhostingenvironment.go new file mode 100644 index 00000000000..3cf4d8a174d --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_disableallforhostingenvironment.go @@ -0,0 +1,76 @@ +package recommendations + +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 DisableAllForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableAllForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableAllForHostingEnvironmentOperationOptions() DisableAllForHostingEnvironmentOperationOptions { + return DisableAllForHostingEnvironmentOperationOptions{} +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableAllForHostingEnvironment ... +func (c RecommendationsClient) DisableAllForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options DisableAllForHostingEnvironmentOperationOptions) (result DisableAllForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/disable", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_disableallforwebapp.go b/resource-manager/web/2023-12-01/recommendations/method_disableallforwebapp.go new file mode 100644 index 00000000000..ce325151614 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_disableallforwebapp.go @@ -0,0 +1,48 @@ +package recommendations + +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 DisableAllForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableAllForWebApp ... +func (c RecommendationsClient) DisableAllForWebApp(ctx context.Context, id commonids.AppServiceId) (result DisableAllForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforhostingenvironment.go b/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforhostingenvironment.go new file mode 100644 index 00000000000..9a2c85fe009 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforhostingenvironment.go @@ -0,0 +1,75 @@ +package recommendations + +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 DisableRecommendationForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableRecommendationForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableRecommendationForHostingEnvironmentOperationOptions() DisableRecommendationForHostingEnvironmentOperationOptions { + return DisableRecommendationForHostingEnvironmentOperationOptions{} +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableRecommendationForHostingEnvironment ... +func (c RecommendationsClient) DisableRecommendationForHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options DisableRecommendationForHostingEnvironmentOperationOptions) (result DisableRecommendationForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsite.go b/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsite.go new file mode 100644 index 00000000000..da51644b3c1 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsite.go @@ -0,0 +1,47 @@ +package recommendations + +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 DisableRecommendationForSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSite ... +func (c RecommendationsClient) DisableRecommendationForSite(ctx context.Context, id SiteRecommendationId) (result DisableRecommendationForSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsubscription.go b/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsubscription.go new file mode 100644 index 00000000000..a3f4f94f085 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_disablerecommendationforsubscription.go @@ -0,0 +1,47 @@ +package recommendations + +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 DisableRecommendationForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSubscription ... +func (c RecommendationsClient) DisableRecommendationForSubscription(ctx context.Context, id RecommendationId) (result DisableRecommendationForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_getruledetailsbyhostingenvironment.go b/resource-manager/web/2023-12-01/recommendations/method_getruledetailsbyhostingenvironment.go new file mode 100644 index 00000000000..524b4ba744d --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_getruledetailsbyhostingenvironment.go @@ -0,0 +1,87 @@ +package recommendations + +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 GetRuleDetailsByHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByHostingEnvironmentOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByHostingEnvironmentOperationOptions() GetRuleDetailsByHostingEnvironmentOperationOptions { + return GetRuleDetailsByHostingEnvironmentOperationOptions{} +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByHostingEnvironment ... +func (c RecommendationsClient) GetRuleDetailsByHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options GetRuleDetailsByHostingEnvironmentOperationOptions) (result GetRuleDetailsByHostingEnvironmentOperationResponse, 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 + } + + var model RecommendationRule + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_getruledetailsbywebapp.go b/resource-manager/web/2023-12-01/recommendations/method_getruledetailsbywebapp.go new file mode 100644 index 00000000000..aca06f267dd --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_getruledetailsbywebapp.go @@ -0,0 +1,87 @@ +package recommendations + +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 GetRuleDetailsByWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByWebAppOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByWebAppOperationOptions() GetRuleDetailsByWebAppOperationOptions { + return GetRuleDetailsByWebAppOperationOptions{} +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByWebApp ... +func (c RecommendationsClient) GetRuleDetailsByWebApp(ctx context.Context, id SiteRecommendationId, options GetRuleDetailsByWebAppOperationOptions) (result GetRuleDetailsByWebAppOperationResponse, 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 + } + + var model RecommendationRule + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_list.go b/resource-manager/web/2023-12-01/recommendations/method_list.go new file mode 100644 index 00000000000..14557066e8e --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_list.go @@ -0,0 +1,124 @@ +package recommendations + +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 *[]Recommendation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListOperationOptions struct { + Featured *bool + 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.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// List ... +func (c RecommendationsClient) List(ctx context.Context, id commonids.SubscriptionId, 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/providers/Microsoft.Web/recommendations", 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 *[]Recommendation `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 RecommendationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate RecommendationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Recommendation, 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/web/2023-12-01/recommendations/method_listhistoryforhostingenvironment.go b/resource-manager/web/2023-12-01/recommendations/method_listhistoryforhostingenvironment.go new file mode 100644 index 00000000000..7075310179c --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_listhistoryforhostingenvironment.go @@ -0,0 +1,124 @@ +package recommendations + +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 ListHistoryForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForHostingEnvironmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListHistoryForHostingEnvironmentOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForHostingEnvironmentOperationOptions() ListHistoryForHostingEnvironmentOperationOptions { + return ListHistoryForHostingEnvironmentOperationOptions{} +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListHistoryForHostingEnvironment ... +func (c RecommendationsClient) ListHistoryForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (result ListHistoryForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendationHistory", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForHostingEnvironmentComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (ListHistoryForHostingEnvironmentCompleteResult, error) { + return c.ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForHostingEnvironment(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 = ListHistoryForHostingEnvironmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_listhistoryforwebapp.go b/resource-manager/web/2023-12-01/recommendations/method_listhistoryforwebapp.go new file mode 100644 index 00000000000..71e585ccb64 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_listhistoryforwebapp.go @@ -0,0 +1,124 @@ +package recommendations + +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 ListHistoryForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForWebAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListHistoryForWebAppOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForWebAppOperationOptions() ListHistoryForWebAppOperationOptions { + return ListHistoryForWebAppOperationOptions{} +} + +func (o ListHistoryForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListHistoryForWebApp ... +func (c RecommendationsClient) ListHistoryForWebApp(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions) (result ListHistoryForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendationHistory", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForWebAppComplete(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions) (ListHistoryForWebAppCompleteResult, error) { + return c.ListHistoryForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForWebAppCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForWebApp(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 = ListHistoryForWebAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforhostingenvironment.go b/resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforhostingenvironment.go new file mode 100644 index 00000000000..4fc2331c132 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforhostingenvironment.go @@ -0,0 +1,124 @@ +package recommendations + +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 ListRecommendedRulesForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForHostingEnvironmentOperationOptions() ListRecommendedRulesForHostingEnvironmentOperationOptions { + return ListRecommendedRulesForHostingEnvironmentOperationOptions{} +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListRecommendedRulesForHostingEnvironment ... +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (result ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendations", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (ListRecommendedRulesForHostingEnvironmentCompleteResult, error) { + return c.ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForHostingEnvironment(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 = ListRecommendedRulesForHostingEnvironmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforwebapp.go b/resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforwebapp.go new file mode 100644 index 00000000000..f4efa019a0e --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_listrecommendedrulesforwebapp.go @@ -0,0 +1,124 @@ +package recommendations + +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 ListRecommendedRulesForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForWebAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListRecommendedRulesForWebAppOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForWebAppOperationOptions() ListRecommendedRulesForWebAppOperationOptions { + return ListRecommendedRulesForWebAppOperationOptions{} +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListRecommendedRulesForWebApp ... +func (c RecommendationsClient) ListRecommendedRulesForWebApp(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions) (result ListRecommendedRulesForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/recommendations", 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 *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForWebAppComplete(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions) (ListRecommendedRulesForWebAppCompleteResult, error) { + return c.ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForWebApp(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 = ListRecommendedRulesForWebAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_resetallfilters.go b/resource-manager/web/2023-12-01/recommendations/method_resetallfilters.go new file mode 100644 index 00000000000..9ca523a21a2 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_resetallfilters.go @@ -0,0 +1,48 @@ +package recommendations + +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 ResetAllFiltersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFilters ... +func (c RecommendationsClient) ResetAllFilters(ctx context.Context, id commonids.SubscriptionId) (result ResetAllFiltersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/recommendations/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforhostingenvironment.go b/resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforhostingenvironment.go new file mode 100644 index 00000000000..37b4b2703d0 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforhostingenvironment.go @@ -0,0 +1,76 @@ +package recommendations + +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 ResetAllFiltersForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ResetAllFiltersForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultResetAllFiltersForHostingEnvironmentOperationOptions() ResetAllFiltersForHostingEnvironmentOperationOptions { + return ResetAllFiltersForHostingEnvironmentOperationOptions{} +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// ResetAllFiltersForHostingEnvironment ... +func (c RecommendationsClient) ResetAllFiltersForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ResetAllFiltersForHostingEnvironmentOperationOptions) (result ResetAllFiltersForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/reset", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforwebapp.go b/resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforwebapp.go new file mode 100644 index 00000000000..79dcbd7603a --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/method_resetallfiltersforwebapp.go @@ -0,0 +1,48 @@ +package recommendations + +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 ResetAllFiltersForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFiltersForWebApp ... +func (c RecommendationsClient) ResetAllFiltersForWebApp(ctx context.Context, id commonids.AppServiceId) (result ResetAllFiltersForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/recommendations/model_recommendation.go b/resource-manager/web/2023-12-01/recommendations/model_recommendation.go new file mode 100644 index 00000000000..341907a80ad --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/model_recommendation.go @@ -0,0 +1,12 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Recommendation struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecommendationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/recommendations/model_recommendationproperties.go b/resource-manager/web/2023-12-01/recommendations/model_recommendationproperties.go new file mode 100644 index 00000000000..af604189bbf --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/model_recommendationproperties.go @@ -0,0 +1,108 @@ +package recommendations + +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 RecommendationProperties struct { + ActionName *string `json:"actionName,omitempty"` + BladeName *string `json:"bladeName,omitempty"` + CategoryTags *[]string `json:"categoryTags,omitempty"` + Channels *Channels `json:"channels,omitempty"` + CreationTime *string `json:"creationTime,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Enabled *int64 `json:"enabled,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + ForwardLink *string `json:"forwardLink,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Level *NotificationLevel `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + NextNotificationTime *string `json:"nextNotificationTime,omitempty"` + NotificationExpirationTime *string `json:"notificationExpirationTime,omitempty"` + NotifiedTime *string `json:"notifiedTime,omitempty"` + RecommendationId *string `json:"recommendationId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceScope *ResourceScopeType `json:"resourceScope,omitempty"` + RuleName *string `json:"ruleName,omitempty"` + Score *float64 `json:"score,omitempty"` + StartTime *string `json:"startTime,omitempty"` + States *[]string `json:"states,omitempty"` +} + +func (o *RecommendationProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RecommendationProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RecommendationProperties) GetNextNotificationTimeAsTime() (*time.Time, error) { + if o.NextNotificationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextNotificationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNextNotificationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextNotificationTime = &formatted +} + +func (o *RecommendationProperties) GetNotificationExpirationTimeAsTime() (*time.Time, error) { + if o.NotificationExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotificationExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNotificationExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotificationExpirationTime = &formatted +} + +func (o *RecommendationProperties) GetNotifiedTimeAsTime() (*time.Time, error) { + if o.NotifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNotifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotifiedTime = &formatted +} + +func (o *RecommendationProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/recommendations/model_recommendationrule.go b/resource-manager/web/2023-12-01/recommendations/model_recommendationrule.go new file mode 100644 index 00000000000..48fdfd600fd --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/model_recommendationrule.go @@ -0,0 +1,12 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationRule struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecommendationRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/recommendations/model_recommendationruleproperties.go b/resource-manager/web/2023-12-01/recommendations/model_recommendationruleproperties.go new file mode 100644 index 00000000000..0352c174d79 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/model_recommendationruleproperties.go @@ -0,0 +1,20 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationRuleProperties struct { + ActionName *string `json:"actionName,omitempty"` + BladeName *string `json:"bladeName,omitempty"` + CategoryTags *[]string `json:"categoryTags,omitempty"` + Channels *Channels `json:"channels,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + ForwardLink *string `json:"forwardLink,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Level *NotificationLevel `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + RecommendationId *string `json:"recommendationId,omitempty"` + RecommendationName *string `json:"recommendationName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/recommendations/predicates.go b/resource-manager/web/2023-12-01/recommendations/predicates.go new file mode 100644 index 00000000000..bb0901fe9f3 --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/predicates.go @@ -0,0 +1,32 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RecommendationOperationPredicate) Matches(input Recommendation) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/recommendations/version.go b/resource-manager/web/2023-12-01/recommendations/version.go new file mode 100644 index 00000000000..b2d9624690a --- /dev/null +++ b/resource-manager/web/2023-12-01/recommendations/version.go @@ -0,0 +1,12 @@ +package recommendations + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/recommendations/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/README.md b/resource-manager/web/2023-12-01/resourcehealthmetadata/README.md new file mode 100644 index 00000000000..84b4dc5d8c9 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/resourcehealthmetadata` Documentation + +The `resourcehealthmetadata` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/resourcehealthmetadata" +``` + + +### Client Initialization + +```go +client := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceHealthMetadataClient.GetBySite` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetBySite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.GetBySiteSlot` + +```go +ctx := context.TODO() +id := resourcehealthmetadata.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetBySiteSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `ResourceHealthMetadataClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.ListBySite` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListBySite(ctx, id)` can be used to do batched pagination +items, err := client.ListBySiteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.ListBySiteSlot` + +```go +ctx := context.TODO() +id := resourcehealthmetadata.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListBySiteSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBySiteSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/client.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/client.go new file mode 100644 index 00000000000..a0e8b63b709 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/client.go @@ -0,0 +1,26 @@ +package resourcehealthmetadata + +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 ResourceHealthMetadataClient struct { + Client *resourcemanager.Client +} + +func NewResourceHealthMetadataClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceHealthMetadataClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "resourcehealthmetadata", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceHealthMetadataClient: %+v", err) + } + + return &ResourceHealthMetadataClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot.go new file mode 100644 index 00000000000..0bfa176043e --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot.go @@ -0,0 +1,139 @@ +package resourcehealthmetadata + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(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 := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot_test.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot_test.go new file mode 100644 index 00000000000..1f185ed3662 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/id_slot_test.go @@ -0,0 +1,327 @@ +package resourcehealthmetadata + +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 = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId 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/web/2023-12-01/resourcehealthmetadata/method_getbysite.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_getbysite.go new file mode 100644 index 00000000000..58587d1e4b3 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_getbysite.go @@ -0,0 +1,56 @@ +package resourcehealthmetadata + +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 GetBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySite ... +func (c ResourceHealthMetadataClient) GetBySite(ctx context.Context, id commonids.AppServiceId) (result GetBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/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 + } + + var model ResourceHealthMetadata + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/method_getbysiteslot.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_getbysiteslot.go new file mode 100644 index 00000000000..23f5d6260a5 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_getbysiteslot.go @@ -0,0 +1,55 @@ +package resourcehealthmetadata + +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 GetBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySiteSlot ... +func (c ResourceHealthMetadataClient) GetBySiteSlot(ctx context.Context, id SlotId) (result GetBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/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 + } + + var model ResourceHealthMetadata + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/method_list.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_list.go new file mode 100644 index 00000000000..3810b0516d3 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_list.go @@ -0,0 +1,92 @@ +package resourcehealthmetadata + +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 *[]ResourceHealthMetadata +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +// List ... +func (c ResourceHealthMetadataClient) List(ctx context.Context, id commonids.SubscriptionId) (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.Web/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `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 ResourceHealthMetadataClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ResourceHealthMetadataOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 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/web/2023-12-01/resourcehealthmetadata/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbyresourcegroup.go new file mode 100644 index 00000000000..ead161313e4 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +// ListByResourceGroup ... +func (c ResourceHealthMetadataClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ResourceHealthMetadataOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysite.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysite.go new file mode 100644 index 00000000000..5a6d21ddd3c --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysite.go @@ -0,0 +1,92 @@ +package resourcehealthmetadata + +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 ListBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +// ListBySite ... +func (c ResourceHealthMetadataClient) ListBySite(ctx context.Context, id commonids.AppServiceId) (result ListBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteComplete(ctx context.Context, id commonids.AppServiceId) (ListBySiteCompleteResult, error) { + return c.ListBySiteCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySite(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 = ListBySiteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysiteslot.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysiteslot.go new file mode 100644 index 00000000000..37b149279de --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/method_listbysiteslot.go @@ -0,0 +1,91 @@ +package resourcehealthmetadata + +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 ListBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +// ListBySiteSlot ... +func (c ResourceHealthMetadataClient) ListBySiteSlot(ctx context.Context, id SlotId) (result ListBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata", 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 *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteSlotComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteSlotComplete(ctx context.Context, id SlotId) (ListBySiteSlotCompleteResult, error) { + return c.ListBySiteSlotCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteSlotCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySiteSlot(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 = ListBySiteSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadata.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadata.go new file mode 100644 index 00000000000..14d0fa99d6c --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadata.go @@ -0,0 +1,12 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadata struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceHealthMetadataProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go new file mode 100644 index 00000000000..a59e92db1ed --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go @@ -0,0 +1,9 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadataProperties struct { + Category *string `json:"category,omitempty"` + SignalAvailability *bool `json:"signalAvailability,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourcehealthmetadata/predicates.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/predicates.go new file mode 100644 index 00000000000..5682d0611c2 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/predicates.go @@ -0,0 +1,32 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadataOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ResourceHealthMetadataOperationPredicate) Matches(input ResourceHealthMetadata) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/resourcehealthmetadata/version.go b/resource-manager/web/2023-12-01/resourcehealthmetadata/version.go new file mode 100644 index 00000000000..c0cfbb51471 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourcehealthmetadata/version.go @@ -0,0 +1,12 @@ +package resourcehealthmetadata + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourcehealthmetadata/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/README.md b/resource-manager/web/2023-12-01/resourceproviders/README.md new file mode 100644 index 00000000000..bca35b126d4 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/README.md @@ -0,0 +1,372 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/resourceproviders` Documentation + +The `resourceproviders` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/resourceproviders" +``` + + +### Client Initialization + +```go +client := resourceproviders.NewResourceProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceProvidersClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.ResourceNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetPublishingUser` + +```go +ctx := context.TODO() + + +read, err := client.GetPublishingUser(ctx) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetSourceControl` + +```go +ctx := context.TODO() +id := resourceproviders.NewSourceControlID("sourceControlValue") + +read, err := client.GetSourceControl(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetSubscriptionDeploymentLocations` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.GetSubscriptionDeploymentLocations(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetUsagesInLocationlist` + +```go +ctx := context.TODO() +id := resourceproviders.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.GetUsagesInLocationlist(ctx, id)` can be used to do batched pagination +items, err := client.GetUsagesInLocationlistComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListAseRegions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAseRegions(ctx, id)` can be used to do batched pagination +items, err := client.ListAseRegionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListBillingMeters` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBillingMeters(ctx, id, resourceproviders.DefaultListBillingMetersOperationOptions())` can be used to do batched pagination +items, err := client.ListBillingMetersComplete(ctx, id, resourceproviders.DefaultListBillingMetersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListCustomHostNameSites` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListCustomHostNameSites(ctx, id, resourceproviders.DefaultListCustomHostNameSitesOperationOptions())` can be used to do batched pagination +items, err := client.ListCustomHostNameSitesComplete(ctx, id, resourceproviders.DefaultListCustomHostNameSitesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListGeoRegions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListGeoRegions(ctx, id, resourceproviders.DefaultListGeoRegionsOperationOptions())` can be used to do batched pagination +items, err := client.ListGeoRegionsComplete(ctx, id, resourceproviders.DefaultListGeoRegionsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListPremierAddOnOffers` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListPremierAddOnOffers(ctx, id)` can be used to do batched pagination +items, err := client.ListPremierAddOnOffersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSiteIdentifiersAssignedToHostName` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.NameIdentifier{ + // ... +} + + +// alternatively `client.ListSiteIdentifiersAssignedToHostName(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSiteIdentifiersAssignedToHostNameComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSkus` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListSkus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSourceControls` + +```go +ctx := context.TODO() + + +// alternatively `client.ListSourceControls(ctx)` can be used to do batched pagination +items, err := client.ListSourceControlsComplete(ctx) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.Move` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.CsmMoveResourceEnvelope{ + // ... +} + + +read, err := client.Move(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.UpdatePublishingUser` + +```go +ctx := context.TODO() + +payload := resourceproviders.User{ + // ... +} + + +read, err := client.UpdatePublishingUser(ctx, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.UpdateSourceControl` + +```go +ctx := context.TODO() +id := resourceproviders.NewSourceControlID("sourceControlValue") + +payload := resourceproviders.SourceControl{ + // ... +} + + +read, err := client.UpdateSourceControl(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.Validate` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.ValidateRequest{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.ValidateMove` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.CsmMoveResourceEnvelope{ + // ... +} + + +read, err := client.ValidateMove(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.VerifyHostingEnvironmentVnet` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.VnetParameters{ + // ... +} + + +read, err := client.VerifyHostingEnvironmentVnet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2023-12-01/resourceproviders/client.go b/resource-manager/web/2023-12-01/resourceproviders/client.go new file mode 100644 index 00000000000..0f91da37d8c --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/client.go @@ -0,0 +1,26 @@ +package resourceproviders + +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 ResourceProvidersClient struct { + Client *resourcemanager.Client +} + +func NewResourceProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceProvidersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "resourceproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceProvidersClient: %+v", err) + } + + return &ResourceProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/constants.go b/resource-manager/web/2023-12-01/resourceproviders/constants.go new file mode 100644 index 00000000000..3f211102eb2 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/constants.go @@ -0,0 +1,563 @@ +package resourceproviders + +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 AppServicePlanRestrictions string + +const ( + AppServicePlanRestrictionsBasic AppServicePlanRestrictions = "Basic" + AppServicePlanRestrictionsFree AppServicePlanRestrictions = "Free" + AppServicePlanRestrictionsNone AppServicePlanRestrictions = "None" + AppServicePlanRestrictionsPremium AppServicePlanRestrictions = "Premium" + AppServicePlanRestrictionsShared AppServicePlanRestrictions = "Shared" + AppServicePlanRestrictionsStandard AppServicePlanRestrictions = "Standard" +) + +func PossibleValuesForAppServicePlanRestrictions() []string { + return []string{ + string(AppServicePlanRestrictionsBasic), + string(AppServicePlanRestrictionsFree), + string(AppServicePlanRestrictionsNone), + string(AppServicePlanRestrictionsPremium), + string(AppServicePlanRestrictionsShared), + string(AppServicePlanRestrictionsStandard), + } +} + +func (s *AppServicePlanRestrictions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppServicePlanRestrictions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAppServicePlanRestrictions(input string) (*AppServicePlanRestrictions, error) { + vals := map[string]AppServicePlanRestrictions{ + "basic": AppServicePlanRestrictionsBasic, + "free": AppServicePlanRestrictionsFree, + "none": AppServicePlanRestrictionsNone, + "premium": AppServicePlanRestrictionsPremium, + "shared": AppServicePlanRestrictionsShared, + "standard": AppServicePlanRestrictionsStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AppServicePlanRestrictions(input) + return &out, nil +} + +type CheckNameResourceTypes string + +const ( + CheckNameResourceTypesHostingEnvironment CheckNameResourceTypes = "HostingEnvironment" + CheckNameResourceTypesMicrosoftPointWebHostingEnvironments CheckNameResourceTypes = "Microsoft.Web/hostingEnvironments" + CheckNameResourceTypesMicrosoftPointWebPublishingUsers CheckNameResourceTypes = "Microsoft.Web/publishingUsers" + CheckNameResourceTypesMicrosoftPointWebSites CheckNameResourceTypes = "Microsoft.Web/sites" + CheckNameResourceTypesMicrosoftPointWebSitesSlots CheckNameResourceTypes = "Microsoft.Web/sites/slots" + CheckNameResourceTypesPublishingUser CheckNameResourceTypes = "PublishingUser" + CheckNameResourceTypesSite CheckNameResourceTypes = "Site" + CheckNameResourceTypesSlot CheckNameResourceTypes = "Slot" +) + +func PossibleValuesForCheckNameResourceTypes() []string { + return []string{ + string(CheckNameResourceTypesHostingEnvironment), + string(CheckNameResourceTypesMicrosoftPointWebHostingEnvironments), + string(CheckNameResourceTypesMicrosoftPointWebPublishingUsers), + string(CheckNameResourceTypesMicrosoftPointWebSites), + string(CheckNameResourceTypesMicrosoftPointWebSitesSlots), + string(CheckNameResourceTypesPublishingUser), + string(CheckNameResourceTypesSite), + string(CheckNameResourceTypesSlot), + } +} + +func (s *CheckNameResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameResourceTypes(input string) (*CheckNameResourceTypes, error) { + vals := map[string]CheckNameResourceTypes{ + "hostingenvironment": CheckNameResourceTypesHostingEnvironment, + "microsoft.web/hostingenvironments": CheckNameResourceTypesMicrosoftPointWebHostingEnvironments, + "microsoft.web/publishingusers": CheckNameResourceTypesMicrosoftPointWebPublishingUsers, + "microsoft.web/sites": CheckNameResourceTypesMicrosoftPointWebSites, + "microsoft.web/sites/slots": CheckNameResourceTypesMicrosoftPointWebSitesSlots, + "publishinguser": CheckNameResourceTypesPublishingUser, + "site": CheckNameResourceTypesSite, + "slot": CheckNameResourceTypesSlot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameResourceTypes(input) + return &out, nil +} + +type CustomDnsSuffixProvisioningState string + +const ( + CustomDnsSuffixProvisioningStateDegraded CustomDnsSuffixProvisioningState = "Degraded" + CustomDnsSuffixProvisioningStateFailed CustomDnsSuffixProvisioningState = "Failed" + CustomDnsSuffixProvisioningStateInProgress CustomDnsSuffixProvisioningState = "InProgress" + CustomDnsSuffixProvisioningStateSucceeded CustomDnsSuffixProvisioningState = "Succeeded" +) + +func PossibleValuesForCustomDnsSuffixProvisioningState() []string { + return []string{ + string(CustomDnsSuffixProvisioningStateDegraded), + string(CustomDnsSuffixProvisioningStateFailed), + string(CustomDnsSuffixProvisioningStateInProgress), + string(CustomDnsSuffixProvisioningStateSucceeded), + } +} + +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { + vals := map[string]CustomDnsSuffixProvisioningState{ + "degraded": CustomDnsSuffixProvisioningStateDegraded, + "failed": CustomDnsSuffixProvisioningStateFailed, + "inprogress": CustomDnsSuffixProvisioningStateInProgress, + "succeeded": CustomDnsSuffixProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDnsSuffixProvisioningState(input) + return &out, nil +} + +type HostingEnvironmentStatus string + +const ( + HostingEnvironmentStatusDeleting HostingEnvironmentStatus = "Deleting" + HostingEnvironmentStatusPreparing HostingEnvironmentStatus = "Preparing" + HostingEnvironmentStatusReady HostingEnvironmentStatus = "Ready" + HostingEnvironmentStatusScaling HostingEnvironmentStatus = "Scaling" +) + +func PossibleValuesForHostingEnvironmentStatus() []string { + return []string{ + string(HostingEnvironmentStatusDeleting), + string(HostingEnvironmentStatusPreparing), + string(HostingEnvironmentStatusReady), + string(HostingEnvironmentStatusScaling), + } +} + +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { + vals := map[string]HostingEnvironmentStatus{ + "deleting": HostingEnvironmentStatusDeleting, + "preparing": HostingEnvironmentStatusPreparing, + "ready": HostingEnvironmentStatusReady, + "scaling": HostingEnvironmentStatusScaling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingEnvironmentStatus(input) + return &out, nil +} + +type InAvailabilityReasonType string + +const ( + InAvailabilityReasonTypeAlreadyExists InAvailabilityReasonType = "AlreadyExists" + InAvailabilityReasonTypeInvalid InAvailabilityReasonType = "Invalid" +) + +func PossibleValuesForInAvailabilityReasonType() []string { + return []string{ + string(InAvailabilityReasonTypeAlreadyExists), + string(InAvailabilityReasonTypeInvalid), + } +} + +func (s *InAvailabilityReasonType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInAvailabilityReasonType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInAvailabilityReasonType(input string) (*InAvailabilityReasonType, error) { + vals := map[string]InAvailabilityReasonType{ + "alreadyexists": InAvailabilityReasonTypeAlreadyExists, + "invalid": InAvailabilityReasonTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InAvailabilityReasonType(input) + return &out, nil +} + +type LoadBalancingMode string + +const ( + LoadBalancingModeNone LoadBalancingMode = "None" + LoadBalancingModePublishing LoadBalancingMode = "Publishing" + LoadBalancingModeWeb LoadBalancingMode = "Web" + LoadBalancingModeWebPublishing LoadBalancingMode = "Web, Publishing" +) + +func PossibleValuesForLoadBalancingMode() []string { + return []string{ + string(LoadBalancingModeNone), + string(LoadBalancingModePublishing), + string(LoadBalancingModeWeb), + string(LoadBalancingModeWebPublishing), + } +} + +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { + vals := map[string]LoadBalancingMode{ + "none": LoadBalancingModeNone, + "publishing": LoadBalancingModePublishing, + "web": LoadBalancingModeWeb, + "web, publishing": LoadBalancingModeWebPublishing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancingMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "Basic" + SkuNameDynamic SkuName = "Dynamic" + SkuNameElasticIsolated SkuName = "ElasticIsolated" + SkuNameElasticPremium SkuName = "ElasticPremium" + SkuNameFlexConsumption SkuName = "FlexConsumption" + SkuNameFree SkuName = "Free" + SkuNameIsolated SkuName = "Isolated" + SkuNameIsolatedVTwo SkuName = "IsolatedV2" + SkuNamePremium SkuName = "Premium" + SkuNamePremiumContainer SkuName = "PremiumContainer" + SkuNamePremiumVThree SkuName = "PremiumV3" + SkuNamePremiumVTwo SkuName = "PremiumV2" + SkuNameShared SkuName = "Shared" + SkuNameStandard SkuName = "Standard" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNameDynamic), + string(SkuNameElasticIsolated), + string(SkuNameElasticPremium), + string(SkuNameFlexConsumption), + string(SkuNameFree), + string(SkuNameIsolated), + string(SkuNameIsolatedVTwo), + string(SkuNamePremium), + string(SkuNamePremiumContainer), + string(SkuNamePremiumVThree), + string(SkuNamePremiumVTwo), + string(SkuNameShared), + string(SkuNameStandard), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "dynamic": SkuNameDynamic, + "elasticisolated": SkuNameElasticIsolated, + "elasticpremium": SkuNameElasticPremium, + "flexconsumption": SkuNameFlexConsumption, + "free": SkuNameFree, + "isolated": SkuNameIsolated, + "isolatedv2": SkuNameIsolatedVTwo, + "premium": SkuNamePremium, + "premiumcontainer": SkuNamePremiumContainer, + "premiumv3": SkuNamePremiumVThree, + "premiumv2": SkuNamePremiumVTwo, + "shared": SkuNameShared, + "standard": SkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type UpgradeAvailability string + +const ( + UpgradeAvailabilityNone UpgradeAvailability = "None" + UpgradeAvailabilityReady UpgradeAvailability = "Ready" +) + +func PossibleValuesForUpgradeAvailability() []string { + return []string{ + string(UpgradeAvailabilityNone), + string(UpgradeAvailabilityReady), + } +} + +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { + vals := map[string]UpgradeAvailability{ + "none": UpgradeAvailabilityNone, + "ready": UpgradeAvailabilityReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeAvailability(input) + return &out, nil +} + +type UpgradePreference string + +const ( + UpgradePreferenceEarly UpgradePreference = "Early" + UpgradePreferenceLate UpgradePreference = "Late" + UpgradePreferenceManual UpgradePreference = "Manual" + UpgradePreferenceNone UpgradePreference = "None" +) + +func PossibleValuesForUpgradePreference() []string { + return []string{ + string(UpgradePreferenceEarly), + string(UpgradePreferenceLate), + string(UpgradePreferenceManual), + string(UpgradePreferenceNone), + } +} + +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradePreference(input string) (*UpgradePreference, error) { + vals := map[string]UpgradePreference{ + "early": UpgradePreferenceEarly, + "late": UpgradePreferenceLate, + "manual": UpgradePreferenceManual, + "none": UpgradePreferenceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradePreference(input) + return &out, nil +} + +type ValidateResourceTypes string + +const ( + ValidateResourceTypesMicrosoftPointWebHostingEnvironments ValidateResourceTypes = "Microsoft.Web/hostingEnvironments" + ValidateResourceTypesServerFarm ValidateResourceTypes = "ServerFarm" + ValidateResourceTypesSite ValidateResourceTypes = "Site" +) + +func PossibleValuesForValidateResourceTypes() []string { + return []string{ + string(ValidateResourceTypesMicrosoftPointWebHostingEnvironments), + string(ValidateResourceTypesServerFarm), + string(ValidateResourceTypesSite), + } +} + +func (s *ValidateResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidateResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidateResourceTypes(input string) (*ValidateResourceTypes, error) { + vals := map[string]ValidateResourceTypes{ + "microsoft.web/hostingenvironments": ValidateResourceTypesMicrosoftPointWebHostingEnvironments, + "serverfarm": ValidateResourceTypesServerFarm, + "site": ValidateResourceTypesSite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidateResourceTypes(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/id_providerlocation.go b/resource-manager/web/2023-12-01/resourceproviders/id_providerlocation.go new file mode 100644 index 00000000000..c73af0cec4a --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/id_providerlocation.go @@ -0,0 +1,121 @@ +package resourceproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/id_providerlocation_test.go b/resource-manager/web/2023-12-01/resourceproviders/id_providerlocation_test.go new file mode 100644 index 00000000000..f3a1f9e63b3 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package resourceproviders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol.go b/resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol.go new file mode 100644 index 00000000000..f59308a6f73 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol.go @@ -0,0 +1,112 @@ +package resourceproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SourceControlId{}) +} + +var _ resourceids.ResourceId = &SourceControlId{} + +// SourceControlId is a struct representing the Resource ID for a Source Control +type SourceControlId struct { + SourceControlName string +} + +// NewSourceControlID returns a new SourceControlId struct +func NewSourceControlID(sourceControlName string) SourceControlId { + return SourceControlId{ + SourceControlName: sourceControlName, + } +} + +// ParseSourceControlID parses 'input' into a SourceControlId +func ParseSourceControlID(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSourceControlIDInsensitively parses 'input' case-insensitively into a SourceControlId +// note: this method should only be used for API response data and not user input +func ParseSourceControlIDInsensitively(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SourceControlId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SourceControlName, ok = input.Parsed["sourceControlName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sourceControlName", input) + } + + return nil +} + +// ValidateSourceControlID checks that 'input' can be parsed as a Source Control ID +func ValidateSourceControlID(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 := ParseSourceControlID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Source Control ID +func (id SourceControlId) ID() string { + fmtString := "/providers/Microsoft.Web/sourceControls/%s" + return fmt.Sprintf(fmtString, id.SourceControlName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Source Control ID +func (id SourceControlId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSourceControls", "sourceControls", "sourceControls"), + resourceids.UserSpecifiedSegment("sourceControlName", "sourceControlValue"), + } +} + +// String returns a human-readable description of this Source Control ID +func (id SourceControlId) String() string { + components := []string{ + fmt.Sprintf("Source Control Name: %q", id.SourceControlName), + } + return fmt.Sprintf("Source Control (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol_test.go b/resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol_test.go new file mode 100644 index 00000000000..b9481327a4e --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/id_sourcecontrol_test.go @@ -0,0 +1,192 @@ +package resourceproviders + +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 = &SourceControlId{} + +func TestNewSourceControlID(t *testing.T) { + id := NewSourceControlID("sourceControlValue") + + if id.SourceControlName != "sourceControlValue" { + t.Fatalf("Expected %q but got %q for Segment 'SourceControlName'", id.SourceControlName, "sourceControlValue") + } +} + +func TestFormatSourceControlID(t *testing.T) { + actual := NewSourceControlID("sourceControlValue").ID() + expected := "/providers/Microsoft.Web/sourceControls/sourceControlValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSourceControlID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/sourceControls", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/sourceControls/sourceControlValue", + Expected: &SourceControlId{ + SourceControlName: "sourceControlValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/sourceControls/sourceControlValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestParseSourceControlIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/sourceControls", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/sourceControls/sourceControlValue", + Expected: &SourceControlId{ + SourceControlName: "sourceControlValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/sourceControls/sourceControlValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS/sOuRcEcOnTrOlVaLuE", + Expected: &SourceControlId{ + SourceControlName: "sOuRcEcOnTrOlVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS/sOuRcEcOnTrOlVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestSegmentsForSourceControlId(t *testing.T) { + segments := SourceControlId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SourceControlId 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/web/2023-12-01/resourceproviders/method_checknameavailability.go b/resource-manager/web/2023-12-01/resourceproviders/method_checknameavailability.go new file mode 100644 index 00000000000..1b0dd0b6a4f --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_checknameavailability.go @@ -0,0 +1,60 @@ +package resourceproviders + +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 CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceNameAvailability +} + +// CheckNameAvailability ... +func (c ResourceProvidersClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ResourceNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/checknameavailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceNameAvailability + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_getpublishinguser.go b/resource-manager/web/2023-12-01/resourceproviders/method_getpublishinguser.go new file mode 100644 index 00000000000..558a74efdd0 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_getpublishinguser.go @@ -0,0 +1,54 @@ +package resourceproviders + +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 GetPublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// GetPublishingUser ... +func (c ResourceProvidersClient) GetPublishingUser(ctx context.Context) (result GetPublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model User + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_getsourcecontrol.go b/resource-manager/web/2023-12-01/resourceproviders/method_getsourcecontrol.go new file mode 100644 index 00000000000..2035eb827a6 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_getsourcecontrol.go @@ -0,0 +1,54 @@ +package resourceproviders + +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 GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// GetSourceControl ... +func (c ResourceProvidersClient) GetSourceControl(ctx context.Context, id SourceControlId) (result GetSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SourceControl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_getsubscriptiondeploymentlocations.go b/resource-manager/web/2023-12-01/resourceproviders/method_getsubscriptiondeploymentlocations.go new file mode 100644 index 00000000000..54881368bcb --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_getsubscriptiondeploymentlocations.go @@ -0,0 +1,56 @@ +package resourceproviders + +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 GetSubscriptionDeploymentLocationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeploymentLocations +} + +// GetSubscriptionDeploymentLocations ... +func (c ResourceProvidersClient) GetSubscriptionDeploymentLocations(ctx context.Context, id commonids.SubscriptionId) (result GetSubscriptionDeploymentLocationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/deploymentLocations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeploymentLocations + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_getusagesinlocationlist.go b/resource-manager/web/2023-12-01/resourceproviders/method_getusagesinlocationlist.go new file mode 100644 index 00000000000..444fc08034c --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_getusagesinlocationlist.go @@ -0,0 +1,91 @@ +package resourceproviders + +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 GetUsagesInLocationlistOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type GetUsagesInLocationlistCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +// GetUsagesInLocationlist ... +func (c ResourceProvidersClient) GetUsagesInLocationlist(ctx context.Context, id ProviderLocationId) (result GetUsagesInLocationlistOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUsagesInLocationlistComplete retrieves all the results into a single object +func (c ResourceProvidersClient) GetUsagesInLocationlistComplete(ctx context.Context, id ProviderLocationId) (GetUsagesInLocationlistCompleteResult, error) { + return c.GetUsagesInLocationlistCompleteMatchingPredicate(ctx, id, CsmUsageQuotaOperationPredicate{}) +} + +// GetUsagesInLocationlistCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) GetUsagesInLocationlistCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate CsmUsageQuotaOperationPredicate) (result GetUsagesInLocationlistCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.GetUsagesInLocationlist(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 = GetUsagesInLocationlistCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listaseregions.go b/resource-manager/web/2023-12-01/resourceproviders/method_listaseregions.go new file mode 100644 index 00000000000..96115eb19be --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listaseregions.go @@ -0,0 +1,92 @@ +package resourceproviders + +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 ListAseRegionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AseRegion +} + +type ListAseRegionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []AseRegion +} + +// ListAseRegions ... +func (c ResourceProvidersClient) ListAseRegions(ctx context.Context, id commonids.SubscriptionId) (result ListAseRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/aseRegions", 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 *[]AseRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAseRegionsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListAseRegionsComplete(ctx context.Context, id commonids.SubscriptionId) (ListAseRegionsCompleteResult, error) { + return c.ListAseRegionsCompleteMatchingPredicate(ctx, id, AseRegionOperationPredicate{}) +} + +// ListAseRegionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListAseRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AseRegionOperationPredicate) (result ListAseRegionsCompleteResult, err error) { + items := make([]AseRegion, 0) + + resp, err := c.ListAseRegions(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 = ListAseRegionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listbillingmeters.go b/resource-manager/web/2023-12-01/resourceproviders/method_listbillingmeters.go new file mode 100644 index 00000000000..4628940320d --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listbillingmeters.go @@ -0,0 +1,124 @@ +package resourceproviders + +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 ListBillingMetersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BillingMeter +} + +type ListBillingMetersCompleteResult struct { + LatestHttpResponse *http.Response + Items []BillingMeter +} + +type ListBillingMetersOperationOptions struct { + BillingLocation *string + OsType *string +} + +func DefaultListBillingMetersOperationOptions() ListBillingMetersOperationOptions { + return ListBillingMetersOperationOptions{} +} + +func (o ListBillingMetersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBillingMetersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListBillingMetersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.BillingLocation != nil { + out.Append("billingLocation", fmt.Sprintf("%v", *o.BillingLocation)) + } + if o.OsType != nil { + out.Append("osType", fmt.Sprintf("%v", *o.OsType)) + } + return &out +} + +// ListBillingMeters ... +func (c ResourceProvidersClient) ListBillingMeters(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (result ListBillingMetersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/billingMeters", 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 *[]BillingMeter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBillingMetersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListBillingMetersComplete(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (ListBillingMetersCompleteResult, error) { + return c.ListBillingMetersCompleteMatchingPredicate(ctx, id, options, BillingMeterOperationPredicate{}) +} + +// ListBillingMetersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListBillingMetersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions, predicate BillingMeterOperationPredicate) (result ListBillingMetersCompleteResult, err error) { + items := make([]BillingMeter, 0) + + resp, err := c.ListBillingMeters(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 = ListBillingMetersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listcustomhostnamesites.go b/resource-manager/web/2023-12-01/resourceproviders/method_listcustomhostnamesites.go new file mode 100644 index 00000000000..0043ea891a4 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listcustomhostnamesites.go @@ -0,0 +1,120 @@ +package resourceproviders + +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 ListCustomHostNameSitesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomHostnameSites +} + +type ListCustomHostNameSitesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomHostnameSites +} + +type ListCustomHostNameSitesOperationOptions struct { + Hostname *string +} + +func DefaultListCustomHostNameSitesOperationOptions() ListCustomHostNameSitesOperationOptions { + return ListCustomHostNameSitesOperationOptions{} +} + +func (o ListCustomHostNameSitesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Hostname != nil { + out.Append("hostname", fmt.Sprintf("%v", *o.Hostname)) + } + return &out +} + +// ListCustomHostNameSites ... +func (c ResourceProvidersClient) ListCustomHostNameSites(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (result ListCustomHostNameSitesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/customhostnameSites", 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 *[]CustomHostnameSites `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCustomHostNameSitesComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListCustomHostNameSitesComplete(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (ListCustomHostNameSitesCompleteResult, error) { + return c.ListCustomHostNameSitesCompleteMatchingPredicate(ctx, id, options, CustomHostnameSitesOperationPredicate{}) +} + +// ListCustomHostNameSitesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListCustomHostNameSitesCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions, predicate CustomHostnameSitesOperationPredicate) (result ListCustomHostNameSitesCompleteResult, err error) { + items := make([]CustomHostnameSites, 0) + + resp, err := c.ListCustomHostNameSites(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 = ListCustomHostNameSitesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listgeoregions.go b/resource-manager/web/2023-12-01/resourceproviders/method_listgeoregions.go new file mode 100644 index 00000000000..3f59e6d2187 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listgeoregions.go @@ -0,0 +1,132 @@ +package resourceproviders + +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 ListGeoRegionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GeoRegion +} + +type ListGeoRegionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []GeoRegion +} + +type ListGeoRegionsOperationOptions struct { + LinuxDynamicWorkersEnabled *bool + LinuxWorkersEnabled *bool + Sku *SkuName + XenonWorkersEnabled *bool +} + +func DefaultListGeoRegionsOperationOptions() ListGeoRegionsOperationOptions { + return ListGeoRegionsOperationOptions{} +} + +func (o ListGeoRegionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListGeoRegionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListGeoRegionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.LinuxDynamicWorkersEnabled != nil { + out.Append("linuxDynamicWorkersEnabled", fmt.Sprintf("%v", *o.LinuxDynamicWorkersEnabled)) + } + if o.LinuxWorkersEnabled != nil { + out.Append("linuxWorkersEnabled", fmt.Sprintf("%v", *o.LinuxWorkersEnabled)) + } + if o.Sku != nil { + out.Append("sku", fmt.Sprintf("%v", *o.Sku)) + } + if o.XenonWorkersEnabled != nil { + out.Append("xenonWorkersEnabled", fmt.Sprintf("%v", *o.XenonWorkersEnabled)) + } + return &out +} + +// ListGeoRegions ... +func (c ResourceProvidersClient) ListGeoRegions(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (result ListGeoRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/geoRegions", 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 *[]GeoRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListGeoRegionsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListGeoRegionsComplete(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (ListGeoRegionsCompleteResult, error) { + return c.ListGeoRegionsCompleteMatchingPredicate(ctx, id, options, GeoRegionOperationPredicate{}) +} + +// ListGeoRegionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListGeoRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions, predicate GeoRegionOperationPredicate) (result ListGeoRegionsCompleteResult, err error) { + items := make([]GeoRegion, 0) + + resp, err := c.ListGeoRegions(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 = ListGeoRegionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listpremieraddonoffers.go b/resource-manager/web/2023-12-01/resourceproviders/method_listpremieraddonoffers.go new file mode 100644 index 00000000000..1a34ba8347b --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listpremieraddonoffers.go @@ -0,0 +1,92 @@ +package resourceproviders + +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 ListPremierAddOnOffersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PremierAddOnOffer +} + +type ListPremierAddOnOffersCompleteResult struct { + LatestHttpResponse *http.Response + Items []PremierAddOnOffer +} + +// ListPremierAddOnOffers ... +func (c ResourceProvidersClient) ListPremierAddOnOffers(ctx context.Context, id commonids.SubscriptionId) (result ListPremierAddOnOffersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/premieraddonoffers", 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 *[]PremierAddOnOffer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPremierAddOnOffersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListPremierAddOnOffersComplete(ctx context.Context, id commonids.SubscriptionId) (ListPremierAddOnOffersCompleteResult, error) { + return c.ListPremierAddOnOffersCompleteMatchingPredicate(ctx, id, PremierAddOnOfferOperationPredicate{}) +} + +// ListPremierAddOnOffersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListPremierAddOnOffersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PremierAddOnOfferOperationPredicate) (result ListPremierAddOnOffersCompleteResult, err error) { + items := make([]PremierAddOnOffer, 0) + + resp, err := c.ListPremierAddOnOffers(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 = ListPremierAddOnOffersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go b/resource-manager/web/2023-12-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go new file mode 100644 index 00000000000..ed3fb516578 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go @@ -0,0 +1,92 @@ +package resourceproviders + +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 ListSiteIdentifiersAssignedToHostNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListSiteIdentifiersAssignedToHostNameCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +// ListSiteIdentifiersAssignedToHostName ... +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostName(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/listSitesAssignedToHostName", 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 *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteIdentifiersAssignedToHostNameComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameComplete(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (ListSiteIdentifiersAssignedToHostNameCompleteResult, error) { + return c.ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx, id, input, IdentifierOperationPredicate{}) +} + +// ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier, predicate IdentifierOperationPredicate) (result ListSiteIdentifiersAssignedToHostNameCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListSiteIdentifiersAssignedToHostName(ctx, id, input) + 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 = ListSiteIdentifiersAssignedToHostNameCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listskus.go b/resource-manager/web/2023-12-01/resourceproviders/method_listskus.go new file mode 100644 index 00000000000..494e7016169 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listskus.go @@ -0,0 +1,56 @@ +package resourceproviders + +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 ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuInfos +} + +// ListSkus ... +func (c ResourceProvidersClient) ListSkus(ctx context.Context, id commonids.SubscriptionId) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SkuInfos + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_listsourcecontrols.go b/resource-manager/web/2023-12-01/resourceproviders/method_listsourcecontrols.go new file mode 100644 index 00000000000..70025325e8d --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_listsourcecontrols.go @@ -0,0 +1,91 @@ +package resourceproviders + +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 ListSourceControlsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SourceControl +} + +type ListSourceControlsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SourceControl +} + +// ListSourceControls ... +func (c ResourceProvidersClient) ListSourceControls(ctx context.Context) (result ListSourceControlsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/sourceControls", + } + + 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 *[]SourceControl `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSourceControlsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSourceControlsComplete(ctx context.Context) (ListSourceControlsCompleteResult, error) { + return c.ListSourceControlsCompleteMatchingPredicate(ctx, SourceControlOperationPredicate{}) +} + +// ListSourceControlsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSourceControlsCompleteMatchingPredicate(ctx context.Context, predicate SourceControlOperationPredicate) (result ListSourceControlsCompleteResult, err error) { + items := make([]SourceControl, 0) + + resp, err := c.ListSourceControls(ctx) + 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 = ListSourceControlsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_move.go b/resource-manager/web/2023-12-01/resourceproviders/method_move.go new file mode 100644 index 00000000000..1d47ce748e7 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_move.go @@ -0,0 +1,52 @@ +package resourceproviders + +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 MoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Move ... +func (c ResourceProvidersClient) Move(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result MoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/moveResources", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_updatepublishinguser.go b/resource-manager/web/2023-12-01/resourceproviders/method_updatepublishinguser.go new file mode 100644 index 00000000000..58d177a7f00 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_updatepublishinguser.go @@ -0,0 +1,58 @@ +package resourceproviders + +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 UpdatePublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// UpdatePublishingUser ... +func (c ResourceProvidersClient) UpdatePublishingUser(ctx context.Context, input User) (result UpdatePublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model User + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_updatesourcecontrol.go b/resource-manager/web/2023-12-01/resourceproviders/method_updatesourcecontrol.go new file mode 100644 index 00000000000..fba65489698 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_updatesourcecontrol.go @@ -0,0 +1,58 @@ +package resourceproviders + +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 UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// UpdateSourceControl ... +func (c ResourceProvidersClient) UpdateSourceControl(ctx context.Context, id SourceControlId, input SourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SourceControl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_validate.go b/resource-manager/web/2023-12-01/resourceproviders/method_validate.go new file mode 100644 index 00000000000..055e2a0b590 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_validate.go @@ -0,0 +1,60 @@ +package resourceproviders + +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 ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateResponse +} + +// Validate ... +func (c ResourceProvidersClient) Validate(ctx context.Context, id commonids.ResourceGroupId, input ValidateRequest) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/validate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ValidateResponse + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_validatemove.go b/resource-manager/web/2023-12-01/resourceproviders/method_validatemove.go new file mode 100644 index 00000000000..7df2e3df0eb --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_validatemove.go @@ -0,0 +1,52 @@ +package resourceproviders + +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 ValidateMoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateMove ... +func (c ResourceProvidersClient) ValidateMove(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result ValidateMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateMoveResources", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/method_verifyhostingenvironmentvnet.go b/resource-manager/web/2023-12-01/resourceproviders/method_verifyhostingenvironmentvnet.go new file mode 100644 index 00000000000..f2d83339160 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/method_verifyhostingenvironmentvnet.go @@ -0,0 +1,60 @@ +package resourceproviders + +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 VerifyHostingEnvironmentVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetValidationFailureDetails +} + +// VerifyHostingEnvironmentVnet ... +func (c ResourceProvidersClient) VerifyHostingEnvironmentVnet(ctx context.Context, id commonids.SubscriptionId, input VnetParameters) (result VerifyHostingEnvironmentVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/verifyHostingEnvironmentVnet", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetValidationFailureDetails + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_appserviceenvironment.go b/resource-manager/web/2023-12-01/resourceproviders/model_appserviceenvironment.go new file mode 100644 index 00000000000..4c64f3befc2 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_appserviceenvironment.go @@ -0,0 +1,27 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironment struct { + ClusterSettings *[]NameValuePair `json:"clusterSettings,omitempty"` + CustomDnsSuffixConfiguration *CustomDnsSuffixConfiguration `json:"customDnsSuffixConfiguration,omitempty"` + DedicatedHostCount *int64 `json:"dedicatedHostCount,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + FrontEndScaleFactor *int64 `json:"frontEndScaleFactor,omitempty"` + HasLinuxWorkers *bool `json:"hasLinuxWorkers,omitempty"` + IPsslAddressCount *int64 `json:"ipsslAddressCount,omitempty"` + InternalLoadBalancingMode *LoadBalancingMode `json:"internalLoadBalancingMode,omitempty"` + MaximumNumberOfMachines *int64 `json:"maximumNumberOfMachines,omitempty"` + MultiRoleCount *int64 `json:"multiRoleCount,omitempty"` + MultiSize *string `json:"multiSize,omitempty"` + NetworkingConfiguration *AseV3NetworkingConfiguration `json:"networkingConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *HostingEnvironmentStatus `json:"status,omitempty"` + Suspended *bool `json:"suspended,omitempty"` + UpgradeAvailability *UpgradeAvailability `json:"upgradeAvailability,omitempty"` + UpgradePreference *UpgradePreference `json:"upgradePreference,omitempty"` + UserWhitelistedIPRanges *[]string `json:"userWhitelistedIpRanges,omitempty"` + VirtualNetwork VirtualNetworkProfile `json:"virtualNetwork"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_aseregion.go b/resource-manager/web/2023-12-01/resourceproviders/model_aseregion.go new file mode 100644 index 00000000000..75229a008cc --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_aseregion.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegion struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseRegionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_aseregionproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_aseregionproperties.go new file mode 100644 index 00000000000..193d6e9cc24 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_aseregionproperties.go @@ -0,0 +1,13 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegionProperties struct { + AvailableOS *[]string `json:"availableOS,omitempty"` + AvailableSku *[]string `json:"availableSku,omitempty"` + DedicatedHost *bool `json:"dedicatedHost,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Standard *bool `json:"standard,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfiguration.go b/resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfiguration.go new file mode 100644 index 00000000000..44e592b0c22 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfiguration.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseV3NetworkingConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfigurationproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfigurationproperties.go new file mode 100644 index 00000000000..d93b1c90db6 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_asev3networkingconfigurationproperties.go @@ -0,0 +1,15 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfigurationProperties struct { + AllowNewPrivateEndpointConnections *bool `json:"allowNewPrivateEndpointConnections,omitempty"` + ExternalInboundIPAddresses *[]string `json:"externalInboundIpAddresses,omitempty"` + FtpEnabled *bool `json:"ftpEnabled,omitempty"` + InboundIPAddressOverride *string `json:"inboundIpAddressOverride,omitempty"` + InternalInboundIPAddresses *[]string `json:"internalInboundIpAddresses,omitempty"` + LinuxOutboundIPAddresses *[]string `json:"linuxOutboundIpAddresses,omitempty"` + RemoteDebugEnabled *bool `json:"remoteDebugEnabled,omitempty"` + WindowsOutboundIPAddresses *[]string `json:"windowsOutboundIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_billingmeter.go b/resource-manager/web/2023-12-01/resourceproviders/model_billingmeter.go new file mode 100644 index 00000000000..5d22f02ed37 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_billingmeter.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeter struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BillingMeterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_billingmeterproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_billingmeterproperties.go new file mode 100644 index 00000000000..aae6e22c948 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_billingmeterproperties.go @@ -0,0 +1,14 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeterProperties struct { + BillingLocation *string `json:"billingLocation,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + MeterId *string `json:"meterId,omitempty"` + Multiplier *float64 `json:"multiplier,omitempty"` + OsType *string `json:"osType,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + ShortName *string `json:"shortName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_capability.go b/resource-manager/web/2023-12-01/resourceproviders/model_capability.go new file mode 100644 index 00000000000..85356855f60 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_capability.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_csmmoveresourceenvelope.go b/resource-manager/web/2023-12-01/resourceproviders/model_csmmoveresourceenvelope.go new file mode 100644 index 00000000000..6e585fdc416 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_csmmoveresourceenvelope.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmMoveResourceEnvelope struct { + Resources *[]string `json:"resources,omitempty"` + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_csmusagequota.go b/resource-manager/web/2023-12-01/resourceproviders/model_csmusagequota.go new file mode 100644 index 00000000000..d3c613eb248 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_csmusagequota.go @@ -0,0 +1,30 @@ +package resourceproviders + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfiguration.go b/resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfiguration.go new file mode 100644 index 00000000000..59f89a9a6b2 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfiguration.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomDnsSuffixConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfigurationproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfigurationproperties.go new file mode 100644 index 00000000000..ba59ff8812d --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_customdnssuffixconfigurationproperties.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfigurationProperties struct { + CertificateUrl *string `json:"certificateUrl,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + ProvisioningDetails *string `json:"provisioningDetails,omitempty"` + ProvisioningState *CustomDnsSuffixProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesites.go b/resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesites.go new file mode 100644 index 00000000000..f967d7a3153 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesites.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameSites struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomHostnameSitesProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesitesproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesitesproperties.go new file mode 100644 index 00000000000..d7767777efa --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_customhostnamesitesproperties.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameSitesProperties struct { + CustomHostname *string `json:"customHostname,omitempty"` + Region *string `json:"region,omitempty"` + SiteResourceIds *[]Identifier `json:"siteResourceIds,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_deploymentlocations.go b/resource-manager/web/2023-12-01/resourceproviders/model_deploymentlocations.go new file mode 100644 index 00000000000..0cf632a9502 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_deploymentlocations.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentLocations struct { + HostingEnvironmentDeploymentInfos *[]HostingEnvironmentDeploymentInfo `json:"hostingEnvironmentDeploymentInfos,omitempty"` + HostingEnvironments *[]AppServiceEnvironment `json:"hostingEnvironments,omitempty"` + Locations *[]GeoRegion `json:"locations,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_georegion.go b/resource-manager/web/2023-12-01/resourceproviders/model_georegion.go new file mode 100644 index 00000000000..bc4c17360b5 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_georegion.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeoRegion struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *GeoRegionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_georegionproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_georegionproperties.go new file mode 100644 index 00000000000..1511ccc9e28 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_georegionproperties.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeoRegionProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + OrgDomain *string `json:"orgDomain,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_globalcsmskudescription.go b/resource-manager/web/2023-12-01/resourceproviders/model_globalcsmskudescription.go new file mode 100644 index 00000000000..fee5a130039 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_globalcsmskudescription.go @@ -0,0 +1,14 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalCsmSkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *SkuCapacity `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go b/resource-manager/web/2023-12-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go new file mode 100644 index 00000000000..5cbdecfc3f3 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentDeploymentInfo struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_identifier.go b/resource-manager/web/2023-12-01/resourceproviders/model_identifier.go new file mode 100644 index 00000000000..879aff521be --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_identifier.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Identifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_identifierproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_identifierproperties.go new file mode 100644 index 00000000000..5fee3a1ed5d --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_identifierproperties.go @@ -0,0 +1,8 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentifierProperties struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_localizablestring.go b/resource-manager/web/2023-12-01/resourceproviders/model_localizablestring.go new file mode 100644 index 00000000000..4ee07f00d95 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_localizablestring.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_nameidentifier.go b/resource-manager/web/2023-12-01/resourceproviders/model_nameidentifier.go new file mode 100644 index 00000000000..94caff8a110 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_namevaluepair.go b/resource-manager/web/2023-12-01/resourceproviders/model_namevaluepair.go new file mode 100644 index 00000000000..30d7a8f6546 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_namevaluepair.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_premieraddonoffer.go b/resource-manager/web/2023-12-01/resourceproviders/model_premieraddonoffer.go new file mode 100644 index 00000000000..8245c61bc6e --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_premieraddonoffer.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnOffer struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnOfferProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_premieraddonofferproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_premieraddonofferproperties.go new file mode 100644 index 00000000000..4dcce517ebe --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_premieraddonofferproperties.go @@ -0,0 +1,17 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnOfferProperties struct { + LegalTermsUrl *string `json:"legalTermsUrl,omitempty"` + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + PrivacyPolicyUrl *string `json:"privacyPolicyUrl,omitempty"` + Product *string `json:"product,omitempty"` + PromoCodeRequired *bool `json:"promoCodeRequired,omitempty"` + Quota *int64 `json:"quota,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` + WebHostingPlanRestrictions *AppServicePlanRestrictions `json:"webHostingPlanRestrictions,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailability.go b/resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailability.go new file mode 100644 index 00000000000..0a19de2fac8 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailability.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNameAvailability struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *InAvailabilityReasonType `json:"reason,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailabilityrequest.go b/resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailabilityrequest.go new file mode 100644 index 00000000000..abefca1cda6 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_resourcenameavailabilityrequest.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNameAvailabilityRequest struct { + EnvironmentId *string `json:"environmentId,omitempty"` + IsFqdn *bool `json:"isFqdn,omitempty"` + Name string `json:"name"` + Type CheckNameResourceTypes `json:"type"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_skucapacity.go b/resource-manager/web/2023-12-01/resourceproviders/model_skucapacity.go new file mode 100644 index 00000000000..9f5bcf3423d --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_skucapacity.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_skuinfos.go b/resource-manager/web/2023-12-01/resourceproviders/model_skuinfos.go new file mode 100644 index 00000000000..c0c36d86b52 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_skuinfos.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuInfos struct { + ResourceType *string `json:"resourceType,omitempty"` + Skus *[]GlobalCsmSkuDescription `json:"skus,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrol.go b/resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrol.go new file mode 100644 index 00000000000..03ce9771a74 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrol.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceControl struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SourceControlProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrolproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrolproperties.go new file mode 100644 index 00000000000..012dfe7a3c3 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_sourcecontrolproperties.go @@ -0,0 +1,29 @@ +package resourceproviders + +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 SourceControlProperties struct { + ExpirationTime *string `json:"expirationTime,omitempty"` + RefreshToken *string `json:"refreshToken,omitempty"` + Token *string `json:"token,omitempty"` + TokenSecret *string `json:"tokenSecret,omitempty"` +} + +func (o *SourceControlProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SourceControlProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_user.go b/resource-manager/web/2023-12-01/resourceproviders/model_user.go new file mode 100644 index 00000000000..adb8119b83f --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_user.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type User struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UserProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_userproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_userproperties.go new file mode 100644 index 00000000000..7ac82ad3b1f --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_userproperties.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserProperties struct { + PublishingPassword *string `json:"publishingPassword,omitempty"` + PublishingPasswordHash *string `json:"publishingPasswordHash,omitempty"` + PublishingPasswordHashSalt *string `json:"publishingPasswordHashSalt,omitempty"` + PublishingUserName string `json:"publishingUserName"` + ScmUri *string `json:"scmUri,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_validateproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_validateproperties.go new file mode 100644 index 00000000000..390aaea61b0 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_validateproperties.go @@ -0,0 +1,21 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateProperties struct { + AppServiceEnvironment *AppServiceEnvironment `json:"appServiceEnvironment,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + ContainerImagePlatform *string `json:"containerImagePlatform,omitempty"` + ContainerImageRepository *string `json:"containerImageRepository,omitempty"` + ContainerImageTag *string `json:"containerImageTag,omitempty"` + ContainerRegistryBaseUrl *string `json:"containerRegistryBaseUrl,omitempty"` + ContainerRegistryPassword *string `json:"containerRegistryPassword,omitempty"` + ContainerRegistryUsername *string `json:"containerRegistryUsername,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + NeedLinuxWorkers *bool `json:"needLinuxWorkers,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SkuName *string `json:"skuName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_validaterequest.go b/resource-manager/web/2023-12-01/resourceproviders/model_validaterequest.go new file mode 100644 index 00000000000..c7dc8dc05f4 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_validaterequest.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateRequest struct { + Location string `json:"location"` + Name string `json:"name"` + Properties ValidateProperties `json:"properties"` + Type ValidateResourceTypes `json:"type"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_validateresponse.go b/resource-manager/web/2023-12-01/resourceproviders/model_validateresponse.go new file mode 100644 index 00000000000..dbc96e23750 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_validateresponse.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateResponse struct { + Error *ValidateResponseError `json:"error,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_validateresponseerror.go b/resource-manager/web/2023-12-01/resourceproviders/model_validateresponseerror.go new file mode 100644 index 00000000000..8d4f8adf944 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_validateresponseerror.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateResponseError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_virtualnetworkprofile.go b/resource-manager/web/2023-12-01/resourceproviders/model_virtualnetworkprofile.go new file mode 100644 index 00000000000..b6498b01aea --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_virtualnetworkprofile.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkProfile struct { + Id string `json:"id"` + Name *string `json:"name,omitempty"` + Subnet *string `json:"subnet,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_vnetparameters.go b/resource-manager/web/2023-12-01/resourceproviders/model_vnetparameters.go new file mode 100644 index 00000000000..195de734cb3 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_vnetparameters.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetParameters struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetParametersProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_vnetparametersproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_vnetparametersproperties.go new file mode 100644 index 00000000000..86fff378387 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_vnetparametersproperties.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetParametersProperties struct { + SubnetResourceId *string `json:"subnetResourceId,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetResourceGroup *string `json:"vnetResourceGroup,omitempty"` + VnetSubnetName *string `json:"vnetSubnetName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetails.go b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetails.go new file mode 100644 index 00000000000..c6f31ff5b83 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetails.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationFailureDetails struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetValidationFailureDetailsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go new file mode 100644 index 00000000000..edae58023cb --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationFailureDetailsProperties struct { + Failed *bool `json:"failed,omitempty"` + FailedTests *[]VnetValidationTestFailure `json:"failedTests,omitempty"` + Message *string `json:"message,omitempty"` + Warnings *[]VnetValidationTestFailure `json:"warnings,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailure.go b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailure.go new file mode 100644 index 00000000000..2ecad9b35ca --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailure.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationTestFailure struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetValidationTestFailureProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailureproperties.go b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailureproperties.go new file mode 100644 index 00000000000..68ba825c530 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/model_vnetvalidationtestfailureproperties.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationTestFailureProperties struct { + Details *string `json:"details,omitempty"` + TestName *string `json:"testName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/resourceproviders/predicates.go b/resource-manager/web/2023-12-01/resourceproviders/predicates.go new file mode 100644 index 00000000000..c633f44ef01 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/predicates.go @@ -0,0 +1,228 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p AseRegionOperationPredicate) Matches(input AseRegion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type BillingMeterOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p BillingMeterOperationPredicate) Matches(input BillingMeter) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type CustomHostnameSitesOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CustomHostnameSitesOperationPredicate) Matches(input CustomHostnameSites) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type GeoRegionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p GeoRegionOperationPredicate) Matches(input GeoRegion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type IdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p IdentifierOperationPredicate) Matches(input Identifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type PremierAddOnOfferOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p PremierAddOnOfferOperationPredicate) Matches(input PremierAddOnOffer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SourceControlOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SourceControlOperationPredicate) Matches(input SourceControl) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/resourceproviders/version.go b/resource-manager/web/2023-12-01/resourceproviders/version.go new file mode 100644 index 00000000000..40dd9249d39 --- /dev/null +++ b/resource-manager/web/2023-12-01/resourceproviders/version.go @@ -0,0 +1,12 @@ +package resourceproviders + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourceproviders/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/staticsites/README.md b/resource-manager/web/2023-12-01/staticsites/README.md new file mode 100644 index 00000000000..9a605698b79 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/README.md @@ -0,0 +1,1300 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/staticsites` Documentation + +The `staticsites` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/staticsites" +``` + + +### Client Initialization + +```go +client := staticsites.NewStaticSitesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StaticSitesClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "privateEndpointConnectionValue") + +payload := staticsites.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StaticSiteBasicAuthPropertiesARMResource{ + // ... +} + + +read, err := client.CreateOrUpdateBasicAuth(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "databaseConnectionValue") + +payload := staticsites.DatabaseConnection{ + // ... +} + + +read, err := client.CreateOrUpdateBuildDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "databaseConnectionValue") + +payload := staticsites.DatabaseConnection{ + // ... +} + + +read, err := client.CreateOrUpdateDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StaticSiteARMResource{ + // ... +} + + +if err := client.CreateOrUpdateStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteBuildAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteBuildAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteBuildFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "customDomainValue") + +payload := staticsites.StaticSiteCustomDomainRequestPropertiesARMResource{ + // ... +} + + +if err := client.CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteFunctionAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateUserRolesInvitationLink` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StaticSiteUserInvitationRequestResource{ + // ... +} + + +read, err := client.CreateUserRolesInvitationLink(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateZipDeploymentForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StaticSiteZipDeploymentARMResource{ + // ... +} + + +if err := client.CreateZipDeploymentForStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateZipDeploymentForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +payload := staticsites.StaticSiteZipDeploymentARMResource{ + // ... +} + + +if err := client.CreateZipDeploymentForStaticSiteBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "databaseConnectionValue") + +read, err := client.DeleteBuildDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DeleteDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "databaseConnectionValue") + +read, err := client.DeleteDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "privateEndpointConnectionValue") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +if err := client.DeleteStaticSiteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +if err := client.DeleteStaticSiteBuildThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "customDomainValue") + +if err := client.DeleteStaticSiteCustomDomainThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteUser` + +```go +ctx := context.TODO() +id := staticsites.NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "authProviderValue", "userValue") + +read, err := client.DeleteStaticSiteUser(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DetachStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +if err := client.DetachStaticSiteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DetachUserProvidedFunctionAppFromStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "userProvidedFunctionAppValue") + +read, err := client.DetachUserProvidedFunctionAppFromStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DetachUserProvidedFunctionAppFromStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "userProvidedFunctionAppValue") + +read, err := client.DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +read, err := client.GetBasicAuth(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "databaseConnectionValue") + +read, err := client.GetBuildDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnectionWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "databaseConnectionValue") + +read, err := client.GetBuildDatabaseConnectionWithDetails(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnections` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +// alternatively `client.GetBuildDatabaseConnections(ctx, id)` can be used to do batched pagination +items, err := client.GetBuildDatabaseConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnectionsWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +// alternatively `client.GetBuildDatabaseConnectionsWithDetails(ctx, id)` can be used to do batched pagination +items, err := client.GetBuildDatabaseConnectionsWithDetailsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "databaseConnectionValue") + +read, err := client.GetDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnectionWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "databaseConnectionValue") + +read, err := client.GetDatabaseConnectionWithDetails(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnections` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.GetDatabaseConnections(ctx, id)` can be used to do batched pagination +items, err := client.GetDatabaseConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnectionsWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.GetDatabaseConnectionsWithDetails(ctx, id)` can be used to do batched pagination +items, err := client.GetDatabaseConnectionsWithDetailsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "linkedBackendValue") + +read, err := client.GetLinkedBackend(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackendForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "linkedBackendValue") + +read, err := client.GetLinkedBackendForBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackends` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.GetLinkedBackends(ctx, id)` can be used to do batched pagination +items, err := client.GetLinkedBackendsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackendsForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +// alternatively `client.GetLinkedBackendsForBuild(ctx, id)` can be used to do batched pagination +items, err := client.GetLinkedBackendsForBuildComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "privateEndpointConnectionValue") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +read, err := client.GetStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +read, err := client.GetStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteBuilds` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.GetStaticSiteBuilds(ctx, id)` can be used to do batched pagination +items, err := client.GetStaticSiteBuildsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "customDomainValue") + +read, err := client.GetStaticSiteCustomDomain(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSitesByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.GetStaticSitesByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.GetStaticSitesByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "userProvidedFunctionAppValue") + +read, err := client.GetUserProvidedFunctionAppForStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "userProvidedFunctionAppValue") + +read, err := client.GetUserProvidedFunctionAppForStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppsForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.GetUserProvidedFunctionAppsForStaticSite(ctx, id)` can be used to do batched pagination +items, err := client.GetUserProvidedFunctionAppsForStaticSiteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppsForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +// alternatively `client.GetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id)` can be used to do batched pagination +items, err := client.GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.LinkBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "linkedBackendValue") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.LinkBackendThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.LinkBackendToBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "linkedBackendValue") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.LinkBackendToBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `StaticSitesClient.ListBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.ListBasicAuth(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicAuthComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +read, err := client.ListStaticSiteAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +read, err := client.ListStaticSiteBuildAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +read, err := client.ListStaticSiteBuildFunctionAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildFunctions` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + +// alternatively `client.ListStaticSiteBuildFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteBuildFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteConfiguredRoles` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +read, err := client.ListStaticSiteConfiguredRoles(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteCustomDomains` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.ListStaticSiteCustomDomains(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteCustomDomainsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +read, err := client.ListStaticSiteFunctionAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteFunctions` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +// alternatively `client.ListStaticSiteFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteSecrets` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +read, err := client.ListStaticSiteSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteUsers` + +```go +ctx := context.TODO() +id := staticsites.NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "authProviderValue") + +// alternatively `client.ListStaticSiteUsers(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteUsersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.PreviewWorkflow` + +```go +ctx := context.TODO() +id := staticsites.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +payload := staticsites.StaticSitesWorkflowPreviewRequest{ + // ... +} + + +read, err := client.PreviewWorkflow(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.RegisterUserProvidedFunctionAppWithStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "userProvidedFunctionAppValue") + +payload := staticsites.StaticSiteUserProvidedFunctionAppARMResource{ + // ... +} + + +if err := client.RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx, id, payload, staticsites.DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.RegisterUserProvidedFunctionAppWithStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "userProvidedFunctionAppValue") + +payload := staticsites.StaticSiteUserProvidedFunctionAppARMResource{ + // ... +} + + +if err := client.RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx, id, payload, staticsites.DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ResetStaticSiteApiKey` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StaticSiteResetPropertiesARMResource{ + // ... +} + + +read, err := client.ResetStaticSiteApiKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UnlinkBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "linkedBackendValue") + +read, err := client.UnlinkBackend(ctx, id, staticsites.DefaultUnlinkBackendOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UnlinkBackendFromBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "linkedBackendValue") + +read, err := client.UnlinkBackendFromBuild(ctx, id, staticsites.DefaultUnlinkBackendFromBuildOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "databaseConnectionValue") + +payload := staticsites.DatabaseConnectionPatchRequest{ + // ... +} + + +read, err := client.UpdateBuildDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "databaseConnectionValue") + +payload := staticsites.DatabaseConnectionPatchRequest{ + // ... +} + + +read, err := client.UpdateDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + +payload := staticsites.StaticSitePatchResource{ + // ... +} + + +read, err := client.UpdateStaticSite(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateStaticSiteUser` + +```go +ctx := context.TODO() +id := staticsites.NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "authProviderValue", "userValue") + +payload := staticsites.StaticSiteUserARMResource{ + // ... +} + + +read, err := client.UpdateStaticSiteUser(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ValidateBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "linkedBackendValue") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.ValidateBackendThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ValidateBackendForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "linkedBackendValue") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.ValidateBackendForBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ValidateCustomDomainCanBeAddedToStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "customDomainValue") + +payload := staticsites.StaticSiteCustomDomainRequestPropertiesARMResource{ + // ... +} + + +if err := client.ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2023-12-01/staticsites/client.go b/resource-manager/web/2023-12-01/staticsites/client.go new file mode 100644 index 00000000000..d725455a2d7 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/client.go @@ -0,0 +1,26 @@ +package staticsites + +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 StaticSitesClient struct { + Client *resourcemanager.Client +} + +func NewStaticSitesClientWithBaseURI(sdkApi sdkEnv.Api) (*StaticSitesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "staticsites", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StaticSitesClient: %+v", err) + } + + return &StaticSitesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/constants.go b/resource-manager/web/2023-12-01/staticsites/constants.go new file mode 100644 index 00000000000..dfdde973015 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/constants.go @@ -0,0 +1,251 @@ +package staticsites + +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 BuildStatus string + +const ( + BuildStatusDeleting BuildStatus = "Deleting" + BuildStatusDeploying BuildStatus = "Deploying" + BuildStatusDetached BuildStatus = "Detached" + BuildStatusFailed BuildStatus = "Failed" + BuildStatusReady BuildStatus = "Ready" + BuildStatusUploading BuildStatus = "Uploading" + BuildStatusWaitingForDeployment BuildStatus = "WaitingForDeployment" +) + +func PossibleValuesForBuildStatus() []string { + return []string{ + string(BuildStatusDeleting), + string(BuildStatusDeploying), + string(BuildStatusDetached), + string(BuildStatusFailed), + string(BuildStatusReady), + string(BuildStatusUploading), + string(BuildStatusWaitingForDeployment), + } +} + +func (s *BuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBuildStatus(input string) (*BuildStatus, error) { + vals := map[string]BuildStatus{ + "deleting": BuildStatusDeleting, + "deploying": BuildStatusDeploying, + "detached": BuildStatusDetached, + "failed": BuildStatusFailed, + "ready": BuildStatusReady, + "uploading": BuildStatusUploading, + "waitingfordeployment": BuildStatusWaitingForDeployment, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BuildStatus(input) + return &out, nil +} + +type CustomDomainStatus string + +const ( + CustomDomainStatusAdding CustomDomainStatus = "Adding" + CustomDomainStatusDeleting CustomDomainStatus = "Deleting" + CustomDomainStatusFailed CustomDomainStatus = "Failed" + CustomDomainStatusReady CustomDomainStatus = "Ready" + CustomDomainStatusRetrievingValidationToken CustomDomainStatus = "RetrievingValidationToken" + CustomDomainStatusUnhealthy CustomDomainStatus = "Unhealthy" + CustomDomainStatusValidating CustomDomainStatus = "Validating" +) + +func PossibleValuesForCustomDomainStatus() []string { + return []string{ + string(CustomDomainStatusAdding), + string(CustomDomainStatusDeleting), + string(CustomDomainStatusFailed), + string(CustomDomainStatusReady), + string(CustomDomainStatusRetrievingValidationToken), + string(CustomDomainStatusUnhealthy), + string(CustomDomainStatusValidating), + } +} + +func (s *CustomDomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDomainStatus(input string) (*CustomDomainStatus, error) { + vals := map[string]CustomDomainStatus{ + "adding": CustomDomainStatusAdding, + "deleting": CustomDomainStatusDeleting, + "failed": CustomDomainStatusFailed, + "ready": CustomDomainStatusReady, + "retrievingvalidationtoken": CustomDomainStatusRetrievingValidationToken, + "unhealthy": CustomDomainStatusUnhealthy, + "validating": CustomDomainStatusValidating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDomainStatus(input) + return &out, nil +} + +type EnterpriseGradeCdnStatus string + +const ( + EnterpriseGradeCdnStatusDisabled EnterpriseGradeCdnStatus = "Disabled" + EnterpriseGradeCdnStatusDisabling EnterpriseGradeCdnStatus = "Disabling" + EnterpriseGradeCdnStatusEnabled EnterpriseGradeCdnStatus = "Enabled" + EnterpriseGradeCdnStatusEnabling EnterpriseGradeCdnStatus = "Enabling" +) + +func PossibleValuesForEnterpriseGradeCdnStatus() []string { + return []string{ + string(EnterpriseGradeCdnStatusDisabled), + string(EnterpriseGradeCdnStatusDisabling), + string(EnterpriseGradeCdnStatusEnabled), + string(EnterpriseGradeCdnStatusEnabling), + } +} + +func (s *EnterpriseGradeCdnStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnterpriseGradeCdnStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnterpriseGradeCdnStatus(input string) (*EnterpriseGradeCdnStatus, error) { + vals := map[string]EnterpriseGradeCdnStatus{ + "disabled": EnterpriseGradeCdnStatusDisabled, + "disabling": EnterpriseGradeCdnStatusDisabling, + "enabled": EnterpriseGradeCdnStatusEnabled, + "enabling": EnterpriseGradeCdnStatusEnabling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnterpriseGradeCdnStatus(input) + return &out, nil +} + +type StagingEnvironmentPolicy string + +const ( + StagingEnvironmentPolicyDisabled StagingEnvironmentPolicy = "Disabled" + StagingEnvironmentPolicyEnabled StagingEnvironmentPolicy = "Enabled" +) + +func PossibleValuesForStagingEnvironmentPolicy() []string { + return []string{ + string(StagingEnvironmentPolicyDisabled), + string(StagingEnvironmentPolicyEnabled), + } +} + +func (s *StagingEnvironmentPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStagingEnvironmentPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStagingEnvironmentPolicy(input string) (*StagingEnvironmentPolicy, error) { + vals := map[string]StagingEnvironmentPolicy{ + "disabled": StagingEnvironmentPolicyDisabled, + "enabled": StagingEnvironmentPolicyEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StagingEnvironmentPolicy(input) + return &out, nil +} + +type TriggerTypes string + +const ( + TriggerTypesHTTPTrigger TriggerTypes = "HttpTrigger" + TriggerTypesUnknown TriggerTypes = "Unknown" +) + +func PossibleValuesForTriggerTypes() []string { + return []string{ + string(TriggerTypesHTTPTrigger), + string(TriggerTypesUnknown), + } +} + +func (s *TriggerTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerTypes(input string) (*TriggerTypes, error) { + vals := map[string]TriggerTypes{ + "httptrigger": TriggerTypesHTTPTrigger, + "unknown": TriggerTypesUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerTypes(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_authprovider.go b/resource-manager/web/2023-12-01/staticsites/id_authprovider.go new file mode 100644 index 00000000000..750184e2aa7 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_authprovider.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AuthProviderId{}) +} + +var _ resourceids.ResourceId = &AuthProviderId{} + +// AuthProviderId is a struct representing the Resource ID for a Auth Provider +type AuthProviderId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + AuthProviderName string +} + +// NewAuthProviderID returns a new AuthProviderId struct +func NewAuthProviderID(subscriptionId string, resourceGroupName string, staticSiteName string, authProviderName string) AuthProviderId { + return AuthProviderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + AuthProviderName: authProviderName, + } +} + +// ParseAuthProviderID parses 'input' into a AuthProviderId +func ParseAuthProviderID(input string) (*AuthProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthProviderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthProviderIDInsensitively parses 'input' case-insensitively into a AuthProviderId +// note: this method should only be used for API response data and not user input +func ParseAuthProviderIDInsensitively(input string) (*AuthProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthProviderId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthProviderId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.AuthProviderName, ok = input.Parsed["authProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authProviderName", input) + } + + return nil +} + +// ValidateAuthProviderID checks that 'input' can be parsed as a Auth Provider ID +func ValidateAuthProviderID(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 := ParseAuthProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Auth Provider ID +func (id AuthProviderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/authProviders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.AuthProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Auth Provider ID +func (id AuthProviderId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticAuthProviders", "authProviders", "authProviders"), + resourceids.UserSpecifiedSegment("authProviderName", "authProviderValue"), + } +} + +// String returns a human-readable description of this Auth Provider ID +func (id AuthProviderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Auth Provider Name: %q", id.AuthProviderName), + } + return fmt.Sprintf("Auth Provider (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_authprovider_test.go b/resource-manager/web/2023-12-01/staticsites/id_authprovider_test.go new file mode 100644 index 00000000000..b7bde36221d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_authprovider_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &AuthProviderId{} + +func TestNewAuthProviderID(t *testing.T) { + id := NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "authProviderValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.AuthProviderName != "authProviderValue" { + t.Fatalf("Expected %q but got %q for Segment 'AuthProviderName'", id.AuthProviderName, "authProviderValue") + } +} + +func TestFormatAuthProviderID(t *testing.T) { + actual := NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "authProviderValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthProviderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthProviderId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + AuthProviderName: "authProviderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthProviderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + } +} + +func TestParseAuthProviderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthProviderId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + AuthProviderName: "authProviderValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs/aUtHpRoViDeRvAlUe", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + AuthProviderName: "aUtHpRoViDeRvAlUe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs/aUtHpRoViDeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthProviderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + } +} + +func TestSegmentsForAuthProviderId(t *testing.T) { + segments := AuthProviderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthProviderId 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/web/2023-12-01/staticsites/id_build.go b/resource-manager/web/2023-12-01/staticsites/id_build.go new file mode 100644 index 00000000000..1e21fb5cf2b --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_build.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildId{}) +} + +var _ resourceids.ResourceId = &BuildId{} + +// BuildId is a struct representing the Resource ID for a Build +type BuildId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string +} + +// NewBuildID returns a new BuildId struct +func NewBuildID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string) BuildId { + return BuildId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + } +} + +// ParseBuildID parses 'input' into a BuildId +func ParseBuildID(input string) (*BuildId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildIDInsensitively parses 'input' case-insensitively into a BuildId +// note: this method should only be used for API response data and not user input +func ParseBuildIDInsensitively(input string) (*BuildId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + return nil +} + +// ValidateBuildID checks that 'input' can be parsed as a Build ID +func ValidateBuildID(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 := ParseBuildID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build ID +func (id BuildId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build ID +func (id BuildId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildValue"), + } +} + +// String returns a human-readable description of this Build ID +func (id BuildId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + } + return fmt.Sprintf("Build (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_build_test.go b/resource-manager/web/2023-12-01/staticsites/id_build_test.go new file mode 100644 index 00000000000..cedc82f4268 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_build_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &BuildId{} + +func TestNewBuildID(t *testing.T) { + id := NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.BuildName != "buildValue" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildValue") + } +} + +func TestFormatBuildID(t *testing.T) { + actual := NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + } +} + +func TestParseBuildIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + BuildName: "bUiLdVaLuE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + } +} + +func TestSegmentsForBuildId(t *testing.T) { + segments := BuildId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildId 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/web/2023-12-01/staticsites/id_builddatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/id_builddatabaseconnection.go new file mode 100644 index 00000000000..0ed1b728e32 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_builddatabaseconnection.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildDatabaseConnectionId{}) +} + +var _ resourceids.ResourceId = &BuildDatabaseConnectionId{} + +// BuildDatabaseConnectionId is a struct representing the Resource ID for a Build Database Connection +type BuildDatabaseConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + DatabaseConnectionName string +} + +// NewBuildDatabaseConnectionID returns a new BuildDatabaseConnectionId struct +func NewBuildDatabaseConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, databaseConnectionName string) BuildDatabaseConnectionId { + return BuildDatabaseConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + DatabaseConnectionName: databaseConnectionName, + } +} + +// ParseBuildDatabaseConnectionID parses 'input' into a BuildDatabaseConnectionId +func ParseBuildDatabaseConnectionID(input string) (*BuildDatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildDatabaseConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildDatabaseConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildDatabaseConnectionIDInsensitively parses 'input' case-insensitively into a BuildDatabaseConnectionId +// note: this method should only be used for API response data and not user input +func ParseBuildDatabaseConnectionIDInsensitively(input string) (*BuildDatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildDatabaseConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildDatabaseConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildDatabaseConnectionId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.DatabaseConnectionName, ok = input.Parsed["databaseConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseConnectionName", input) + } + + return nil +} + +// ValidateBuildDatabaseConnectionID checks that 'input' can be parsed as a Build Database Connection ID +func ValidateBuildDatabaseConnectionID(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 := ParseBuildDatabaseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build Database Connection ID +func (id BuildDatabaseConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/databaseConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.DatabaseConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build Database Connection ID +func (id BuildDatabaseConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildValue"), + resourceids.StaticSegment("staticDatabaseConnections", "databaseConnections", "databaseConnections"), + resourceids.UserSpecifiedSegment("databaseConnectionName", "databaseConnectionValue"), + } +} + +// String returns a human-readable description of this Build Database Connection ID +func (id BuildDatabaseConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("Database Connection Name: %q", id.DatabaseConnectionName), + } + return fmt.Sprintf("Build Database Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_builddatabaseconnection_test.go b/resource-manager/web/2023-12-01/staticsites/id_builddatabaseconnection_test.go new file mode 100644 index 00000000000..1ff75e30e16 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_builddatabaseconnection_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &BuildDatabaseConnectionId{} + +func TestNewBuildDatabaseConnectionID(t *testing.T) { + id := NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "databaseConnectionValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.BuildName != "buildValue" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildValue") + } + + if id.DatabaseConnectionName != "databaseConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseConnectionName'", id.DatabaseConnectionName, "databaseConnectionValue") + } +} + +func TestFormatBuildDatabaseConnectionID(t *testing.T) { + actual := NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "databaseConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/databaseConnections/databaseConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildDatabaseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildDatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/databaseConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/databaseConnections/databaseConnectionValue", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + DatabaseConnectionName: "databaseConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/databaseConnections/databaseConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildDatabaseConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestParseBuildDatabaseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildDatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/databaseConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/dAtAbAsEcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/databaseConnections/databaseConnectionValue", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + DatabaseConnectionName: "databaseConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/databaseConnections/databaseConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNvAlUe", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + BuildName: "bUiLdVaLuE", + DatabaseConnectionName: "dAtAbAsEcOnNeCtIoNvAlUe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildDatabaseConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestSegmentsForBuildDatabaseConnectionId(t *testing.T) { + segments := BuildDatabaseConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildDatabaseConnectionId 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/web/2023-12-01/staticsites/id_buildlinkedbackend.go b/resource-manager/web/2023-12-01/staticsites/id_buildlinkedbackend.go new file mode 100644 index 00000000000..d6cf5a07976 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_buildlinkedbackend.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildLinkedBackendId{}) +} + +var _ resourceids.ResourceId = &BuildLinkedBackendId{} + +// BuildLinkedBackendId is a struct representing the Resource ID for a Build Linked Backend +type BuildLinkedBackendId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + LinkedBackendName string +} + +// NewBuildLinkedBackendID returns a new BuildLinkedBackendId struct +func NewBuildLinkedBackendID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, linkedBackendName string) BuildLinkedBackendId { + return BuildLinkedBackendId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + LinkedBackendName: linkedBackendName, + } +} + +// ParseBuildLinkedBackendID parses 'input' into a BuildLinkedBackendId +func ParseBuildLinkedBackendID(input string) (*BuildLinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildLinkedBackendId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildLinkedBackendId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildLinkedBackendIDInsensitively parses 'input' case-insensitively into a BuildLinkedBackendId +// note: this method should only be used for API response data and not user input +func ParseBuildLinkedBackendIDInsensitively(input string) (*BuildLinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildLinkedBackendId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildLinkedBackendId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildLinkedBackendId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.LinkedBackendName, ok = input.Parsed["linkedBackendName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedBackendName", input) + } + + return nil +} + +// ValidateBuildLinkedBackendID checks that 'input' can be parsed as a Build Linked Backend ID +func ValidateBuildLinkedBackendID(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 := ParseBuildLinkedBackendID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build Linked Backend ID +func (id BuildLinkedBackendId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/linkedBackends/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.LinkedBackendName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build Linked Backend ID +func (id BuildLinkedBackendId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildValue"), + resourceids.StaticSegment("staticLinkedBackends", "linkedBackends", "linkedBackends"), + resourceids.UserSpecifiedSegment("linkedBackendName", "linkedBackendValue"), + } +} + +// String returns a human-readable description of this Build Linked Backend ID +func (id BuildLinkedBackendId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("Linked Backend Name: %q", id.LinkedBackendName), + } + return fmt.Sprintf("Build Linked Backend (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_buildlinkedbackend_test.go b/resource-manager/web/2023-12-01/staticsites/id_buildlinkedbackend_test.go new file mode 100644 index 00000000000..a0f9798d33e --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_buildlinkedbackend_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &BuildLinkedBackendId{} + +func TestNewBuildLinkedBackendID(t *testing.T) { + id := NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "linkedBackendValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.BuildName != "buildValue" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildValue") + } + + if id.LinkedBackendName != "linkedBackendValue" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedBackendName'", id.LinkedBackendName, "linkedBackendValue") + } +} + +func TestFormatBuildLinkedBackendID(t *testing.T) { + actual := NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "linkedBackendValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/linkedBackends/linkedBackendValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildLinkedBackendID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildLinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/linkedBackends", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/linkedBackends/linkedBackendValue", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + LinkedBackendName: "linkedBackendValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/linkedBackends/linkedBackendValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildLinkedBackendID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestParseBuildLinkedBackendIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildLinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/linkedBackends", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/lInKeDbAcKeNdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/linkedBackends/linkedBackendValue", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + LinkedBackendName: "linkedBackendValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/linkedBackends/linkedBackendValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/lInKeDbAcKeNdS/lInKeDbAcKeNdVaLuE", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + BuildName: "bUiLdVaLuE", + LinkedBackendName: "lInKeDbAcKeNdVaLuE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/lInKeDbAcKeNdS/lInKeDbAcKeNdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildLinkedBackendIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestSegmentsForBuildLinkedBackendId(t *testing.T) { + segments := BuildLinkedBackendId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildLinkedBackendId 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/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp.go b/resource-manager/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp.go new file mode 100644 index 00000000000..3b8c90ea51f --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildUserProvidedFunctionAppId{}) +} + +var _ resourceids.ResourceId = &BuildUserProvidedFunctionAppId{} + +// BuildUserProvidedFunctionAppId is a struct representing the Resource ID for a Build User Provided Function App +type BuildUserProvidedFunctionAppId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + UserProvidedFunctionAppName string +} + +// NewBuildUserProvidedFunctionAppID returns a new BuildUserProvidedFunctionAppId struct +func NewBuildUserProvidedFunctionAppID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, userProvidedFunctionAppName string) BuildUserProvidedFunctionAppId { + return BuildUserProvidedFunctionAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + UserProvidedFunctionAppName: userProvidedFunctionAppName, + } +} + +// ParseBuildUserProvidedFunctionAppID parses 'input' into a BuildUserProvidedFunctionAppId +func ParseBuildUserProvidedFunctionAppID(input string) (*BuildUserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildUserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildUserProvidedFunctionAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildUserProvidedFunctionAppIDInsensitively parses 'input' case-insensitively into a BuildUserProvidedFunctionAppId +// note: this method should only be used for API response data and not user input +func ParseBuildUserProvidedFunctionAppIDInsensitively(input string) (*BuildUserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildUserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildUserProvidedFunctionAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildUserProvidedFunctionAppId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.UserProvidedFunctionAppName, ok = input.Parsed["userProvidedFunctionAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userProvidedFunctionAppName", input) + } + + return nil +} + +// ValidateBuildUserProvidedFunctionAppID checks that 'input' can be parsed as a Build User Provided Function App ID +func ValidateBuildUserProvidedFunctionAppID(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 := ParseBuildUserProvidedFunctionAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/userProvidedFunctionApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.UserProvidedFunctionAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildValue"), + resourceids.StaticSegment("staticUserProvidedFunctionApps", "userProvidedFunctionApps", "userProvidedFunctionApps"), + resourceids.UserSpecifiedSegment("userProvidedFunctionAppName", "userProvidedFunctionAppValue"), + } +} + +// String returns a human-readable description of this Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("User Provided Function App Name: %q", id.UserProvidedFunctionAppName), + } + return fmt.Sprintf("Build User Provided Function App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp_test.go b/resource-manager/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp_test.go new file mode 100644 index 00000000000..ac72bb42d05 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_builduserprovidedfunctionapp_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &BuildUserProvidedFunctionAppId{} + +func TestNewBuildUserProvidedFunctionAppID(t *testing.T) { + id := NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "userProvidedFunctionAppValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.BuildName != "buildValue" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildValue") + } + + if id.UserProvidedFunctionAppName != "userProvidedFunctionAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'UserProvidedFunctionAppName'", id.UserProvidedFunctionAppName, "userProvidedFunctionAppValue") + } +} + +func TestFormatBuildUserProvidedFunctionAppID(t *testing.T) { + actual := NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "buildValue", "userProvidedFunctionAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/userProvidedFunctionApps/userProvidedFunctionAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildUserProvidedFunctionAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildUserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/userProvidedFunctionApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/userProvidedFunctionApps/userProvidedFunctionAppValue", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + UserProvidedFunctionAppName: "userProvidedFunctionAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/userProvidedFunctionApps/userProvidedFunctionAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildUserProvidedFunctionAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestParseBuildUserProvidedFunctionAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildUserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/userProvidedFunctionApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/uSeRpRoViDeDfUnCtIoNaPpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/userProvidedFunctionApps/userProvidedFunctionAppValue", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + BuildName: "buildValue", + UserProvidedFunctionAppName: "userProvidedFunctionAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/builds/buildValue/userProvidedFunctionApps/userProvidedFunctionAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpVaLuE", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + BuildName: "bUiLdVaLuE", + UserProvidedFunctionAppName: "uSeRpRoViDeDfUnCtIoNaPpVaLuE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/bUiLdS/bUiLdVaLuE/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildUserProvidedFunctionAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestSegmentsForBuildUserProvidedFunctionAppId(t *testing.T) { + segments := BuildUserProvidedFunctionAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildUserProvidedFunctionAppId 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/web/2023-12-01/staticsites/id_customdomain.go b/resource-manager/web/2023-12-01/staticsites/id_customdomain.go new file mode 100644 index 00000000000..8b71f5f6a29 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_customdomain.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CustomDomainId{}) +} + +var _ resourceids.ResourceId = &CustomDomainId{} + +// CustomDomainId is a struct representing the Resource ID for a Custom Domain +type CustomDomainId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + CustomDomainName string +} + +// NewCustomDomainID returns a new CustomDomainId struct +func NewCustomDomainID(subscriptionId string, resourceGroupName string, staticSiteName string, customDomainName string) CustomDomainId { + return CustomDomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + CustomDomainName: customDomainName, + } +} + +// ParseCustomDomainID parses 'input' into a CustomDomainId +func ParseCustomDomainID(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomDomainIDInsensitively parses 'input' case-insensitively into a CustomDomainId +// note: this method should only be used for API response data and not user input +func ParseCustomDomainIDInsensitively(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomDomainId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.CustomDomainName, ok = input.Parsed["customDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customDomainName", input) + } + + return nil +} + +// ValidateCustomDomainID checks that 'input' can be parsed as a Custom Domain ID +func ValidateCustomDomainID(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 := ParseCustomDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Domain ID +func (id CustomDomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/customDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.CustomDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Domain ID +func (id CustomDomainId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticCustomDomains", "customDomains", "customDomains"), + resourceids.UserSpecifiedSegment("customDomainName", "customDomainValue"), + } +} + +// String returns a human-readable description of this Custom Domain ID +func (id CustomDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Custom Domain Name: %q", id.CustomDomainName), + } + return fmt.Sprintf("Custom Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_customdomain_test.go b/resource-manager/web/2023-12-01/staticsites/id_customdomain_test.go new file mode 100644 index 00000000000..8dc64d266a7 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_customdomain_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &CustomDomainId{} + +func TestNewCustomDomainID(t *testing.T) { + id := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "customDomainValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.CustomDomainName != "customDomainValue" { + t.Fatalf("Expected %q but got %q for Segment 'CustomDomainName'", id.CustomDomainName, "customDomainValue") + } +} + +func TestFormatCustomDomainID(t *testing.T) { + actual := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "customDomainValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/customDomains/customDomainValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/customDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/customDomains/customDomainValue", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + CustomDomainName: "customDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/customDomains/customDomainValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestParseCustomDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/customDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/cUsToMdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/customDomains/customDomainValue", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + CustomDomainName: "customDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/customDomains/customDomainValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/cUsToMdOmAiNs/cUsToMdOmAiNvAlUe", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + CustomDomainName: "cUsToMdOmAiNvAlUe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/cUsToMdOmAiNs/cUsToMdOmAiNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestSegmentsForCustomDomainId(t *testing.T) { + segments := CustomDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomDomainId 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/web/2023-12-01/staticsites/id_databaseconnection.go b/resource-manager/web/2023-12-01/staticsites/id_databaseconnection.go new file mode 100644 index 00000000000..9369f53f8e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_databaseconnection.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DatabaseConnectionId{}) +} + +var _ resourceids.ResourceId = &DatabaseConnectionId{} + +// DatabaseConnectionId is a struct representing the Resource ID for a Database Connection +type DatabaseConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + DatabaseConnectionName string +} + +// NewDatabaseConnectionID returns a new DatabaseConnectionId struct +func NewDatabaseConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, databaseConnectionName string) DatabaseConnectionId { + return DatabaseConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + DatabaseConnectionName: databaseConnectionName, + } +} + +// ParseDatabaseConnectionID parses 'input' into a DatabaseConnectionId +func ParseDatabaseConnectionID(input string) (*DatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseConnectionIDInsensitively parses 'input' case-insensitively into a DatabaseConnectionId +// note: this method should only be used for API response data and not user input +func ParseDatabaseConnectionIDInsensitively(input string) (*DatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseConnectionId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.DatabaseConnectionName, ok = input.Parsed["databaseConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseConnectionName", input) + } + + return nil +} + +// ValidateDatabaseConnectionID checks that 'input' can be parsed as a Database Connection ID +func ValidateDatabaseConnectionID(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 := ParseDatabaseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Connection ID +func (id DatabaseConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/databaseConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.DatabaseConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Connection ID +func (id DatabaseConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticDatabaseConnections", "databaseConnections", "databaseConnections"), + resourceids.UserSpecifiedSegment("databaseConnectionName", "databaseConnectionValue"), + } +} + +// String returns a human-readable description of this Database Connection ID +func (id DatabaseConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Database Connection Name: %q", id.DatabaseConnectionName), + } + return fmt.Sprintf("Database Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_databaseconnection_test.go b/resource-manager/web/2023-12-01/staticsites/id_databaseconnection_test.go new file mode 100644 index 00000000000..e878da4356a --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_databaseconnection_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &DatabaseConnectionId{} + +func TestNewDatabaseConnectionID(t *testing.T) { + id := NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "databaseConnectionValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.DatabaseConnectionName != "databaseConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseConnectionName'", id.DatabaseConnectionName, "databaseConnectionValue") + } +} + +func TestFormatDatabaseConnectionID(t *testing.T) { + actual := NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "databaseConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/databaseConnections/databaseConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/databaseConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/databaseConnections/databaseConnectionValue", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + DatabaseConnectionName: "databaseConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/databaseConnections/databaseConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestParseDatabaseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/databaseConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/dAtAbAsEcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/databaseConnections/databaseConnectionValue", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + DatabaseConnectionName: "databaseConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/databaseConnections/databaseConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNvAlUe", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + DatabaseConnectionName: "dAtAbAsEcOnNeCtIoNvAlUe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestSegmentsForDatabaseConnectionId(t *testing.T) { + segments := DatabaseConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseConnectionId 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/web/2023-12-01/staticsites/id_linkedbackend.go b/resource-manager/web/2023-12-01/staticsites/id_linkedbackend.go new file mode 100644 index 00000000000..718f2b0e7f1 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_linkedbackend.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LinkedBackendId{}) +} + +var _ resourceids.ResourceId = &LinkedBackendId{} + +// LinkedBackendId is a struct representing the Resource ID for a Linked Backend +type LinkedBackendId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + LinkedBackendName string +} + +// NewLinkedBackendID returns a new LinkedBackendId struct +func NewLinkedBackendID(subscriptionId string, resourceGroupName string, staticSiteName string, linkedBackendName string) LinkedBackendId { + return LinkedBackendId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + LinkedBackendName: linkedBackendName, + } +} + +// ParseLinkedBackendID parses 'input' into a LinkedBackendId +func ParseLinkedBackendID(input string) (*LinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedBackendId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedBackendId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLinkedBackendIDInsensitively parses 'input' case-insensitively into a LinkedBackendId +// note: this method should only be used for API response data and not user input +func ParseLinkedBackendIDInsensitively(input string) (*LinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedBackendId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedBackendId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LinkedBackendId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.LinkedBackendName, ok = input.Parsed["linkedBackendName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedBackendName", input) + } + + return nil +} + +// ValidateLinkedBackendID checks that 'input' can be parsed as a Linked Backend ID +func ValidateLinkedBackendID(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 := ParseLinkedBackendID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Linked Backend ID +func (id LinkedBackendId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/linkedBackends/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.LinkedBackendName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Linked Backend ID +func (id LinkedBackendId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticLinkedBackends", "linkedBackends", "linkedBackends"), + resourceids.UserSpecifiedSegment("linkedBackendName", "linkedBackendValue"), + } +} + +// String returns a human-readable description of this Linked Backend ID +func (id LinkedBackendId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Linked Backend Name: %q", id.LinkedBackendName), + } + return fmt.Sprintf("Linked Backend (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_linkedbackend_test.go b/resource-manager/web/2023-12-01/staticsites/id_linkedbackend_test.go new file mode 100644 index 00000000000..5e5e4260093 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_linkedbackend_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &LinkedBackendId{} + +func TestNewLinkedBackendID(t *testing.T) { + id := NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "linkedBackendValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.LinkedBackendName != "linkedBackendValue" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedBackendName'", id.LinkedBackendName, "linkedBackendValue") + } +} + +func TestFormatLinkedBackendID(t *testing.T) { + actual := NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "linkedBackendValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/linkedBackends/linkedBackendValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLinkedBackendID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/linkedBackends", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/linkedBackends/linkedBackendValue", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + LinkedBackendName: "linkedBackendValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/linkedBackends/linkedBackendValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedBackendID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestParseLinkedBackendIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedBackendId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/linkedBackends", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/lInKeDbAcKeNdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/linkedBackends/linkedBackendValue", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + LinkedBackendName: "linkedBackendValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/linkedBackends/linkedBackendValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/lInKeDbAcKeNdS/lInKeDbAcKeNdVaLuE", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + LinkedBackendName: "lInKeDbAcKeNdVaLuE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/lInKeDbAcKeNdS/lInKeDbAcKeNdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedBackendIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestSegmentsForLinkedBackendId(t *testing.T) { + segments := LinkedBackendId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LinkedBackendId 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/web/2023-12-01/staticsites/id_providerlocation.go b/resource-manager/web/2023-12-01/staticsites/id_providerlocation.go new file mode 100644 index 00000000000..ee9a3aa0549 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_providerlocation.go @@ -0,0 +1,121 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_providerlocation_test.go b/resource-manager/web/2023-12-01/staticsites/id_providerlocation_test.go new file mode 100644 index 00000000000..ed865e83b60 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_staticsite.go b/resource-manager/web/2023-12-01/staticsites/id_staticsite.go new file mode 100644 index 00000000000..1c7bb88ff3c --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_staticsite.go @@ -0,0 +1,130 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StaticSiteId{}) +} + +var _ resourceids.ResourceId = &StaticSiteId{} + +// StaticSiteId is a struct representing the Resource ID for a Static Site +type StaticSiteId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string +} + +// NewStaticSiteID returns a new StaticSiteId struct +func NewStaticSiteID(subscriptionId string, resourceGroupName string, staticSiteName string) StaticSiteId { + return StaticSiteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + } +} + +// ParseStaticSiteID parses 'input' into a StaticSiteId +func ParseStaticSiteID(input string) (*StaticSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticSiteIDInsensitively parses 'input' case-insensitively into a StaticSiteId +// note: this method should only be used for API response data and not user input +func ParseStaticSiteIDInsensitively(input string) (*StaticSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSiteId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticSiteId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + return nil +} + +// ValidateStaticSiteID checks that 'input' can be parsed as a Static Site ID +func ValidateStaticSiteID(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 := ParseStaticSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Site ID +func (id StaticSiteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Site ID +func (id StaticSiteId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + } +} + +// String returns a human-readable description of this Static Site ID +func (id StaticSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + } + return fmt.Sprintf("Static Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_staticsite_test.go b/resource-manager/web/2023-12-01/staticsites/id_staticsite_test.go new file mode 100644 index 00000000000..9044ace34ba --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_staticsite_test.go @@ -0,0 +1,282 @@ +package staticsites + +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 = &StaticSiteId{} + +func TestNewStaticSiteID(t *testing.T) { + id := NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } +} + +func TestFormatStaticSiteID(t *testing.T) { + actual := NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSiteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + } +} + +func TestParseStaticSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSiteId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + } +} + +func TestSegmentsForStaticSiteId(t *testing.T) { + segments := StaticSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticSiteId 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/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection.go b/resource-manager/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection.go new file mode 100644 index 00000000000..34f63677af6 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StaticSitePrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &StaticSitePrivateEndpointConnectionId{} + +// StaticSitePrivateEndpointConnectionId is a struct representing the Resource ID for a Static Site Private Endpoint Connection +type StaticSitePrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + PrivateEndpointConnectionName string +} + +// NewStaticSitePrivateEndpointConnectionID returns a new StaticSitePrivateEndpointConnectionId struct +func NewStaticSitePrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, privateEndpointConnectionName string) StaticSitePrivateEndpointConnectionId { + return StaticSitePrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseStaticSitePrivateEndpointConnectionID parses 'input' into a StaticSitePrivateEndpointConnectionId +func ParseStaticSitePrivateEndpointConnectionID(input string) (*StaticSitePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSitePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSitePrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticSitePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a StaticSitePrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseStaticSitePrivateEndpointConnectionIDInsensitively(input string) (*StaticSitePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSitePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSitePrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticSitePrivateEndpointConnectionId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateStaticSitePrivateEndpointConnectionID checks that 'input' can be parsed as a Static Site Private Endpoint Connection ID +func ValidateStaticSitePrivateEndpointConnectionID(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 := ParseStaticSitePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Static Site Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection_test.go b/resource-manager/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection_test.go new file mode 100644 index 00000000000..1b2edd0aa59 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_staticsiteprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &StaticSitePrivateEndpointConnectionId{} + +func TestNewStaticSitePrivateEndpointConnectionID(t *testing.T) { + id := NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatStaticSitePrivateEndpointConnectionID(t *testing.T) { + actual := NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticSitePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSitePrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSitePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseStaticSitePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSitePrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSitePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForStaticSitePrivateEndpointConnectionId(t *testing.T) { + segments := StaticSitePrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticSitePrivateEndpointConnectionId 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/web/2023-12-01/staticsites/id_user.go b/resource-manager/web/2023-12-01/staticsites/id_user.go new file mode 100644 index 00000000000..a53ca4c5a29 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_user.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UserId{}) +} + +var _ resourceids.ResourceId = &UserId{} + +// UserId is a struct representing the Resource ID for a User +type UserId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + AuthProviderName string + UserName string +} + +// NewUserID returns a new UserId struct +func NewUserID(subscriptionId string, resourceGroupName string, staticSiteName string, authProviderName string, userName string) UserId { + return UserId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + AuthProviderName: authProviderName, + UserName: userName, + } +} + +// ParseUserID parses 'input' into a UserId +func ParseUserID(input string) (*UserId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserIDInsensitively parses 'input' case-insensitively into a UserId +// note: this method should only be used for API response data and not user input +func ParseUserIDInsensitively(input string) (*UserId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.AuthProviderName, ok = input.Parsed["authProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authProviderName", input) + } + + if id.UserName, ok = input.Parsed["userName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userName", input) + } + + return nil +} + +// ValidateUserID checks that 'input' can be parsed as a User ID +func ValidateUserID(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 := ParseUserID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User ID +func (id UserId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/authProviders/%s/users/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.AuthProviderName, id.UserName) +} + +// Segments returns a slice of Resource ID Segments which comprise this User ID +func (id UserId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticAuthProviders", "authProviders", "authProviders"), + resourceids.UserSpecifiedSegment("authProviderName", "authProviderValue"), + resourceids.StaticSegment("staticUsers", "users", "users"), + resourceids.UserSpecifiedSegment("userName", "userValue"), + } +} + +// String returns a human-readable description of this User ID +func (id UserId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Auth Provider Name: %q", id.AuthProviderName), + fmt.Sprintf("User Name: %q", id.UserName), + } + return fmt.Sprintf("User (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_user_test.go b/resource-manager/web/2023-12-01/staticsites/id_user_test.go new file mode 100644 index 00000000000..7dee230032b --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_user_test.go @@ -0,0 +1,372 @@ +package staticsites + +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 = &UserId{} + +func TestNewUserID(t *testing.T) { + id := NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "authProviderValue", "userValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.AuthProviderName != "authProviderValue" { + t.Fatalf("Expected %q but got %q for Segment 'AuthProviderName'", id.AuthProviderName, "authProviderValue") + } + + if id.UserName != "userValue" { + t.Fatalf("Expected %q but got %q for Segment 'UserName'", id.UserName, "userValue") + } +} + +func TestFormatUserID(t *testing.T) { + actual := NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "authProviderValue", "userValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/users/userValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/users", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/users/userValue", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + AuthProviderName: "authProviderValue", + UserName: "userValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/users/userValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + if actual.UserName != v.Expected.UserName { + t.Fatalf("Expected %q but got %q for UserName", v.Expected.UserName, actual.UserName) + } + + } +} + +func TestParseUserIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs/aUtHpRoViDeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/users", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs/aUtHpRoViDeRvAlUe/uSeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/users/userValue", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + AuthProviderName: "authProviderValue", + UserName: "userValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/authProviders/authProviderValue/users/userValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs/aUtHpRoViDeRvAlUe/uSeRs/uSeRvAlUe", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + AuthProviderName: "aUtHpRoViDeRvAlUe", + UserName: "uSeRvAlUe", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/aUtHpRoViDeRs/aUtHpRoViDeRvAlUe/uSeRs/uSeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + if actual.UserName != v.Expected.UserName { + t.Fatalf("Expected %q but got %q for UserName", v.Expected.UserName, actual.UserName) + } + + } +} + +func TestSegmentsForUserId(t *testing.T) { + segments := UserId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserId 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/web/2023-12-01/staticsites/id_userprovidedfunctionapp.go b/resource-manager/web/2023-12-01/staticsites/id_userprovidedfunctionapp.go new file mode 100644 index 00000000000..fb801e139a9 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_userprovidedfunctionapp.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UserProvidedFunctionAppId{}) +} + +var _ resourceids.ResourceId = &UserProvidedFunctionAppId{} + +// UserProvidedFunctionAppId is a struct representing the Resource ID for a User Provided Function App +type UserProvidedFunctionAppId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + UserProvidedFunctionAppName string +} + +// NewUserProvidedFunctionAppID returns a new UserProvidedFunctionAppId struct +func NewUserProvidedFunctionAppID(subscriptionId string, resourceGroupName string, staticSiteName string, userProvidedFunctionAppName string) UserProvidedFunctionAppId { + return UserProvidedFunctionAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + UserProvidedFunctionAppName: userProvidedFunctionAppName, + } +} + +// ParseUserProvidedFunctionAppID parses 'input' into a UserProvidedFunctionAppId +func ParseUserProvidedFunctionAppID(input string) (*UserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserProvidedFunctionAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserProvidedFunctionAppIDInsensitively parses 'input' case-insensitively into a UserProvidedFunctionAppId +// note: this method should only be used for API response data and not user input +func ParseUserProvidedFunctionAppIDInsensitively(input string) (*UserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserProvidedFunctionAppId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserProvidedFunctionAppId) 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.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.UserProvidedFunctionAppName, ok = input.Parsed["userProvidedFunctionAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userProvidedFunctionAppName", input) + } + + return nil +} + +// ValidateUserProvidedFunctionAppID checks that 'input' can be parsed as a User Provided Function App ID +func ValidateUserProvidedFunctionAppID(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 := ParseUserProvidedFunctionAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User Provided Function App ID +func (id UserProvidedFunctionAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/userProvidedFunctionApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.UserProvidedFunctionAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this User Provided Function App ID +func (id UserProvidedFunctionAppId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteValue"), + resourceids.StaticSegment("staticUserProvidedFunctionApps", "userProvidedFunctionApps", "userProvidedFunctionApps"), + resourceids.UserSpecifiedSegment("userProvidedFunctionAppName", "userProvidedFunctionAppValue"), + } +} + +// String returns a human-readable description of this User Provided Function App ID +func (id UserProvidedFunctionAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("User Provided Function App Name: %q", id.UserProvidedFunctionAppName), + } + return fmt.Sprintf("User Provided Function App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/staticsites/id_userprovidedfunctionapp_test.go b/resource-manager/web/2023-12-01/staticsites/id_userprovidedfunctionapp_test.go new file mode 100644 index 00000000000..9120ae65fcf --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/id_userprovidedfunctionapp_test.go @@ -0,0 +1,327 @@ +package staticsites + +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 = &UserProvidedFunctionAppId{} + +func TestNewUserProvidedFunctionAppID(t *testing.T) { + id := NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "userProvidedFunctionAppValue") + + 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.StaticSiteName != "staticSiteValue" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteValue") + } + + if id.UserProvidedFunctionAppName != "userProvidedFunctionAppValue" { + t.Fatalf("Expected %q but got %q for Segment 'UserProvidedFunctionAppName'", id.UserProvidedFunctionAppName, "userProvidedFunctionAppValue") + } +} + +func TestFormatUserProvidedFunctionAppID(t *testing.T) { + actual := NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteValue", "userProvidedFunctionAppValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/userProvidedFunctionApps/userProvidedFunctionAppValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserProvidedFunctionAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/userProvidedFunctionApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/userProvidedFunctionApps/userProvidedFunctionAppValue", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + UserProvidedFunctionAppName: "userProvidedFunctionAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/userProvidedFunctionApps/userProvidedFunctionAppValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserProvidedFunctionAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestParseUserProvidedFunctionAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserProvidedFunctionAppId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/userProvidedFunctionApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/uSeRpRoViDeDfUnCtIoNaPpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/userProvidedFunctionApps/userProvidedFunctionAppValue", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteValue", + UserProvidedFunctionAppName: "userProvidedFunctionAppValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteValue/userProvidedFunctionApps/userProvidedFunctionAppValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpVaLuE", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEvAlUe", + UserProvidedFunctionAppName: "uSeRpRoViDeDfUnCtIoNaPpVaLuE", + }, + }, + { + // 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.wEb/sTaTiCsItEs/sTaTiCsItEvAlUe/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserProvidedFunctionAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestSegmentsForUserProvidedFunctionAppId(t *testing.T) { + segments := UserProvidedFunctionAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserProvidedFunctionAppId 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/web/2023-12-01/staticsites/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2023-12-01/staticsites/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..b07e7684411 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package staticsites + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatebasicauth.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatebasicauth.go new file mode 100644 index 00000000000..34051d7923f --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatebasicauth.go @@ -0,0 +1,59 @@ +package staticsites + +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 CreateOrUpdateBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// CreateOrUpdateBasicAuth ... +func (c StaticSitesClient) CreateOrUpdateBasicAuth(ctx context.Context, id StaticSiteId, input StaticSiteBasicAuthPropertiesARMResource) (result CreateOrUpdateBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicAuth/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteBasicAuthPropertiesARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatebuilddatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatebuilddatabaseconnection.go new file mode 100644 index 00000000000..9fa486417cb --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatebuilddatabaseconnection.go @@ -0,0 +1,58 @@ +package staticsites + +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 CreateOrUpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateBuildDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatedatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatedatabaseconnection.go new file mode 100644 index 00000000000..718dd346c56 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatedatabaseconnection.go @@ -0,0 +1,58 @@ +package staticsites + +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 CreateOrUpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsite.go new file mode 100644 index 00000000000..15bec306823 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsite.go @@ -0,0 +1,75 @@ +package staticsites + +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 CreateOrUpdateStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// CreateOrUpdateStaticSite ... +func (c StaticSitesClient) CreateOrUpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) (result CreateOrUpdateStaticSiteOperationResponse, 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 +} + +// CreateOrUpdateStaticSiteThenPoll performs CreateOrUpdateStaticSite then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) error { + result, err := c.CreateOrUpdateStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsiteappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsiteappsettings.go new file mode 100644 index 00000000000..19e3b9c2d9d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsiteappsettings.go @@ -0,0 +1,59 @@ +package staticsites + +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 CreateOrUpdateStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildappsettings.go new file mode 100644 index 00000000000..bcded5df29e --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildappsettings.go @@ -0,0 +1,59 @@ +package staticsites + +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 CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..4a99a9e6b1d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go @@ -0,0 +1,59 @@ +package staticsites + +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 CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitecustomdomain.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitecustomdomain.go new file mode 100644 index 00000000000..77c06560af1 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitecustomdomain.go @@ -0,0 +1,75 @@ +package staticsites + +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 CreateOrUpdateStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteCustomDomainOverviewARMResource +} + +// CreateOrUpdateStaticSiteCustomDomain ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomain(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result CreateOrUpdateStaticSiteCustomDomainOperationResponse, 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 +} + +// CreateOrUpdateStaticSiteCustomDomainThenPoll performs CreateOrUpdateStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.CreateOrUpdateStaticSiteCustomDomain(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go new file mode 100644 index 00000000000..b4181e79c23 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go @@ -0,0 +1,59 @@ +package staticsites + +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 CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createuserrolesinvitationlink.go b/resource-manager/web/2023-12-01/staticsites/method_createuserrolesinvitationlink.go new file mode 100644 index 00000000000..2c3ce3709a2 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createuserrolesinvitationlink.go @@ -0,0 +1,59 @@ +package staticsites + +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 CreateUserRolesInvitationLinkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserInvitationResponseResource +} + +// CreateUserRolesInvitationLink ... +func (c StaticSitesClient) CreateUserRolesInvitationLink(ctx context.Context, id StaticSiteId, input StaticSiteUserInvitationRequestResource) (result CreateUserRolesInvitationLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/createUserInvitation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteUserInvitationResponseResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsite.go new file mode 100644 index 00000000000..6dddfe32ead --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateZipDeploymentForStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSite ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", 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 +} + +// CreateZipDeploymentForStaticSiteThenPoll performs CreateZipDeploymentForStaticSite then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsitebuild.go b/resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsitebuild.go new file mode 100644 index 00000000000..4b1ac38f9e9 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_createzipdeploymentforstaticsitebuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 CreateZipDeploymentForStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSiteBuild ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuild(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", 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 +} + +// CreateZipDeploymentForStaticSiteBuildThenPoll performs CreateZipDeploymentForStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuildThenPoll(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSiteBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_deletebuilddatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_deletebuilddatabaseconnection.go new file mode 100644 index 00000000000..5a80028d137 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_deletebuilddatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +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 DeleteBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBuildDatabaseConnection ... +func (c StaticSitesClient) DeleteBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result DeleteBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_deletedatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_deletedatabaseconnection.go new file mode 100644 index 00000000000..7f0d6cc94aa --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_deletedatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +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 DeleteDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDatabaseConnection ... +func (c StaticSitesClient) DeleteDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result DeleteDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_deleteprivateendpointconnection.go b/resource-manager/web/2023-12-01/staticsites/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..d632f3899b4 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package staticsites + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c StaticSitesClient) DeletePrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_deletestaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsite.go new file mode 100644 index 00000000000..78d3bd0abf4 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +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 DeleteStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSite ... +func (c StaticSitesClient) DeleteStaticSite(ctx context.Context, id StaticSiteId) (result DeleteStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + 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 +} + +// DeleteStaticSiteThenPoll performs DeleteStaticSite then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DeleteStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_deletestaticsitebuild.go b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsitebuild.go new file mode 100644 index 00000000000..a3fdbf84900 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsitebuild.go @@ -0,0 +1,71 @@ +package staticsites + +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 DeleteStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteBuild ... +func (c StaticSitesClient) DeleteStaticSiteBuild(ctx context.Context, id BuildId) (result DeleteStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeleteStaticSiteBuildThenPoll performs DeleteStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteBuildThenPoll(ctx context.Context, id BuildId) error { + result, err := c.DeleteStaticSiteBuild(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_deletestaticsitecustomdomain.go b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsitecustomdomain.go new file mode 100644 index 00000000000..471bf713f5d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsitecustomdomain.go @@ -0,0 +1,70 @@ +package staticsites + +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 DeleteStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteCustomDomain ... +func (c StaticSitesClient) DeleteStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result DeleteStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + 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 +} + +// DeleteStaticSiteCustomDomainThenPoll performs DeleteStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId) error { + result, err := c.DeleteStaticSiteCustomDomain(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_deletestaticsiteuser.go b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsiteuser.go new file mode 100644 index 00000000000..e4799c87ddb --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_deletestaticsiteuser.go @@ -0,0 +1,46 @@ +package staticsites + +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 DeleteStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteUser ... +func (c StaticSitesClient) DeleteStaticSiteUser(ctx context.Context, id UserId) (result DeleteStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_detachstaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_detachstaticsite.go new file mode 100644 index 00000000000..00fa4ac9dd0 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_detachstaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +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 DetachStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DetachStaticSite ... +func (c StaticSitesClient) DetachStaticSite(ctx context.Context, id StaticSiteId) (result DetachStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/detach", 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 +} + +// DetachStaticSiteThenPoll performs DetachStaticSite then polls until it's completed +func (c StaticSitesClient) DetachStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DetachStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DetachStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DetachStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go new file mode 100644 index 00000000000..b9a68ba826d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go @@ -0,0 +1,47 @@ +package staticsites + +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 DetachUserProvidedFunctionAppFromStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSite ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go b/resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go new file mode 100644 index 00000000000..305f4802b1d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go @@ -0,0 +1,47 @@ +package staticsites + +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 DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSiteBuild ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getbasicauth.go b/resource-manager/web/2023-12-01/staticsites/method_getbasicauth.go new file mode 100644 index 00000000000..93aca3f09be --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getbasicauth.go @@ -0,0 +1,55 @@ +package staticsites + +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 GetBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// GetBasicAuth ... +func (c StaticSitesClient) GetBasicAuth(ctx context.Context, id StaticSiteId) (result GetBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicAuth/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 + } + + var model StaticSiteBasicAuthPropertiesARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnection.go new file mode 100644 index 00000000000..64d51db24b6 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnection.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnection ... +func (c StaticSitesClient) GetBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnections.go b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnections.go new file mode 100644 index 00000000000..044bfd57fbc --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnections.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetBuildDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +// GetBuildDatabaseConnections ... +func (c StaticSitesClient) GetBuildDatabaseConnections(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/databaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnections(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 = GetBuildDatabaseConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..a32b0d4ac41 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetBuildDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsWithDetailsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +// GetBuildDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetails(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/showDatabaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnectionsWithDetails(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 = GetBuildDatabaseConnectionsWithDetailsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..39323af4c15 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go @@ -0,0 +1,55 @@ +package staticsites + +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 GetBuildDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionWithDetails(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnection.go new file mode 100644 index 00000000000..118dabea250 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnection.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnection ... +func (c StaticSitesClient) GetDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnections.go b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnections.go new file mode 100644 index 00000000000..3f413b9475b --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnections.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +// GetDatabaseConnections ... +func (c StaticSitesClient) GetDatabaseConnections(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/databaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsCompleteResult, error) { + return c.GetDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnections(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 = GetDatabaseConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionswithdetails.go b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..4c1fb498cae --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionswithdetails.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsWithDetailsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +// GetDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionsWithDetails(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/showDatabaseConnections", 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 *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnectionsWithDetails(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 = GetDatabaseConnectionsWithDetailsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionwithdetails.go b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..7ff319615bd --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getdatabaseconnectionwithdetails.go @@ -0,0 +1,55 @@ +package staticsites + +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 GetDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionWithDetails(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackend.go b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackend.go new file mode 100644 index 00000000000..b572c2a2856 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackend.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetLinkedBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackend ... +func (c StaticSitesClient) GetLinkedBackend(ctx context.Context, id LinkedBackendId) (result GetLinkedBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteLinkedBackendARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendforbuild.go b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendforbuild.go new file mode 100644 index 00000000000..9bc02ed8de7 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendforbuild.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetLinkedBackendForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackendForBuild ... +func (c StaticSitesClient) GetLinkedBackendForBuild(ctx context.Context, id BuildLinkedBackendId) (result GetLinkedBackendForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteLinkedBackendARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackends.go b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackends.go new file mode 100644 index 00000000000..a9117d962ae --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackends.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetLinkedBackendsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackends ... +func (c StaticSitesClient) GetLinkedBackends(ctx context.Context, id StaticSiteId) (result GetLinkedBackendsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedBackends", 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 *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsComplete(ctx context.Context, id StaticSiteId) (GetLinkedBackendsCompleteResult, error) { + return c.GetLinkedBackendsCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackends(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 = GetLinkedBackendsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendsforbuild.go b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendsforbuild.go new file mode 100644 index 00000000000..a9c90637d14 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getlinkedbackendsforbuild.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetLinkedBackendsForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsForBuildCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackendsForBuild ... +func (c StaticSitesClient) GetLinkedBackendsForBuild(ctx context.Context, id BuildId) (result GetLinkedBackendsForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/linkedBackends", 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 *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsForBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsForBuildComplete(ctx context.Context, id BuildId) (GetLinkedBackendsForBuildCompleteResult, error) { + return c.GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsForBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsForBuildCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackendsForBuild(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 = GetLinkedBackendsForBuildCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnection.go b/resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..7342343fa2a --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnection.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c StaticSitesClient) GetPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnectionlist.go b/resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..b5a681796cd --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getprivateendpointconnectionlist.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionList ... +func (c StaticSitesClient) GetPrivateEndpointConnectionList(ctx context.Context, id StaticSiteId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c StaticSitesClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id StaticSiteId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(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 = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getprivatelinkresources.go b/resource-manager/web/2023-12-01/staticsites/method_getprivatelinkresources.go new file mode 100644 index 00000000000..d9590943395 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getprivatelinkresources.go @@ -0,0 +1,55 @@ +package staticsites + +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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c StaticSitesClient) GetPrivateLinkResources(ctx context.Context, id StaticSiteId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getstaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_getstaticsite.go new file mode 100644 index 00000000000..6096f2cb35e --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getstaticsite.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// GetStaticSite ... +func (c StaticSitesClient) GetStaticSite(ctx context.Context, id StaticSiteId) (result GetStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuild.go b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuild.go new file mode 100644 index 00000000000..0794f8c9a40 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuild.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBuildARMResource +} + +// GetStaticSiteBuild ... +func (c StaticSitesClient) GetStaticSiteBuild(ctx context.Context, id BuildId) (result GetStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteBuildARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuilds.go b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuilds.go new file mode 100644 index 00000000000..35a0a1c37e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitebuilds.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetStaticSiteBuildsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBuildARMResource +} + +type GetStaticSiteBuildsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteBuildARMResource +} + +// GetStaticSiteBuilds ... +func (c StaticSitesClient) GetStaticSiteBuilds(ctx context.Context, id StaticSiteId) (result GetStaticSiteBuildsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/builds", 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 *[]StaticSiteBuildARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSiteBuildsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSiteBuildsComplete(ctx context.Context, id StaticSiteId) (GetStaticSiteBuildsCompleteResult, error) { + return c.GetStaticSiteBuildsCompleteMatchingPredicate(ctx, id, StaticSiteBuildARMResourceOperationPredicate{}) +} + +// GetStaticSiteBuildsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSiteBuildsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBuildARMResourceOperationPredicate) (result GetStaticSiteBuildsCompleteResult, err error) { + items := make([]StaticSiteBuildARMResource, 0) + + resp, err := c.GetStaticSiteBuilds(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 = GetStaticSiteBuildsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getstaticsitecustomdomain.go b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitecustomdomain.go new file mode 100644 index 00000000000..482be40cd04 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitecustomdomain.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetStaticSiteCustomDomainOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteCustomDomainOverviewARMResource +} + +// GetStaticSiteCustomDomain ... +func (c StaticSitesClient) GetStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result GetStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteCustomDomainOverviewARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getstaticsitesbyresourcegroup.go b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitesbyresourcegroup.go new file mode 100644 index 00000000000..f5a6e73a93a --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getstaticsitesbyresourcegroup.go @@ -0,0 +1,92 @@ +package staticsites + +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 GetStaticSitesByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteARMResource +} + +type GetStaticSitesByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteARMResource +} + +// GetStaticSitesByResourceGroup ... +func (c StaticSitesClient) GetStaticSitesByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result GetStaticSitesByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", 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 *[]StaticSiteARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSitesByResourceGroupComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSitesByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (GetStaticSitesByResourceGroupCompleteResult, error) { + return c.GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// GetStaticSitesByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StaticSiteARMResourceOperationPredicate) (result GetStaticSitesByResourceGroupCompleteResult, err error) { + items := make([]StaticSiteARMResource, 0) + + resp, err := c.GetStaticSitesByResourceGroup(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 = GetStaticSitesByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go new file mode 100644 index 00000000000..8b09371d9c2 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetUserProvidedFunctionAppForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteUserProvidedFunctionAppARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go new file mode 100644 index 00000000000..9419b0ecc93 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go @@ -0,0 +1,54 @@ +package staticsites + +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 GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteUserProvidedFunctionAppARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go new file mode 100644 index 00000000000..23d1ee2ba48 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetUserProvidedFunctionAppsForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppsForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSite(ctx context.Context, id StaticSiteId) (result GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", 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 *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteComplete(ctx context.Context, id StaticSiteId) (GetUserProvidedFunctionAppsForStaticSiteCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSite(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 = GetUserProvidedFunctionAppsForStaticSiteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go new file mode 100644 index 00000000000..2e45fd82f95 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go @@ -0,0 +1,91 @@ +package staticsites + +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 GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppsForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuild(ctx context.Context, id BuildId) (result GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", 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 *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx context.Context, id BuildId) (GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSiteBuild(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 = GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_linkbackend.go b/resource-manager/web/2023-12-01/staticsites/method_linkbackend.go new file mode 100644 index 00000000000..a36f96d86fa --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_linkbackend.go @@ -0,0 +1,74 @@ +package staticsites + +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 LinkBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// LinkBackend ... +func (c StaticSitesClient) LinkBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendOperationResponse, 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 +} + +// LinkBackendThenPoll performs LinkBackend then polls until it's completed +func (c StaticSitesClient) LinkBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_linkbackendtobuild.go b/resource-manager/web/2023-12-01/staticsites/method_linkbackendtobuild.go new file mode 100644 index 00000000000..5e187571493 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_linkbackendtobuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 LinkBackendToBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// LinkBackendToBuild ... +func (c StaticSitesClient) LinkBackendToBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendToBuildOperationResponse, 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 +} + +// LinkBackendToBuildThenPoll performs LinkBackendToBuild then polls until it's completed +func (c StaticSitesClient) LinkBackendToBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackendToBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackendToBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackendToBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_list.go b/resource-manager/web/2023-12-01/staticsites/method_list.go new file mode 100644 index 00000000000..827e0cf3855 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_list.go @@ -0,0 +1,92 @@ +package staticsites + +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 *[]StaticSiteARMResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteARMResource +} + +// List ... +func (c StaticSitesClient) List(ctx context.Context, id commonids.SubscriptionId) (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.Web/staticSites", 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 *[]StaticSiteARMResource `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 StaticSitesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StaticSiteARMResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StaticSiteARMResource, 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/web/2023-12-01/staticsites/method_listbasicauth.go b/resource-manager/web/2023-12-01/staticsites/method_listbasicauth.go new file mode 100644 index 00000000000..5a3da7684ed --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_listbasicauth.go @@ -0,0 +1,91 @@ +package staticsites + +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 ListBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBasicAuthPropertiesARMResource +} + +type ListBasicAuthCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteBasicAuthPropertiesARMResource +} + +// ListBasicAuth ... +func (c StaticSitesClient) ListBasicAuth(ctx context.Context, id StaticSiteId) (result ListBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicAuth", 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 *[]StaticSiteBasicAuthPropertiesARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicAuthComplete retrieves all the results into a single object +func (c StaticSitesClient) ListBasicAuthComplete(ctx context.Context, id StaticSiteId) (ListBasicAuthCompleteResult, error) { + return c.ListBasicAuthCompleteMatchingPredicate(ctx, id, StaticSiteBasicAuthPropertiesARMResourceOperationPredicate{}) +} + +// ListBasicAuthCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListBasicAuthCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) (result ListBasicAuthCompleteResult, err error) { + items := make([]StaticSiteBasicAuthPropertiesARMResource, 0) + + resp, err := c.ListBasicAuth(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 = ListBasicAuthCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteappsettings.go new file mode 100644 index 00000000000..5ecb3eee84b --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteappsettings.go @@ -0,0 +1,55 @@ +package staticsites + +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 ListStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteAppSettings ... +func (c StaticSitesClient) ListStaticSiteAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildappsettings.go new file mode 100644 index 00000000000..deb7ce043ec --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildappsettings.go @@ -0,0 +1,55 @@ +package staticsites + +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 ListStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctionappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..14b452b8d2a --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctionappsettings.go @@ -0,0 +1,55 @@ +package staticsites + +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 ListStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctions.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctions.go new file mode 100644 index 00000000000..ac7570b97c5 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitebuildfunctions.go @@ -0,0 +1,91 @@ +package staticsites + +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 ListStaticSiteBuildFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteBuildFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteFunctionOverviewARMResource +} + +// ListStaticSiteBuildFunctions ... +func (c StaticSitesClient) ListStaticSiteBuildFunctions(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", 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 *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteBuildFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteBuildFunctionsComplete(ctx context.Context, id BuildId) (ListStaticSiteBuildFunctionsCompleteResult, error) { + return c.ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteBuildFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteBuildFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteBuildFunctions(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 = ListStaticSiteBuildFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteconfiguredroles.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteconfiguredroles.go new file mode 100644 index 00000000000..1a015925a7f --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteconfiguredroles.go @@ -0,0 +1,55 @@ +package staticsites + +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 ListStaticSiteConfiguredRolesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringList +} + +// ListStaticSiteConfiguredRoles ... +func (c StaticSitesClient) ListStaticSiteConfiguredRoles(ctx context.Context, id StaticSiteId) (result ListStaticSiteConfiguredRolesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listConfiguredRoles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringList + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsitecustomdomains.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitecustomdomains.go new file mode 100644 index 00000000000..570facccce5 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitecustomdomains.go @@ -0,0 +1,91 @@ +package staticsites + +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 ListStaticSiteCustomDomainsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteCustomDomainOverviewARMResource +} + +type ListStaticSiteCustomDomainsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteCustomDomainOverviewARMResource +} + +// ListStaticSiteCustomDomains ... +func (c StaticSitesClient) ListStaticSiteCustomDomains(ctx context.Context, id StaticSiteId) (result ListStaticSiteCustomDomainsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/customDomains", 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 *[]StaticSiteCustomDomainOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteCustomDomainsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteCustomDomainsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteCustomDomainsCompleteResult, error) { + return c.ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx, id, StaticSiteCustomDomainOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteCustomDomainsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteCustomDomainOverviewARMResourceOperationPredicate) (result ListStaticSiteCustomDomainsCompleteResult, err error) { + items := make([]StaticSiteCustomDomainOverviewARMResource, 0) + + resp, err := c.ListStaticSiteCustomDomains(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 = ListStaticSiteCustomDomainsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctionappsettings.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctionappsettings.go new file mode 100644 index 00000000000..32f56586d7e --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctionappsettings.go @@ -0,0 +1,55 @@ +package staticsites + +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 ListStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctions.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctions.go new file mode 100644 index 00000000000..374b80280e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitefunctions.go @@ -0,0 +1,91 @@ +package staticsites + +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 ListStaticSiteFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteFunctionOverviewARMResource +} + +// ListStaticSiteFunctions ... +func (c StaticSitesClient) ListStaticSiteFunctions(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", 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 *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteFunctionsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteFunctionsCompleteResult, error) { + return c.ListStaticSiteFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteFunctionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteFunctions(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 = ListStaticSiteFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsitesecrets.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitesecrets.go new file mode 100644 index 00000000000..cc35a7c0654 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsitesecrets.go @@ -0,0 +1,55 @@ +package staticsites + +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 ListStaticSiteSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteSecrets ... +func (c StaticSitesClient) ListStaticSiteSecrets(ctx context.Context, id StaticSiteId) (result ListStaticSiteSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteusers.go b/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteusers.go new file mode 100644 index 00000000000..1c6904d7ecc --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_liststaticsiteusers.go @@ -0,0 +1,91 @@ +package staticsites + +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 ListStaticSiteUsersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserARMResource +} + +type ListStaticSiteUsersCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserARMResource +} + +// ListStaticSiteUsers ... +func (c StaticSitesClient) ListStaticSiteUsers(ctx context.Context, id AuthProviderId) (result ListStaticSiteUsersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listUsers", 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 *[]StaticSiteUserARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteUsersComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteUsersComplete(ctx context.Context, id AuthProviderId) (ListStaticSiteUsersCompleteResult, error) { + return c.ListStaticSiteUsersCompleteMatchingPredicate(ctx, id, StaticSiteUserARMResourceOperationPredicate{}) +} + +// ListStaticSiteUsersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteUsersCompleteMatchingPredicate(ctx context.Context, id AuthProviderId, predicate StaticSiteUserARMResourceOperationPredicate) (result ListStaticSiteUsersCompleteResult, err error) { + items := make([]StaticSiteUserARMResource, 0) + + resp, err := c.ListStaticSiteUsers(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 = ListStaticSiteUsersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_previewworkflow.go b/resource-manager/web/2023-12-01/staticsites/method_previewworkflow.go new file mode 100644 index 00000000000..f867a88a25e --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_previewworkflow.go @@ -0,0 +1,59 @@ +package staticsites + +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 PreviewWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSitesWorkflowPreview +} + +// PreviewWorkflow ... +func (c StaticSitesClient) PreviewWorkflow(ctx context.Context, id ProviderLocationId, input StaticSitesWorkflowPreviewRequest) (result PreviewWorkflowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/previewStaticSiteWorkflowFile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSitesWorkflowPreview + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go new file mode 100644 index 00000000000..cda8ba615de --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go @@ -0,0 +1,103 @@ +package staticsites + +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 RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +type RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSite ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSite(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} + +// RegisterUserProvidedFunctionAppWithStaticSiteThenPoll performs RegisterUserProvidedFunctionAppWithStaticSite then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSite(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go b/resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go new file mode 100644 index 00000000000..a3f67cbfd6e --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go @@ -0,0 +1,103 @@ +package staticsites + +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 RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +type RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuild ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + OptionsObject: options, + } + + 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 +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll performs RegisterUserProvidedFunctionAppWithStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_resetstaticsiteapikey.go b/resource-manager/web/2023-12-01/staticsites/method_resetstaticsiteapikey.go new file mode 100644 index 00000000000..722e36f78c6 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_resetstaticsiteapikey.go @@ -0,0 +1,51 @@ +package staticsites + +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 ResetStaticSiteApiKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetStaticSiteApiKey ... +func (c StaticSitesClient) ResetStaticSiteApiKey(ctx context.Context, id StaticSiteId, input StaticSiteResetPropertiesARMResource) (result ResetStaticSiteApiKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetapikey", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_unlinkbackend.go b/resource-manager/web/2023-12-01/staticsites/method_unlinkbackend.go new file mode 100644 index 00000000000..98066240969 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_unlinkbackend.go @@ -0,0 +1,76 @@ +package staticsites + +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 UnlinkBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendOperationOptions() UnlinkBackendOperationOptions { + return UnlinkBackendOperationOptions{} +} + +func (o UnlinkBackendOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UnlinkBackendOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackend ... +func (c StaticSitesClient) UnlinkBackend(ctx context.Context, id LinkedBackendId, options UnlinkBackendOperationOptions) (result UnlinkBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_unlinkbackendfrombuild.go b/resource-manager/web/2023-12-01/staticsites/method_unlinkbackendfrombuild.go new file mode 100644 index 00000000000..9ef02435e54 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_unlinkbackendfrombuild.go @@ -0,0 +1,76 @@ +package staticsites + +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 UnlinkBackendFromBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendFromBuildOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendFromBuildOperationOptions() UnlinkBackendFromBuildOperationOptions { + return UnlinkBackendFromBuildOperationOptions{} +} + +func (o UnlinkBackendFromBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackendFromBuild ... +func (c StaticSitesClient) UnlinkBackendFromBuild(ctx context.Context, id BuildLinkedBackendId, options UnlinkBackendFromBuildOperationOptions) (result UnlinkBackendFromBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_updatebuilddatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_updatebuilddatabaseconnection.go new file mode 100644 index 00000000000..c9611ae5cb3 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_updatebuilddatabaseconnection.go @@ -0,0 +1,58 @@ +package staticsites + +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 UpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateBuildDatabaseConnection ... +func (c StaticSitesClient) UpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_updatedatabaseconnection.go b/resource-manager/web/2023-12-01/staticsites/method_updatedatabaseconnection.go new file mode 100644 index 00000000000..6e37673f34d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_updatedatabaseconnection.go @@ -0,0 +1,58 @@ +package staticsites + +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 UpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateDatabaseConnection ... +func (c StaticSitesClient) UpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model DatabaseConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_updatestaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_updatestaticsite.go new file mode 100644 index 00000000000..2db8a28235a --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_updatestaticsite.go @@ -0,0 +1,59 @@ +package staticsites + +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 UpdateStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// UpdateStaticSite ... +func (c StaticSitesClient) UpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSitePatchResource) (result UpdateStaticSiteOperationResponse, 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 + } + + var model StaticSiteARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_updatestaticsiteuser.go b/resource-manager/web/2023-12-01/staticsites/method_updatestaticsiteuser.go new file mode 100644 index 00000000000..ddcb14fbcc6 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_updatestaticsiteuser.go @@ -0,0 +1,58 @@ +package staticsites + +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 UpdateStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserARMResource +} + +// UpdateStaticSiteUser ... +func (c StaticSitesClient) UpdateStaticSiteUser(ctx context.Context, id UserId, input StaticSiteUserARMResource) (result UpdateStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model StaticSiteUserARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_validatebackend.go b/resource-manager/web/2023-12-01/staticsites/method_validatebackend.go new file mode 100644 index 00000000000..12aa25c2202 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_validatebackend.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackend ... +func (c StaticSitesClient) ValidateBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateBackendThenPoll performs ValidateBackend then polls until it's completed +func (c StaticSitesClient) ValidateBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_validatebackendforbuild.go b/resource-manager/web/2023-12-01/staticsites/method_validatebackendforbuild.go new file mode 100644 index 00000000000..d703ff84c0b --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_validatebackendforbuild.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateBackendForBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackendForBuild ... +func (c StaticSitesClient) ValidateBackendForBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateBackendForBuildThenPoll performs ValidateBackendForBuild then polls until it's completed +func (c StaticSitesClient) ValidateBackendForBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackendForBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackendForBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackendForBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go b/resource-manager/web/2023-12-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go new file mode 100644 index 00000000000..deda3155c42 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +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 ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateCustomDomainCanBeAddedToStaticSite ... +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSite(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 +} + +// ValidateCustomDomainCanBeAddedToStaticSiteThenPoll performs ValidateCustomDomainCanBeAddedToStaticSite then polls until it's completed +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.ValidateCustomDomainCanBeAddedToStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_armidwrapper.go b/resource-manager/web/2023-12-01/staticsites/model_armidwrapper.go new file mode 100644 index 00000000000..c9987651a5f --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_armidwrapper.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_armplan.go b/resource-manager/web/2023-12-01/staticsites/model_armplan.go new file mode 100644 index 00000000000..2cb5352de6e --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_armplan.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmPlan struct { + Name *string `json:"name,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_capability.go b/resource-manager/web/2023-12-01/staticsites/model_capability.go new file mode 100644 index 00000000000..300bf980489 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_capability.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_databaseconnection.go b/resource-manager/web/2023-12-01/staticsites/model_databaseconnection.go new file mode 100644 index 00000000000..cd069f365d4 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_databaseconnection.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DatabaseConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionoverview.go b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionoverview.go new file mode 100644 index 00000000000..8597c4ff8b4 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionoverview.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionOverview struct { + ConfigurationFiles *[]StaticSiteDatabaseConnectionConfigurationFileOverview `json:"configurationFiles,omitempty"` + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + Name *string `json:"name,omitempty"` + Region *string `json:"region,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequest.go b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequest.go new file mode 100644 index 00000000000..493e3509268 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequest.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionPatchRequest struct { + Properties *DatabaseConnectionPatchRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequestproperties.go b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequestproperties.go new file mode 100644 index 00000000000..2b5eb824c26 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionpatchrequestproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionPatchRequestProperties struct { + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Region *string `json:"region,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionproperties.go b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionproperties.go new file mode 100644 index 00000000000..81aee01e533 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_databaseconnectionproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionProperties struct { + ConfigurationFiles *[]StaticSiteDatabaseConnectionConfigurationFileOverview `json:"configurationFiles,omitempty"` + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Region string `json:"region"` + ResourceId string `json:"resourceId"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_errorentity.go b/resource-manager/web/2023-12-01/staticsites/model_errorentity.go new file mode 100644 index 00000000000..6b726cb5492 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_errorentity.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_privatelinkconnectionstate.go b/resource-manager/web/2023-12-01/staticsites/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..bdfe81e8a98 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_privatelinkresource.go b/resource-manager/web/2023-12-01/staticsites/model_privatelinkresource.go new file mode 100644 index 00000000000..975df70d5c7 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..8dacfc8b182 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceswrapper.go b/resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..2890dfe9e4a --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnection.go b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnection.go new file mode 100644 index 00000000000..2456e6e1d5b --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnection.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..708bf563a7f --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..75f3ef6233d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionproperties.go b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionproperties.go new file mode 100644 index 00000000000..23d098fcaa6 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_remoteprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go b/resource-manager/web/2023-12-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go new file mode 100644 index 00000000000..54a231b3460 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go @@ -0,0 +1,24 @@ +package staticsites + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseMessageEnvelopeRemotePrivateEndpointConnection struct { + Error *ErrorEntity `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Plan *ArmPlan `json:"plan,omitempty"` + Properties *RemotePrivateEndpointConnection `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Status *string `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_skucapacity.go b/resource-manager/web/2023-12-01/staticsites/model_skucapacity.go new file mode 100644 index 00000000000..d8cd9de7ec4 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_skucapacity.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_skudescription.go b/resource-manager/web/2023-12-01/staticsites/model_skudescription.go new file mode 100644 index 00000000000..2e1e0cde311 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_skudescription.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsite.go b/resource-manager/web/2023-12-01/staticsites/model_staticsite.go new file mode 100644 index 00000000000..9fad6989e54 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsite.go @@ -0,0 +1,25 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSite struct { + AllowConfigFileUpdates *bool `json:"allowConfigFileUpdates,omitempty"` + Branch *string `json:"branch,omitempty"` + BuildProperties *StaticSiteBuildProperties `json:"buildProperties,omitempty"` + ContentDistributionEndpoint *string `json:"contentDistributionEndpoint,omitempty"` + CustomDomains *[]string `json:"customDomains,omitempty"` + DatabaseConnections *[]DatabaseConnectionOverview `json:"databaseConnections,omitempty"` + DefaultHostname *string `json:"defaultHostname,omitempty"` + EnterpriseGradeCdnStatus *EnterpriseGradeCdnStatus `json:"enterpriseGradeCdnStatus,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LinkedBackends *[]StaticSiteLinkedBackend `json:"linkedBackends,omitempty"` + PrivateEndpointConnections *[]ResponseMessageEnvelopeRemotePrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + Provider *string `json:"provider,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RepositoryToken *string `json:"repositoryToken,omitempty"` + RepositoryUrl *string `json:"repositoryUrl,omitempty"` + StagingEnvironmentPolicy *StagingEnvironmentPolicy `json:"stagingEnvironmentPolicy,omitempty"` + TemplateProperties *StaticSiteTemplateOptions `json:"templateProperties,omitempty"` + UserProvidedFunctionApps *[]StaticSiteUserProvidedFunctionApp `json:"userProvidedFunctionApps,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitearmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitearmresource.go new file mode 100644 index 00000000000..a54aa2362bb --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitearmresource.go @@ -0,0 +1,20 @@ +package staticsites + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteARMResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *StaticSite `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go new file mode 100644 index 00000000000..bf58faf53d3 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBasicAuthPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteBasicAuthPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..80795463497 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBasicAuthPropertiesARMResourceProperties struct { + ApplicableEnvironmentsMode string `json:"applicableEnvironmentsMode"` + Environments *[]string `json:"environments,omitempty"` + Password *string `json:"password,omitempty"` + SecretState *string `json:"secretState,omitempty"` + SecretUrl *string `json:"secretUrl,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresource.go new file mode 100644 index 00000000000..332e5334386 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBuildARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteBuildARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresourceproperties.go new file mode 100644 index 00000000000..50bbe9e5443 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildarmresourceproperties.go @@ -0,0 +1,47 @@ +package staticsites + +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 StaticSiteBuildARMResourceProperties struct { + BuildId *string `json:"buildId,omitempty"` + CreatedTimeUtc *string `json:"createdTimeUtc,omitempty"` + DatabaseConnections *[]DatabaseConnectionOverview `json:"databaseConnections,omitempty"` + Hostname *string `json:"hostname,omitempty"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + LinkedBackends *[]StaticSiteLinkedBackend `json:"linkedBackends,omitempty"` + PullRequestTitle *string `json:"pullRequestTitle,omitempty"` + SourceBranch *string `json:"sourceBranch,omitempty"` + Status *BuildStatus `json:"status,omitempty"` + UserProvidedFunctionApps *[]StaticSiteUserProvidedFunctionApp `json:"userProvidedFunctionApps,omitempty"` +} + +func (o *StaticSiteBuildARMResourceProperties) GetCreatedTimeUtcAsTime() (*time.Time, error) { + if o.CreatedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteBuildARMResourceProperties) SetCreatedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimeUtc = &formatted +} + +func (o *StaticSiteBuildARMResourceProperties) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteBuildARMResourceProperties) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildproperties.go new file mode 100644 index 00000000000..9dbe72ed06c --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitebuildproperties.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBuildProperties struct { + ApiBuildCommand *string `json:"apiBuildCommand,omitempty"` + ApiLocation *string `json:"apiLocation,omitempty"` + AppArtifactLocation *string `json:"appArtifactLocation,omitempty"` + AppBuildCommand *string `json:"appBuildCommand,omitempty"` + AppLocation *string `json:"appLocation,omitempty"` + GitHubActionSecretNameOverride *string `json:"githubActionSecretNameOverride,omitempty"` + OutputLocation *string `json:"outputLocation,omitempty"` + SkipGithubActionWorkflowGeneration *bool `json:"skipGithubActionWorkflowGeneration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go new file mode 100644 index 00000000000..95f00a98762 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainOverviewARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteCustomDomainOverviewARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go new file mode 100644 index 00000000000..cc0b5c99274 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go @@ -0,0 +1,30 @@ +package staticsites + +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 StaticSiteCustomDomainOverviewARMResourceProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + DomainName *string `json:"domainName,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Status *CustomDomainStatus `json:"status,omitempty"` + ValidationToken *string `json:"validationToken,omitempty"` +} + +func (o *StaticSiteCustomDomainOverviewARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteCustomDomainOverviewARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go new file mode 100644 index 00000000000..b790fc90f5d --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainRequestPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteCustomDomainRequestPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..e4510ee8855 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainRequestPropertiesARMResourceProperties struct { + ValidationMethod *string `json:"validationMethod,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go new file mode 100644 index 00000000000..0389a6f704c --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteDatabaseConnectionConfigurationFileOverview struct { + Contents *string `json:"contents,omitempty"` + FileName *string `json:"fileName,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresource.go new file mode 100644 index 00000000000..fa8ca3288d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteFunctionOverviewARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteFunctionOverviewARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go new file mode 100644 index 00000000000..46eeb330774 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteFunctionOverviewARMResourceProperties struct { + FunctionName *string `json:"functionName,omitempty"` + TriggerType *TriggerTypes `json:"triggerType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackend.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackend.go new file mode 100644 index 00000000000..52b103d13bc --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackend.go @@ -0,0 +1,29 @@ +package staticsites + +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 StaticSiteLinkedBackend struct { + BackendResourceId *string `json:"backendResourceId,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *StaticSiteLinkedBackend) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteLinkedBackend) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresource.go new file mode 100644 index 00000000000..97ddc7ab2ac --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteLinkedBackendARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteLinkedBackendARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go new file mode 100644 index 00000000000..5ec2c55c393 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go @@ -0,0 +1,29 @@ +package staticsites + +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 StaticSiteLinkedBackendARMResourceProperties struct { + BackendResourceId *string `json:"backendResourceId,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *StaticSiteLinkedBackendARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteLinkedBackendARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitepatchresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitepatchresource.go new file mode 100644 index 00000000000..6969a6ebae4 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitepatchresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSite `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresource.go new file mode 100644 index 00000000000..53a0c64632a --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteResetPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteResetPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..87a927d3952 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteResetPropertiesARMResourceProperties struct { + RepositoryToken *string `json:"repositoryToken,omitempty"` + ShouldUpdateRepository *bool `json:"shouldUpdateRepository,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreview.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreview.go new file mode 100644 index 00000000000..01cca8f1d47 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreview.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreview struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSitesWorkflowPreviewProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewproperties.go new file mode 100644 index 00000000000..4e0aa482c92 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewProperties struct { + Contents *string `json:"contents,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequest.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequest.go new file mode 100644 index 00000000000..c255ba00697 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequest.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSitesWorkflowPreviewRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go new file mode 100644 index 00000000000..bca5c553bc4 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewRequestProperties struct { + Branch *string `json:"branch,omitempty"` + BuildProperties *StaticSiteBuildProperties `json:"buildProperties,omitempty"` + RepositoryUrl *string `json:"repositoryUrl,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitetemplateoptions.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitetemplateoptions.go new file mode 100644 index 00000000000..5afb0421afc --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitetemplateoptions.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteTemplateOptions struct { + Description *string `json:"description,omitempty"` + IsPrivate *bool `json:"isPrivate,omitempty"` + Owner *string `json:"owner,omitempty"` + RepositoryName *string `json:"repositoryName,omitempty"` + TemplateRepositoryUrl *string `json:"templateRepositoryUrl,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresource.go new file mode 100644 index 00000000000..296cf30c6f8 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresourceproperties.go new file mode 100644 index 00000000000..1ee310fa773 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserarmresourceproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserARMResourceProperties struct { + DisplayName *string `json:"displayName,omitempty"` + Provider *string `json:"provider,omitempty"` + Roles *string `json:"roles,omitempty"` + UserId *string `json:"userId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresource.go new file mode 100644 index 00000000000..d9d5ae47bdc --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationRequestResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserInvitationRequestResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go new file mode 100644 index 00000000000..744a01b8f56 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationRequestResourceProperties struct { + Domain *string `json:"domain,omitempty"` + NumHoursToExpiration *int64 `json:"numHoursToExpiration,omitempty"` + Provider *string `json:"provider,omitempty"` + Roles *string `json:"roles,omitempty"` + UserDetails *string `json:"userDetails,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresource.go new file mode 100644 index 00000000000..1c89e5056c0 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationResponseResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserInvitationResponseResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go new file mode 100644 index 00000000000..674c99a3b50 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go @@ -0,0 +1,27 @@ +package staticsites + +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 StaticSiteUserInvitationResponseResourceProperties struct { + ExpiresOn *string `json:"expiresOn,omitempty"` + InvitationUrl *string `json:"invitationUrl,omitempty"` +} + +func (o *StaticSiteUserInvitationResponseResourceProperties) GetExpiresOnAsTime() (*time.Time, error) { + if o.ExpiresOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiresOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserInvitationResponseResourceProperties) SetExpiresOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiresOn = &formatted +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapp.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapp.go new file mode 100644 index 00000000000..08c7d23a344 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapp.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionApp struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserProvidedFunctionAppProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go new file mode 100644 index 00000000000..c3a983f8eea --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionAppARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserProvidedFunctionAppARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go new file mode 100644 index 00000000000..5c3f5f4b629 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go @@ -0,0 +1,28 @@ +package staticsites + +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 StaticSiteUserProvidedFunctionAppARMResourceProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + FunctionAppRegion *string `json:"functionAppRegion,omitempty"` + FunctionAppResourceId *string `json:"functionAppResourceId,omitempty"` +} + +func (o *StaticSiteUserProvidedFunctionAppARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserProvidedFunctionAppARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go new file mode 100644 index 00000000000..d1aa33d93e1 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go @@ -0,0 +1,28 @@ +package staticsites + +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 StaticSiteUserProvidedFunctionAppProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + FunctionAppRegion *string `json:"functionAppRegion,omitempty"` + FunctionAppResourceId *string `json:"functionAppResourceId,omitempty"` +} + +func (o *StaticSiteUserProvidedFunctionAppProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserProvidedFunctionAppProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeployment.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeployment.go new file mode 100644 index 00000000000..29435dc00a6 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeployment.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteZipDeployment struct { + ApiZipUrl *string `json:"apiZipUrl,omitempty"` + AppZipUrl *string `json:"appZipUrl,omitempty"` + DeploymentTitle *string `json:"deploymentTitle,omitempty"` + FunctionLanguage *string `json:"functionLanguage,omitempty"` + Provider *string `json:"provider,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeploymentarmresource.go b/resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeploymentarmresource.go new file mode 100644 index 00000000000..f842a2730dc --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_staticsitezipdeploymentarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteZipDeploymentARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteZipDeployment `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_stringdictionary.go b/resource-manager/web/2023-12-01/staticsites/model_stringdictionary.go new file mode 100644 index 00000000000..71965903614 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_stringdictionary.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/model_stringlist.go b/resource-manager/web/2023-12-01/staticsites/model_stringlist.go new file mode 100644 index 00000000000..79987b1ea84 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/model_stringlist.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringList struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *[]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/staticsites/predicates.go b/resource-manager/web/2023-12-01/staticsites/predicates.go new file mode 100644 index 00000000000..b27ed7b5388 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/predicates.go @@ -0,0 +1,289 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DatabaseConnectionOperationPredicate) Matches(input DatabaseConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteARMResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p StaticSiteARMResourceOperationPredicate) Matches(input StaticSiteARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteBasicAuthPropertiesARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) Matches(input StaticSiteBasicAuthPropertiesARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteBuildARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteBuildARMResourceOperationPredicate) Matches(input StaticSiteBuildARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteCustomDomainOverviewARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteCustomDomainOverviewARMResourceOperationPredicate) Matches(input StaticSiteCustomDomainOverviewARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteFunctionOverviewARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteFunctionOverviewARMResourceOperationPredicate) Matches(input StaticSiteFunctionOverviewARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteLinkedBackendARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteLinkedBackendARMResourceOperationPredicate) Matches(input StaticSiteLinkedBackendARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteUserARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteUserARMResourceOperationPredicate) Matches(input StaticSiteUserARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) Matches(input StaticSiteUserProvidedFunctionAppARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/staticsites/version.go b/resource-manager/web/2023-12-01/staticsites/version.go new file mode 100644 index 00000000000..18154ade274 --- /dev/null +++ b/resource-manager/web/2023-12-01/staticsites/version.go @@ -0,0 +1,12 @@ +package staticsites + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/staticsites/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/README.md b/resource-manager/web/2023-12-01/topleveldomains/README.md new file mode 100644 index 00000000000..513d7ddc42d --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/README.md @@ -0,0 +1,76 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/topleveldomains` Documentation + +The `topleveldomains` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/topleveldomains" +``` + + +### Client Initialization + +```go +client := topleveldomains.NewTopLevelDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TopLevelDomainsClient.Get` + +```go +ctx := context.TODO() +id := topleveldomains.NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainValue") + +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: `TopLevelDomainsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `TopLevelDomainsClient.ListAgreements` + +```go +ctx := context.TODO() +id := topleveldomains.NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainValue") + +payload := topleveldomains.TopLevelDomainAgreementOption{ + // ... +} + + +// alternatively `client.ListAgreements(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListAgreementsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/topleveldomains/client.go b/resource-manager/web/2023-12-01/topleveldomains/client.go new file mode 100644 index 00000000000..f688cee500e --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/client.go @@ -0,0 +1,26 @@ +package topleveldomains + +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 TopLevelDomainsClient struct { + Client *resourcemanager.Client +} + +func NewTopLevelDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*TopLevelDomainsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "topleveldomains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TopLevelDomainsClient: %+v", err) + } + + return &TopLevelDomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain.go b/resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain.go new file mode 100644 index 00000000000..acfeab4dadd --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain.go @@ -0,0 +1,121 @@ +package topleveldomains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TopLevelDomainId{}) +} + +var _ resourceids.ResourceId = &TopLevelDomainId{} + +// TopLevelDomainId is a struct representing the Resource ID for a Top Level Domain +type TopLevelDomainId struct { + SubscriptionId string + TopLevelDomainName string +} + +// NewTopLevelDomainID returns a new TopLevelDomainId struct +func NewTopLevelDomainID(subscriptionId string, topLevelDomainName string) TopLevelDomainId { + return TopLevelDomainId{ + SubscriptionId: subscriptionId, + TopLevelDomainName: topLevelDomainName, + } +} + +// ParseTopLevelDomainID parses 'input' into a TopLevelDomainId +func ParseTopLevelDomainID(input string) (*TopLevelDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&TopLevelDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TopLevelDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTopLevelDomainIDInsensitively parses 'input' case-insensitively into a TopLevelDomainId +// note: this method should only be used for API response data and not user input +func ParseTopLevelDomainIDInsensitively(input string) (*TopLevelDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&TopLevelDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TopLevelDomainId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TopLevelDomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.TopLevelDomainName, ok = input.Parsed["topLevelDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "topLevelDomainName", input) + } + + return nil +} + +// ValidateTopLevelDomainID checks that 'input' can be parsed as a Top Level Domain ID +func ValidateTopLevelDomainID(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 := ParseTopLevelDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Top Level Domain ID +func (id TopLevelDomainId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DomainRegistration/topLevelDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.TopLevelDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Top Level Domain ID +func (id TopLevelDomainId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticTopLevelDomains", "topLevelDomains", "topLevelDomains"), + resourceids.UserSpecifiedSegment("topLevelDomainName", "topLevelDomainValue"), + } +} + +// String returns a human-readable description of this Top Level Domain ID +func (id TopLevelDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Top Level Domain Name: %q", id.TopLevelDomainName), + } + return fmt.Sprintf("Top Level Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain_test.go b/resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain_test.go new file mode 100644 index 00000000000..ab4b2a52534 --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/id_topleveldomain_test.go @@ -0,0 +1,237 @@ +package topleveldomains + +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 = &TopLevelDomainId{} + +func TestNewTopLevelDomainID(t *testing.T) { + id := NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainValue") + + 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.TopLevelDomainName != "topLevelDomainValue" { + t.Fatalf("Expected %q but got %q for Segment 'TopLevelDomainName'", id.TopLevelDomainName, "topLevelDomainValue") + } +} + +func TestFormatTopLevelDomainID(t *testing.T) { + actual := NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTopLevelDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TopLevelDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainValue", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "topLevelDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTopLevelDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.TopLevelDomainName != v.Expected.TopLevelDomainName { + t.Fatalf("Expected %q but got %q for TopLevelDomainName", v.Expected.TopLevelDomainName, actual.TopLevelDomainName) + } + + } +} + +func TestParseTopLevelDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TopLevelDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainValue", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "topLevelDomainValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs/tOpLeVeLdOmAiNvAlUe", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "tOpLeVeLdOmAiNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs/tOpLeVeLdOmAiNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTopLevelDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.TopLevelDomainName != v.Expected.TopLevelDomainName { + t.Fatalf("Expected %q but got %q for TopLevelDomainName", v.Expected.TopLevelDomainName, actual.TopLevelDomainName) + } + + } +} + +func TestSegmentsForTopLevelDomainId(t *testing.T) { + segments := TopLevelDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TopLevelDomainId 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/web/2023-12-01/topleveldomains/method_get.go b/resource-manager/web/2023-12-01/topleveldomains/method_get.go new file mode 100644 index 00000000000..f8281b382bd --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/method_get.go @@ -0,0 +1,54 @@ +package topleveldomains + +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 *TopLevelDomain +} + +// Get ... +func (c TopLevelDomainsClient) Get(ctx context.Context, id TopLevelDomainId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TopLevelDomain + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/method_list.go b/resource-manager/web/2023-12-01/topleveldomains/method_list.go new file mode 100644 index 00000000000..f40da4d4c39 --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/method_list.go @@ -0,0 +1,92 @@ +package topleveldomains + +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 *[]TopLevelDomain +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []TopLevelDomain +} + +// List ... +func (c TopLevelDomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (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.DomainRegistration/topLevelDomains", 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 *[]TopLevelDomain `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 TopLevelDomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, TopLevelDomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate TopLevelDomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]TopLevelDomain, 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/web/2023-12-01/topleveldomains/method_listagreements.go b/resource-manager/web/2023-12-01/topleveldomains/method_listagreements.go new file mode 100644 index 00000000000..d7f40d1d257 --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/method_listagreements.go @@ -0,0 +1,91 @@ +package topleveldomains + +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 ListAgreementsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TldLegalAgreement +} + +type ListAgreementsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TldLegalAgreement +} + +// ListAgreements ... +func (c TopLevelDomainsClient) ListAgreements(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (result ListAgreementsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAgreements", 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 *[]TldLegalAgreement `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAgreementsComplete retrieves all the results into a single object +func (c TopLevelDomainsClient) ListAgreementsComplete(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (ListAgreementsCompleteResult, error) { + return c.ListAgreementsCompleteMatchingPredicate(ctx, id, input, TldLegalAgreementOperationPredicate{}) +} + +// ListAgreementsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListAgreementsCompleteMatchingPredicate(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption, predicate TldLegalAgreementOperationPredicate) (result ListAgreementsCompleteResult, err error) { + items := make([]TldLegalAgreement, 0) + + resp, err := c.ListAgreements(ctx, id, input) + 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 = ListAgreementsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/model_tldlegalagreement.go b/resource-manager/web/2023-12-01/topleveldomains/model_tldlegalagreement.go new file mode 100644 index 00000000000..7efd744d882 --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/model_tldlegalagreement.go @@ -0,0 +1,11 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TldLegalAgreement struct { + AgreementKey string `json:"agreementKey"` + Content string `json:"content"` + Title string `json:"title"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomain.go b/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomain.go new file mode 100644 index 00000000000..88855d8e294 --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomain.go @@ -0,0 +1,12 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomain struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TopLevelDomainProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainagreementoption.go b/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainagreementoption.go new file mode 100644 index 00000000000..f39158b5cbc --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainagreementoption.go @@ -0,0 +1,9 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomainAgreementOption struct { + ForTransfer *bool `json:"forTransfer,omitempty"` + IncludePrivacy *bool `json:"includePrivacy,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainproperties.go b/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainproperties.go new file mode 100644 index 00000000000..9e205230463 --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/model_topleveldomainproperties.go @@ -0,0 +1,8 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomainProperties struct { + Privacy *bool `json:"privacy,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/topleveldomains/predicates.go b/resource-manager/web/2023-12-01/topleveldomains/predicates.go new file mode 100644 index 00000000000..a85c5378eeb --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/predicates.go @@ -0,0 +1,60 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TldLegalAgreementOperationPredicate struct { + AgreementKey *string + Content *string + Title *string + Url *string +} + +func (p TldLegalAgreementOperationPredicate) Matches(input TldLegalAgreement) bool { + + if p.AgreementKey != nil && *p.AgreementKey != input.AgreementKey { + return false + } + + if p.Content != nil && *p.Content != input.Content { + return false + } + + if p.Title != nil && *p.Title != input.Title { + return false + } + + if p.Url != nil && (input.Url == nil || *p.Url != *input.Url) { + return false + } + + return true +} + +type TopLevelDomainOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TopLevelDomainOperationPredicate) Matches(input TopLevelDomain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/topleveldomains/version.go b/resource-manager/web/2023-12-01/topleveldomains/version.go new file mode 100644 index 00000000000..6213fcd72da --- /dev/null +++ b/resource-manager/web/2023-12-01/topleveldomains/version.go @@ -0,0 +1,12 @@ +package topleveldomains + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/topleveldomains/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/webapps/README.md b/resource-manager/web/2023-12-01/webapps/README.md new file mode 100644 index 00000000000..b166355d1dd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/README.md @@ -0,0 +1,7053 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps` Documentation + +The `webapps` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/webapps" +``` + + +### Client Initialization + +```go +client := webapps.NewWebAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebAppsClient.AddPremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "premierAddonValue") + +payload := webapps.PremierAddOn{ + // ... +} + + +read, err := client.AddPremierAddOn(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AddPremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "premierAddonValue") + +payload := webapps.PremierAddOn{ + // ... +} + + +read, err := client.AddPremierAddOnSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AnalyzeCustomHostname` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.AnalyzeCustomHostname(ctx, id, webapps.DefaultAnalyzeCustomHostnameOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AnalyzeCustomHostnameSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.AnalyzeCustomHostnameSlot(ctx, id, webapps.DefaultAnalyzeCustomHostnameSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApplySlotConfigToProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +read, err := client.ApplySlotConfigToProduction(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApplySlotConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +read, err := client.ApplySlotConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "privateEndpointConnectionValue") + +payload := webapps.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ApproveOrRejectPrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "privateEndpointConnectionValue") + +payload := webapps.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.Backup` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.Backup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.BackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.BackupSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "deploymentValue") + +payload := webapps.Deployment{ + // ... +} + + +read, err := client.CreateDeployment(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "deploymentValue") + +payload := webapps.Deployment{ + // ... +} + + +read, err := client.CreateDeploymentSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue") + +payload := webapps.FunctionEnvelope{ + // ... +} + + +if err := client.CreateFunctionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue") + +payload := webapps.FunctionEnvelope{ + // ... +} + + +if err := client.CreateInstanceFunctionSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceMSDeployOperation` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateInstanceMSDeployOperationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceMSDeployOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateInstanceMSDeployOperationSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateMSDeployOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateMSDeployOperationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateMSDeployOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateMSDeployOperationSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOneDeployOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.CreateOneDeployOperation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.Site{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.CreateOrUpdateConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.CreateOrUpdateConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "domainOwnershipIdentifierValue") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.CreateOrUpdateDomainOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "domainOwnershipIdentifierValue") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.CreateOrUpdateDomainOwnershipIdentifierSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateFunctionSecret` + +```go +ctx := context.TODO() +id := webapps.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue", "keyValue") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateFunctionSecret(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateFunctionSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue", "keyValue") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateFunctionSecretSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hostNameBindingValue") + +payload := webapps.HostNameBinding{ + // ... +} + + +read, err := client.CreateOrUpdateHostNameBinding(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hostNameBindingValue") + +payload := webapps.HostNameBinding{ + // ... +} + + +read, err := client.CreateOrUpdateHostNameBindingSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostSecret` + +```go +ctx := context.TODO() +id := webapps.NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "defaultValue", "keyValue") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateHostSecret(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "defaultValue", "keyValue") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateHostSecretSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionNamespaceValue", "relayValue") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.CreateOrUpdateHybridConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionNamespaceValue", "relayValue") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.CreateOrUpdateHybridConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdatePublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "publicCertificateValue") + +payload := webapps.PublicCertificate{ + // ... +} + + +read, err := client.CreateOrUpdatePublicCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdatePublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "publicCertificateValue") + +payload := webapps.PublicCertificate{ + // ... +} + + +read, err := client.CreateOrUpdatePublicCertificateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionValue") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.CreateOrUpdateRelayServiceConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionValue") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.CreateOrUpdateRelayServiceConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "sitecontainerValue") + +payload := webapps.SiteContainer{ + // ... +} + + +read, err := client.CreateOrUpdateSiteContainer(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "sitecontainerValue") + +payload := webapps.SiteContainer{ + // ... +} + + +read, err := client.CreateOrUpdateSiteContainerSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.Site{ + // ... +} + + +if err := client.CreateOrUpdateSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SiteSourceControl{ + // ... +} + + +if err := client.CreateOrUpdateSourceControlThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SiteSourceControl{ + // ... +} + + +if err := client.CreateOrUpdateSourceControlSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue", "gatewayValue") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue", "gatewayValue") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionGatewaySlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.Delete(ctx, id, webapps.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackup` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "backupIdValue") + +read, err := client.DeleteBackup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.DeleteBackupConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.DeleteBackupConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "backupIdValue") + +read, err := client.DeleteBackupSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "continuousWebJobValue") + +read, err := client.DeleteContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "continuousWebJobValue") + +read, err := client.DeleteContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "deploymentValue") + +read, err := client.DeleteDeployment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "deploymentValue") + +read, err := client.DeleteDeploymentSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "domainOwnershipIdentifierValue") + +read, err := client.DeleteDomainOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "domainOwnershipIdentifierValue") + +read, err := client.DeleteDomainOwnershipIdentifierSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue") + +read, err := client.DeleteFunction(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunctionSecret` + +```go +ctx := context.TODO() +id := webapps.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue", "keyValue") + +read, err := client.DeleteFunctionSecret(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunctionSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue", "keyValue") + +read, err := client.DeleteFunctionSecretSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hostNameBindingValue") + +read, err := client.DeleteHostNameBinding(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hostNameBindingValue") + +read, err := client.DeleteHostNameBindingSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostSecret` + +```go +ctx := context.TODO() +id := webapps.NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "defaultValue", "keyValue") + +read, err := client.DeleteHostSecret(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "defaultValue", "keyValue") + +read, err := client.DeleteHostSecretSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionNamespaceValue", "relayValue") + +read, err := client.DeleteHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionNamespaceValue", "relayValue") + +read, err := client.DeleteHybridConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue") + +read, err := client.DeleteInstanceFunctionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceProcess` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue") + +read, err := client.DeleteInstanceProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue") + +read, err := client.DeleteInstanceProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "premierAddonValue") + +read, err := client.DeletePremierAddOn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "premierAddonValue") + +read, err := client.DeletePremierAddOnSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "privateEndpointConnectionValue") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.DeletePrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "privateEndpointConnectionValue") + +if err := client.DeletePrivateEndpointConnectionSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.DeleteProcess` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue") + +read, err := client.DeleteProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue") + +read, err := client.DeleteProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "publicCertificateValue") + +read, err := client.DeletePublicCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "publicCertificateValue") + +read, err := client.DeletePublicCertificateSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionValue") + +read, err := client.DeleteRelayServiceConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionValue") + +read, err := client.DeleteRelayServiceConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "sitecontainerValue") + +read, err := client.DeleteSiteContainer(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "sitecontainerValue") + +read, err := client.DeleteSiteContainerSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "siteExtensionIdValue") + +read, err := client.DeleteSiteExtension(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "siteExtensionIdValue") + +read, err := client.DeleteSiteExtensionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.DeleteSlot(ctx, id, webapps.DefaultDeleteSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.DeleteSourceControl(ctx, id, webapps.DefaultDeleteSourceControlOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.DeleteSourceControlSlot(ctx, id, webapps.DefaultDeleteSourceControlSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSwiftVirtualNetwork` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.DeleteSwiftVirtualNetwork(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSwiftVirtualNetworkSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.DeleteSwiftVirtualNetworkSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue") + +read, err := client.DeleteTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue") + +read, err := client.DeleteTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue") + +read, err := client.DeleteVnetConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue") + +read, err := client.DeleteVnetConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeployWorkflowArtifacts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.WorkflowArtifacts{ + // ... +} + + +read, err := client.DeployWorkflowArtifacts(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeployWorkflowArtifactsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.WorkflowArtifacts{ + // ... +} + + +read, err := client.DeployWorkflowArtifactsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DiscoverBackup` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.RestoreRequest{ + // ... +} + + +read, err := client.DiscoverBackup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DiscoverBackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.RestoreRequest{ + // ... +} + + +read, err := client.DiscoverBackupSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GenerateNewSitePublishingPassword` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GenerateNewSitePublishingPassword(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GenerateNewSitePublishingPasswordSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GenerateNewSitePublishingPasswordSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +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: `WebAppsClient.GetAppSettingKeyVaultReference` + +```go +ctx := context.TODO() +id := webapps.NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "appSettingKeyValue") + +read, err := client.GetAppSettingKeyVaultReference(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingKeyVaultReferenceSlot` + +```go +ctx := context.TODO() +id := webapps.NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "appSettingKeyValue") + +read, err := client.GetAppSettingKeyVaultReferenceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingsKeyVaultReferences` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.GetAppSettingsKeyVaultReferences(ctx, id)` can be used to do batched pagination +items, err := client.GetAppSettingsKeyVaultReferencesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingsKeyVaultReferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.GetAppSettingsKeyVaultReferencesSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetAppSettingsKeyVaultReferencesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetAuthSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetAuthSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetAuthSettingsV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2Slot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetAuthSettingsV2Slot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2WithoutSecrets` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetAuthSettingsV2WithoutSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2WithoutSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetAuthSettingsV2WithoutSecretsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetBackupConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetBackupConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupStatus` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "backupIdValue") + +read, err := client.GetBackupStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "backupIdValue") + +read, err := client.GetBackupStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSnapshot` + +```go +ctx := context.TODO() +id := webapps.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "snapshotIdValue") + +read, err := client.GetConfigurationSnapshot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "snapshotIdValue") + +read, err := client.GetConfigurationSnapshotSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContainerLogsZip` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetContainerLogsZip(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContainerLogsZipSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetContainerLogsZipSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "continuousWebJobValue") + +read, err := client.GetContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "continuousWebJobValue") + +read, err := client.GetContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "deploymentValue") + +read, err := client.GetDeployment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "deploymentValue") + +read, err := client.GetDeploymentSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDiagnosticLogsConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetDiagnosticLogsConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDiagnosticLogsConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetDiagnosticLogsConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "domainOwnershipIdentifierValue") + +read, err := client.GetDomainOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "domainOwnershipIdentifierValue") + +read, err := client.GetDomainOwnershipIdentifierSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFtpAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetFtpAllowed(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFtpAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetFtpAllowedSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue") + +read, err := client.GetFunction(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunctionsAdminToken` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetFunctionsAdminToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunctionsAdminTokenSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetFunctionsAdminTokenSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hostNameBindingValue") + +read, err := client.GetHostNameBinding(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hostNameBindingValue") + +read, err := client.GetHostNameBindingSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionNamespaceValue", "relayValue") + +read, err := client.GetHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionNamespaceValue", "relayValue") + +read, err := client.GetHybridConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue") + +read, err := client.GetInstanceFunctionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceInfo` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue") + +read, err := client.GetInstanceInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceInfoSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue") + +read, err := client.GetInstanceInfoSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMSDeployLog` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue") + +read, err := client.GetInstanceMSDeployLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMSDeployLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue") + +read, err := client.GetInstanceMSDeployLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMsDeployStatus` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue") + +read, err := client.GetInstanceMsDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMsDeployStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue") + +read, err := client.GetInstanceMsDeployStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcess` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue") + +read, err := client.GetInstanceProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessDump` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue") + +read, err := client.GetInstanceProcessDump(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessDumpSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue") + +read, err := client.GetInstanceProcessDumpSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessModule` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue", "moduleValue") + +read, err := client.GetInstanceProcessModule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessModuleSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue", "moduleValue") + +read, err := client.GetInstanceProcessModuleSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue") + +read, err := client.GetInstanceProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceWorkflowSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "workflowValue") + +read, err := client.GetInstanceWorkflowSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployLog` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetMSDeployLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetMSDeployLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetMSDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetMSDeployStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMigrateMySqlStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetMigrateMySqlStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMigrateMySqlStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetMigrateMySqlStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTraces` + +```go +ctx := context.TODO() +id := webapps.NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "operationIdValue") + +read, err := client.GetNetworkTraces(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "operationIdValue") + +read, err := client.GetNetworkTracesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesSlotV2` + +```go +ctx := context.TODO() +id := webapps.NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "operationIdValue") + +read, err := client.GetNetworkTracesSlotV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesV2` + +```go +ctx := context.TODO() +id := webapps.NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "operationIdValue") + +read, err := client.GetNetworkTracesV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetOneDeployStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetOneDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "premierAddonValue") + +read, err := client.GetPremierAddOn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "premierAddonValue") + +read, err := client.GetPremierAddOnSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateAccess` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetPrivateAccess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateAccessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetPrivateAccessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "privateEndpointConnectionValue") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionListSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.GetPrivateEndpointConnectionListSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "privateEndpointConnectionValue") + +read, err := client.GetPrivateEndpointConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateLinkResourcesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetPrivateLinkResourcesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcess` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue") + +read, err := client.GetProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessDump` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue") + +read, err := client.GetProcessDump(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessDumpSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue") + +read, err := client.GetProcessDumpSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessModule` + +```go +ctx := context.TODO() +id := webapps.NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue", "moduleValue") + +read, err := client.GetProcessModule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessModuleSlot` + +```go +ctx := context.TODO() +id := webapps.NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue", "moduleValue") + +read, err := client.GetProcessModuleSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue") + +read, err := client.GetProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "publicCertificateValue") + +read, err := client.GetPublicCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "publicCertificateValue") + +read, err := client.GetPublicCertificateSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionValue") + +read, err := client.GetRelayServiceConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionValue") + +read, err := client.GetRelayServiceConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetScmAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetScmAllowed(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetScmAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetScmAllowedSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReference` + +```go +ctx := context.TODO() +id := webapps.NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "connectionStringKeyValue") + +read, err := client.GetSiteConnectionStringKeyVaultReference(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferenceSlot` + +```go +ctx := context.TODO() +id := webapps.NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "connectionStringKeyValue") + +read, err := client.GetSiteConnectionStringKeyVaultReferenceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferences` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.GetSiteConnectionStringKeyVaultReferences(ctx, id)` can be used to do batched pagination +items, err := client.GetSiteConnectionStringKeyVaultReferencesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.GetSiteConnectionStringKeyVaultReferencesSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "sitecontainerValue") + +read, err := client.GetSiteContainer(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "sitecontainerValue") + +read, err := client.GetSiteContainerSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "siteExtensionIdValue") + +read, err := client.GetSiteExtension(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "siteExtensionIdValue") + +read, err := client.GetSiteExtensionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSitePhpErrorLogFlag` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetSitePhpErrorLogFlag(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSitePhpErrorLogFlagSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetSitePhpErrorLogFlagSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetSourceControl(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetSourceControlSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSwiftVirtualNetworkConnection` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetSwiftVirtualNetworkConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSwiftVirtualNetworkConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue") + +read, err := client.GetTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobHistory` + +```go +ctx := context.TODO() +id := webapps.NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue", "historyValue") + +read, err := client.GetTriggeredWebJobHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobHistorySlot` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue", "historyValue") + +read, err := client.GetTriggeredWebJobHistorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue") + +read, err := client.GetTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue") + +read, err := client.GetVnetConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue", "gatewayValue") + +read, err := client.GetVnetConnectionGateway(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue", "gatewayValue") + +read, err := client.GetVnetConnectionGatewaySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue") + +read, err := client.GetVnetConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebJob` + +```go +ctx := context.TODO() +id := webapps.NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "webJobValue") + +read, err := client.GetWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "webJobValue") + +read, err := client.GetWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebSiteContainerLogs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.GetWebSiteContainerLogs(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebSiteContainerLogsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.GetWebSiteContainerLogsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWorkflow` + +```go +ctx := context.TODO() +id := webapps.NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + +read, err := client.GetWorkflow(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.InstallSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "siteExtensionIdValue") + +if err := client.InstallSiteExtensionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.InstallSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "siteExtensionIdValue") + +if err := client.InstallSiteExtensionSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.IsCloneable` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.IsCloneable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.IsCloneableSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.IsCloneableSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// 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: `WebAppsClient.ListApplicationSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListApplicationSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListApplicationSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListApplicationSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListAzureStorageAccounts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListAzureStorageAccounts(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListAzureStorageAccountsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListAzureStorageAccountsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackupStatusSecrets` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "backupIdValue") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.ListBackupStatusSecrets(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackupStatusSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "backupIdValue") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.ListBackupStatusSecretsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackups` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListBackups(ctx, id)` can be used to do batched pagination +items, err := client.ListBackupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBackupsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListBackupsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBackupsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBasicPublishingCredentialsPolicies` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListBasicPublishingCredentialsPolicies(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicPublishingCredentialsPoliciesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBasicPublishingCredentialsPoliciesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListBasicPublishingCredentialsPoliciesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicPublishingCredentialsPoliciesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, webapps.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, webapps.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationSnapshotInfo` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListConfigurationSnapshotInfo(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationSnapshotInfoComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationSnapshotInfoSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListConfigurationSnapshotInfoSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationSnapshotInfoSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurations` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListConfigurations(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListConfigurationsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConnectionStrings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListConnectionStrings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListConnectionStringsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListConnectionStringsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListContinuousWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListContinuousWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListContinuousWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListContinuousWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListContinuousWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListContinuousWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentLog` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "deploymentValue") + +read, err := client.ListDeploymentLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "deploymentValue") + +read, err := client.ListDeploymentLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListDeployments` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListDeployments(ctx, id)` can be used to do batched pagination +items, err := client.ListDeploymentsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListDeploymentsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListDeploymentsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDomainOwnershipIdentifiers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListDomainOwnershipIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListDomainOwnershipIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDomainOwnershipIdentifiersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListDomainOwnershipIdentifiersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListDomainOwnershipIdentifiersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionKeys` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue") + +read, err := client.ListFunctionKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionKeysSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue") + +read, err := client.ListFunctionKeysSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionSecrets` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue") + +read, err := client.ListFunctionSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue") + +read, err := client.ListFunctionSecretsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHostKeys` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListHostKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHostKeysSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListHostKeysSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHostNameBindings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListHostNameBindings(ctx, id)` can be used to do batched pagination +items, err := client.ListHostNameBindingsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHostNameBindingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListHostNameBindingsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListHostNameBindingsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHybridConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListHybridConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHybridConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListHybridConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceFunctionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListInstanceFunctionsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceFunctionsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceIdentifiers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListInstanceIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceIdentifiersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListInstanceIdentifiersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceIdentifiersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessModules` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue") + +// alternatively `client.ListInstanceProcessModules(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessModulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessModulesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue") + +// alternatively `client.ListInstanceProcessModulesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessModulesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessThreads` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue") + +// alternatively `client.ListInstanceProcessThreads(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessThreadsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessThreadsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue") + +// alternatively `client.ListInstanceProcessThreadsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessThreadsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcesses` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue") + +// alternatively `client.ListInstanceProcesses(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue") + +// alternatively `client.ListInstanceProcessesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceWorkflowsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListInstanceWorkflowsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceWorkflowsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListMetadata` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListMetadata(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListMetadataSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListMetadataSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListNetworkFeatures` + +```go +ctx := context.TODO() +id := webapps.NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "networkFeatureValue") + +read, err := client.ListNetworkFeatures(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListNetworkFeaturesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "networkFeatureValue") + +read, err := client.ListNetworkFeaturesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPerfMonCounters` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListPerfMonCounters(ctx, id, webapps.DefaultListPerfMonCountersOperationOptions())` can be used to do batched pagination +items, err := client.ListPerfMonCountersComplete(ctx, id, webapps.DefaultListPerfMonCountersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPerfMonCountersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListPerfMonCountersSlot(ctx, id, webapps.DefaultListPerfMonCountersSlotOperationOptions())` can be used to do batched pagination +items, err := client.ListPerfMonCountersSlotComplete(ctx, id, webapps.DefaultListPerfMonCountersSlotOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPremierAddOns` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListPremierAddOns(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPremierAddOnsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListPremierAddOnsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListProcessModules` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue") + +// alternatively `client.ListProcessModules(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessModulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessModulesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue") + +// alternatively `client.ListProcessModulesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessModulesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessThreads` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue") + +// alternatively `client.ListProcessThreads(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessThreadsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessThreadsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue") + +// alternatively `client.ListProcessThreadsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessThreadsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcesses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListProcesses(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListProcessesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProductionSiteDeploymentStatuses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListProductionSiteDeploymentStatuses(ctx, id)` can be used to do batched pagination +items, err := client.ListProductionSiteDeploymentStatusesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublicCertificates` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListPublicCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListPublicCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublicCertificatesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListPublicCertificatesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListPublicCertificatesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingCredentials` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +if err := client.ListPublishingCredentialsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingCredentialsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +if err := client.ListPublishingCredentialsSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingProfileXmlWithSecrets` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.CsmPublishingProfileOptions{ + // ... +} + + +read, err := client.ListPublishingProfileXmlWithSecrets(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingProfileXmlWithSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.CsmPublishingProfileOptions{ + // ... +} + + +read, err := client.ListPublishingProfileXmlWithSecretsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListRelayServiceConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListRelayServiceConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListRelayServiceConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListRelayServiceConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSiteBackups` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSiteBackups(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteBackupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteBackupsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSiteBackupsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteBackupsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteContainers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSiteContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteContainersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSiteContainersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteContainersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteExtensions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSiteExtensions(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteExtensionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteExtensionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSiteExtensionsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteExtensionsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSitePushSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListSitePushSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSitePushSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListSitePushSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSlotConfigurationNames` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListSlotConfigurationNames(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSlotDifferencesFromProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +// alternatively `client.ListSlotDifferencesFromProduction(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSlotDifferencesFromProductionComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlotDifferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +// alternatively `client.ListSlotDifferencesSlot(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSlotDifferencesSlotComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlotSiteDeploymentStatusesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSlotSiteDeploymentStatusesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSlotSiteDeploymentStatusesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlots` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSlots(ctx, id)` can be used to do batched pagination +items, err := client.ListSlotsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshots` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSnapshots(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsFromDRSecondary` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListSnapshotsFromDRSecondary(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsFromDRSecondaryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsFromDRSecondarySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSnapshotsFromDRSecondarySlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsFromDRSecondarySlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListSnapshotsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSyncFunctionTriggers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListSyncFunctionTriggers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncFunctionTriggersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListSyncFunctionTriggersSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListSyncStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListSyncStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobHistory` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue") + +// alternatively `client.ListTriggeredWebJobHistory(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobHistoryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobHistorySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue") + +// alternatively `client.ListTriggeredWebJobHistorySlot(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobHistorySlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListTriggeredWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListTriggeredWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListUsages(ctx, id, webapps.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, webapps.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListUsagesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListUsagesSlot(ctx, id, webapps.DefaultListUsagesSlotOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesSlotComplete(ctx, id, webapps.DefaultListUsagesSlotOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListVnetConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListVnetConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListVnetConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListVnetConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +// alternatively `client.ListWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflows` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +// alternatively `client.ListWorkflows(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkflowsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflowsConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ListWorkflowsConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflowsConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ListWorkflowsConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.MigrateMySql` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.MigrateMySqlRequest{ + // ... +} + + +if err := client.MigrateMySqlThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.MigrateStorage` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.StorageMigrationOptions{ + // ... +} + + +if err := client.MigrateStorageThenPoll(ctx, id, payload, webapps.DefaultMigrateStorageOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.PutPrivateAccessVnet` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.PrivateAccess{ + // ... +} + + +read, err := client.PutPrivateAccessVnet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.PutPrivateAccessVnetSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.PrivateAccess{ + // ... +} + + +read, err := client.PutPrivateAccessVnetSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RecoverSiteConfigurationSnapshot` + +```go +ctx := context.TODO() +id := webapps.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "snapshotIdValue") + +read, err := client.RecoverSiteConfigurationSnapshot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RecoverSiteConfigurationSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "snapshotIdValue") + +read, err := client.RecoverSiteConfigurationSnapshotSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ResetProductionSlotConfig` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.ResetProductionSlotConfig(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ResetSlotConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.ResetSlotConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Restart` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.Restart(ctx, id, webapps.DefaultRestartOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RestartSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.RestartSlot(ctx, id, webapps.DefaultRestartSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Restore` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "backupIdValue") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromBackupBlob` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreFromBackupBlobThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromBackupBlobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreFromBackupBlobSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromDeletedApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.DeletedAppRestoreRequest{ + // ... +} + + +if err := client.RestoreFromDeletedAppThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromDeletedAppSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.DeletedAppRestoreRequest{ + // ... +} + + +if err := client.RestoreFromDeletedAppSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "backupIdValue") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSnapshot` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SnapshotRestoreRequest{ + // ... +} + + +if err := client.RestoreSnapshotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SnapshotRestoreRequest{ + // ... +} + + +if err := client.RestoreSnapshotSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RunTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue") + +read, err := client.RunTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RunTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue") + +read, err := client.RunTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Start` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.Start(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "continuousWebJobValue") + +read, err := client.StartContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "continuousWebJobValue") + +read, err := client.StartContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +if err := client.StartNetworkTraceThenPoll(ctx, id, webapps.DefaultStartNetworkTraceOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +if err := client.StartNetworkTraceSlotThenPoll(ctx, id, webapps.DefaultStartNetworkTraceSlotOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.StartSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.StartWebSiteNetworkTrace(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +if err := client.StartWebSiteNetworkTraceOperationThenPoll(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +if err := client.StartWebSiteNetworkTraceOperationSlotThenPoll(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.StartWebSiteNetworkTraceSlot(ctx, id, webapps.DefaultStartWebSiteNetworkTraceSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Stop` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.Stop(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "continuousWebJobValue") + +read, err := client.StopContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "continuousWebJobValue") + +read, err := client.StopContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.StopNetworkTrace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.StopNetworkTraceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.StopSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopWebSiteNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.StopWebSiteNetworkTrace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopWebSiteNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.StopWebSiteNetworkTraceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SwapSlotSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +if err := client.SwapSlotSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.SwapSlotWithProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +if err := client.SwapSlotWithProductionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionTriggers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.SyncFunctionTriggers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionTriggersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.SyncFunctionTriggersSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.SyncFunctions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.SyncFunctionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncRepository` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +read, err := client.SyncRepository(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncRepositorySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +read, err := client.SyncRepositorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SitePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateApplicationSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateApplicationSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateApplicationSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateApplicationSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SiteAuthSettings{ + // ... +} + + +read, err := client.UpdateAuthSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SiteAuthSettings{ + // ... +} + + +read, err := client.UpdateAuthSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsV2` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SiteAuthSettingsV2{ + // ... +} + + +read, err := client.UpdateAuthSettingsV2(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsV2Slot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SiteAuthSettingsV2{ + // ... +} + + +read, err := client.UpdateAuthSettingsV2Slot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAzureStorageAccounts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.AzureStoragePropertyDictionaryResource{ + // ... +} + + +read, err := client.UpdateAzureStorageAccounts(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAzureStorageAccountsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.AzureStoragePropertyDictionaryResource{ + // ... +} + + +read, err := client.UpdateAzureStorageAccountsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.UpdateBackupConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.UpdateBackupConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.UpdateConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.UpdateConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConnectionStrings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.ConnectionStringDictionary{ + // ... +} + + +read, err := client.UpdateConnectionStrings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConnectionStringsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.ConnectionStringDictionary{ + // ... +} + + +read, err := client.UpdateConnectionStringsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDiagnosticLogsConfig` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SiteLogsConfig{ + // ... +} + + +read, err := client.UpdateDiagnosticLogsConfig(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDiagnosticLogsConfigSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SiteLogsConfig{ + // ... +} + + +read, err := client.UpdateDiagnosticLogsConfigSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "domainOwnershipIdentifierValue") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.UpdateDomainOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "domainOwnershipIdentifierValue") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.UpdateDomainOwnershipIdentifierSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateFtpAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateFtpAllowed(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateFtpAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateFtpAllowedSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionNamespaceValue", "relayValue") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.UpdateHybridConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionNamespaceValue", "relayValue") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.UpdateHybridConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMetadata` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateMetadata(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMetadataSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateMetadataSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdatePremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "premierAddonValue") + +payload := webapps.PremierAddOnPatchResource{ + // ... +} + + +read, err := client.UpdatePremierAddOn(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdatePremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "premierAddonValue") + +payload := webapps.PremierAddOnPatchResource{ + // ... +} + + +read, err := client.UpdatePremierAddOnSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionValue") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.UpdateRelayServiceConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionValue") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.UpdateRelayServiceConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateScmAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateScmAllowed(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateScmAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateScmAllowedSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSitePushSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.PushSettings{ + // ... +} + + +read, err := client.UpdateSitePushSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSitePushSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.PushSettings{ + // ... +} + + +read, err := client.UpdateSitePushSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SitePatchResource{ + // ... +} + + +read, err := client.UpdateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSlotConfigurationNames` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SlotConfigNamesResource{ + // ... +} + + +read, err := client.UpdateSlotConfigurationNames(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SiteSourceControl{ + // ... +} + + +read, err := client.UpdateSourceControl(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SiteSourceControl{ + // ... +} + + +read, err := client.UpdateSourceControlSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSwiftVirtualNetworkConnectionWithCheck` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.UpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSwiftVirtualNetworkConnectionWithCheckSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.UpdateVnetConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue", "gatewayValue") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetConnectionGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue", "gatewayValue") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetConnectionGatewaySlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.UpdateVnetConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2023-12-01/webapps/client.go b/resource-manager/web/2023-12-01/webapps/client.go new file mode 100644 index 00000000000..5b73caa6cf9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/client.go @@ -0,0 +1,26 @@ +package webapps + +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 WebAppsClient struct { + Client *resourcemanager.Client +} + +func NewWebAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*WebAppsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "webapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebAppsClient: %+v", err) + } + + return &WebAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/webapps/constants.go b/resource-manager/web/2023-12-01/webapps/constants.go new file mode 100644 index 00000000000..89e6814a97c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/constants.go @@ -0,0 +1,2725 @@ +package webapps + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthType string + +const ( + AuthTypeAnonymous AuthType = "Anonymous" + AuthTypeSystemIdentity AuthType = "SystemIdentity" + AuthTypeUserAssigned AuthType = "UserAssigned" + AuthTypeUserCredentials AuthType = "UserCredentials" +) + +func PossibleValuesForAuthType() []string { + return []string{ + string(AuthTypeAnonymous), + string(AuthTypeSystemIdentity), + string(AuthTypeUserAssigned), + string(AuthTypeUserCredentials), + } +} + +func (s *AuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthType(input string) (*AuthType, error) { + vals := map[string]AuthType{ + "anonymous": AuthTypeAnonymous, + "systemidentity": AuthTypeSystemIdentity, + "userassigned": AuthTypeUserAssigned, + "usercredentials": AuthTypeUserCredentials, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthType(input) + return &out, nil +} + +type AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureResourceType string + +const ( + AzureResourceTypeTrafficManager AzureResourceType = "TrafficManager" + AzureResourceTypeWebsite AzureResourceType = "Website" +) + +func PossibleValuesForAzureResourceType() []string { + return []string{ + string(AzureResourceTypeTrafficManager), + string(AzureResourceTypeWebsite), + } +} + +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceType(input string) (*AzureResourceType, error) { + vals := map[string]AzureResourceType{ + "trafficmanager": AzureResourceTypeTrafficManager, + "website": AzureResourceTypeWebsite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type BackupItemStatus string + +const ( + BackupItemStatusCreated BackupItemStatus = "Created" + BackupItemStatusDeleteFailed BackupItemStatus = "DeleteFailed" + BackupItemStatusDeleteInProgress BackupItemStatus = "DeleteInProgress" + BackupItemStatusDeleted BackupItemStatus = "Deleted" + BackupItemStatusFailed BackupItemStatus = "Failed" + BackupItemStatusInProgress BackupItemStatus = "InProgress" + BackupItemStatusPartiallySucceeded BackupItemStatus = "PartiallySucceeded" + BackupItemStatusSkipped BackupItemStatus = "Skipped" + BackupItemStatusSucceeded BackupItemStatus = "Succeeded" + BackupItemStatusTimedOut BackupItemStatus = "TimedOut" +) + +func PossibleValuesForBackupItemStatus() []string { + return []string{ + string(BackupItemStatusCreated), + string(BackupItemStatusDeleteFailed), + string(BackupItemStatusDeleteInProgress), + string(BackupItemStatusDeleted), + string(BackupItemStatusFailed), + string(BackupItemStatusInProgress), + string(BackupItemStatusPartiallySucceeded), + string(BackupItemStatusSkipped), + string(BackupItemStatusSucceeded), + string(BackupItemStatusTimedOut), + } +} + +func (s *BackupItemStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupItemStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupItemStatus(input string) (*BackupItemStatus, error) { + vals := map[string]BackupItemStatus{ + "created": BackupItemStatusCreated, + "deletefailed": BackupItemStatusDeleteFailed, + "deleteinprogress": BackupItemStatusDeleteInProgress, + "deleted": BackupItemStatusDeleted, + "failed": BackupItemStatusFailed, + "inprogress": BackupItemStatusInProgress, + "partiallysucceeded": BackupItemStatusPartiallySucceeded, + "skipped": BackupItemStatusSkipped, + "succeeded": BackupItemStatusSucceeded, + "timedout": BackupItemStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupItemStatus(input) + return &out, nil +} + +type BackupRestoreOperationType string + +const ( + BackupRestoreOperationTypeClone BackupRestoreOperationType = "Clone" + BackupRestoreOperationTypeCloudFS BackupRestoreOperationType = "CloudFS" + BackupRestoreOperationTypeDefault BackupRestoreOperationType = "Default" + BackupRestoreOperationTypeRelocation BackupRestoreOperationType = "Relocation" + BackupRestoreOperationTypeSnapshot BackupRestoreOperationType = "Snapshot" +) + +func PossibleValuesForBackupRestoreOperationType() []string { + return []string{ + string(BackupRestoreOperationTypeClone), + string(BackupRestoreOperationTypeCloudFS), + string(BackupRestoreOperationTypeDefault), + string(BackupRestoreOperationTypeRelocation), + string(BackupRestoreOperationTypeSnapshot), + } +} + +func (s *BackupRestoreOperationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationType(input string) (*BackupRestoreOperationType, error) { + vals := map[string]BackupRestoreOperationType{ + "clone": BackupRestoreOperationTypeClone, + "cloudfs": BackupRestoreOperationTypeCloudFS, + "default": BackupRestoreOperationTypeDefault, + "relocation": BackupRestoreOperationTypeRelocation, + "snapshot": BackupRestoreOperationTypeSnapshot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationType(input) + return &out, nil +} + +type BuiltInAuthenticationProvider string + +const ( + BuiltInAuthenticationProviderAzureActiveDirectory BuiltInAuthenticationProvider = "AzureActiveDirectory" + BuiltInAuthenticationProviderFacebook BuiltInAuthenticationProvider = "Facebook" + BuiltInAuthenticationProviderGithub BuiltInAuthenticationProvider = "Github" + BuiltInAuthenticationProviderGoogle BuiltInAuthenticationProvider = "Google" + BuiltInAuthenticationProviderMicrosoftAccount BuiltInAuthenticationProvider = "MicrosoftAccount" + BuiltInAuthenticationProviderTwitter BuiltInAuthenticationProvider = "Twitter" +) + +func PossibleValuesForBuiltInAuthenticationProvider() []string { + return []string{ + string(BuiltInAuthenticationProviderAzureActiveDirectory), + string(BuiltInAuthenticationProviderFacebook), + string(BuiltInAuthenticationProviderGithub), + string(BuiltInAuthenticationProviderGoogle), + string(BuiltInAuthenticationProviderMicrosoftAccount), + string(BuiltInAuthenticationProviderTwitter), + } +} + +func (s *BuiltInAuthenticationProvider) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuiltInAuthenticationProvider(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBuiltInAuthenticationProvider(input string) (*BuiltInAuthenticationProvider, error) { + vals := map[string]BuiltInAuthenticationProvider{ + "azureactivedirectory": BuiltInAuthenticationProviderAzureActiveDirectory, + "facebook": BuiltInAuthenticationProviderFacebook, + "github": BuiltInAuthenticationProviderGithub, + "google": BuiltInAuthenticationProviderGoogle, + "microsoftaccount": BuiltInAuthenticationProviderMicrosoftAccount, + "twitter": BuiltInAuthenticationProviderTwitter, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BuiltInAuthenticationProvider(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ClientCredentialMethod string + +const ( + ClientCredentialMethodClientSecretPost ClientCredentialMethod = "ClientSecretPost" +) + +func PossibleValuesForClientCredentialMethod() []string { + return []string{ + string(ClientCredentialMethodClientSecretPost), + } +} + +func (s *ClientCredentialMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCredentialMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCredentialMethod(input string) (*ClientCredentialMethod, error) { + vals := map[string]ClientCredentialMethod{ + "clientsecretpost": ClientCredentialMethodClientSecretPost, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCredentialMethod(input) + return &out, nil +} + +type CloneAbilityResult string + +const ( + CloneAbilityResultCloneable CloneAbilityResult = "Cloneable" + CloneAbilityResultNotCloneable CloneAbilityResult = "NotCloneable" + CloneAbilityResultPartiallyCloneable CloneAbilityResult = "PartiallyCloneable" +) + +func PossibleValuesForCloneAbilityResult() []string { + return []string{ + string(CloneAbilityResultCloneable), + string(CloneAbilityResultNotCloneable), + string(CloneAbilityResultPartiallyCloneable), + } +} + +func (s *CloneAbilityResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloneAbilityResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloneAbilityResult(input string) (*CloneAbilityResult, error) { + vals := map[string]CloneAbilityResult{ + "cloneable": CloneAbilityResultCloneable, + "notcloneable": CloneAbilityResultNotCloneable, + "partiallycloneable": CloneAbilityResultPartiallyCloneable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloneAbilityResult(input) + return &out, nil +} + +type ConfigReferenceSource string + +const ( + ConfigReferenceSourceKeyVault ConfigReferenceSource = "KeyVault" +) + +func PossibleValuesForConfigReferenceSource() []string { + return []string{ + string(ConfigReferenceSourceKeyVault), + } +} + +func (s *ConfigReferenceSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigReferenceSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConfigReferenceSource(input string) (*ConfigReferenceSource, error) { + vals := map[string]ConfigReferenceSource{ + "keyvault": ConfigReferenceSourceKeyVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConfigReferenceSource(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type ContinuousWebJobStatus string + +const ( + ContinuousWebJobStatusInitializing ContinuousWebJobStatus = "Initializing" + ContinuousWebJobStatusPendingRestart ContinuousWebJobStatus = "PendingRestart" + ContinuousWebJobStatusRunning ContinuousWebJobStatus = "Running" + ContinuousWebJobStatusStarting ContinuousWebJobStatus = "Starting" + ContinuousWebJobStatusStopped ContinuousWebJobStatus = "Stopped" +) + +func PossibleValuesForContinuousWebJobStatus() []string { + return []string{ + string(ContinuousWebJobStatusInitializing), + string(ContinuousWebJobStatusPendingRestart), + string(ContinuousWebJobStatusRunning), + string(ContinuousWebJobStatusStarting), + string(ContinuousWebJobStatusStopped), + } +} + +func (s *ContinuousWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContinuousWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContinuousWebJobStatus(input string) (*ContinuousWebJobStatus, error) { + vals := map[string]ContinuousWebJobStatus{ + "initializing": ContinuousWebJobStatusInitializing, + "pendingrestart": ContinuousWebJobStatusPendingRestart, + "running": ContinuousWebJobStatusRunning, + "starting": ContinuousWebJobStatusStarting, + "stopped": ContinuousWebJobStatusStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContinuousWebJobStatus(input) + return &out, nil +} + +type CookieExpirationConvention string + +const ( + CookieExpirationConventionFixedTime CookieExpirationConvention = "FixedTime" + CookieExpirationConventionIdentityProviderDerived CookieExpirationConvention = "IdentityProviderDerived" +) + +func PossibleValuesForCookieExpirationConvention() []string { + return []string{ + string(CookieExpirationConventionFixedTime), + string(CookieExpirationConventionIdentityProviderDerived), + } +} + +func (s *CookieExpirationConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCookieExpirationConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCookieExpirationConvention(input string) (*CookieExpirationConvention, error) { + vals := map[string]CookieExpirationConvention{ + "fixedtime": CookieExpirationConventionFixedTime, + "identityproviderderived": CookieExpirationConventionIdentityProviderDerived, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CookieExpirationConvention(input) + return &out, nil +} + +type CustomHostNameDnsRecordType string + +const ( + CustomHostNameDnsRecordTypeA CustomHostNameDnsRecordType = "A" + CustomHostNameDnsRecordTypeCName CustomHostNameDnsRecordType = "CName" +) + +func PossibleValuesForCustomHostNameDnsRecordType() []string { + return []string{ + string(CustomHostNameDnsRecordTypeA), + string(CustomHostNameDnsRecordTypeCName), + } +} + +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { + vals := map[string]CustomHostNameDnsRecordType{ + "a": CustomHostNameDnsRecordTypeA, + "cname": CustomHostNameDnsRecordTypeCName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHostNameDnsRecordType(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DatabaseType string + +const ( + DatabaseTypeLocalMySql DatabaseType = "LocalMySql" + DatabaseTypeMySql DatabaseType = "MySql" + DatabaseTypePostgreSql DatabaseType = "PostgreSql" + DatabaseTypeSqlAzure DatabaseType = "SqlAzure" +) + +func PossibleValuesForDatabaseType() []string { + return []string{ + string(DatabaseTypeLocalMySql), + string(DatabaseTypeMySql), + string(DatabaseTypePostgreSql), + string(DatabaseTypeSqlAzure), + } +} + +func (s *DatabaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseType(input string) (*DatabaseType, error) { + vals := map[string]DatabaseType{ + "localmysql": DatabaseTypeLocalMySql, + "mysql": DatabaseTypeMySql, + "postgresql": DatabaseTypePostgreSql, + "sqlazure": DatabaseTypeSqlAzure, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseType(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type DeploymentBuildStatus string + +const ( + DeploymentBuildStatusBuildAborted DeploymentBuildStatus = "BuildAborted" + DeploymentBuildStatusBuildFailed DeploymentBuildStatus = "BuildFailed" + DeploymentBuildStatusBuildInProgress DeploymentBuildStatus = "BuildInProgress" + DeploymentBuildStatusBuildPending DeploymentBuildStatus = "BuildPending" + DeploymentBuildStatusBuildRequestReceived DeploymentBuildStatus = "BuildRequestReceived" + DeploymentBuildStatusBuildSuccessful DeploymentBuildStatus = "BuildSuccessful" + DeploymentBuildStatusPostBuildRestartRequired DeploymentBuildStatus = "PostBuildRestartRequired" + DeploymentBuildStatusRuntimeFailed DeploymentBuildStatus = "RuntimeFailed" + DeploymentBuildStatusRuntimeStarting DeploymentBuildStatus = "RuntimeStarting" + DeploymentBuildStatusRuntimeSuccessful DeploymentBuildStatus = "RuntimeSuccessful" + DeploymentBuildStatusStartPolling DeploymentBuildStatus = "StartPolling" + DeploymentBuildStatusStartPollingWithRestart DeploymentBuildStatus = "StartPollingWithRestart" + DeploymentBuildStatusTimedOut DeploymentBuildStatus = "TimedOut" +) + +func PossibleValuesForDeploymentBuildStatus() []string { + return []string{ + string(DeploymentBuildStatusBuildAborted), + string(DeploymentBuildStatusBuildFailed), + string(DeploymentBuildStatusBuildInProgress), + string(DeploymentBuildStatusBuildPending), + string(DeploymentBuildStatusBuildRequestReceived), + string(DeploymentBuildStatusBuildSuccessful), + string(DeploymentBuildStatusPostBuildRestartRequired), + string(DeploymentBuildStatusRuntimeFailed), + string(DeploymentBuildStatusRuntimeStarting), + string(DeploymentBuildStatusRuntimeSuccessful), + string(DeploymentBuildStatusStartPolling), + string(DeploymentBuildStatusStartPollingWithRestart), + string(DeploymentBuildStatusTimedOut), + } +} + +func (s *DeploymentBuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentBuildStatus(input string) (*DeploymentBuildStatus, error) { + vals := map[string]DeploymentBuildStatus{ + "buildaborted": DeploymentBuildStatusBuildAborted, + "buildfailed": DeploymentBuildStatusBuildFailed, + "buildinprogress": DeploymentBuildStatusBuildInProgress, + "buildpending": DeploymentBuildStatusBuildPending, + "buildrequestreceived": DeploymentBuildStatusBuildRequestReceived, + "buildsuccessful": DeploymentBuildStatusBuildSuccessful, + "postbuildrestartrequired": DeploymentBuildStatusPostBuildRestartRequired, + "runtimefailed": DeploymentBuildStatusRuntimeFailed, + "runtimestarting": DeploymentBuildStatusRuntimeStarting, + "runtimesuccessful": DeploymentBuildStatusRuntimeSuccessful, + "startpolling": DeploymentBuildStatusStartPolling, + "startpollingwithrestart": DeploymentBuildStatusStartPollingWithRestart, + "timedout": DeploymentBuildStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentBuildStatus(input) + return &out, nil +} + +type DnsVerificationTestResult string + +const ( + DnsVerificationTestResultFailed DnsVerificationTestResult = "Failed" + DnsVerificationTestResultPassed DnsVerificationTestResult = "Passed" + DnsVerificationTestResultSkipped DnsVerificationTestResult = "Skipped" +) + +func PossibleValuesForDnsVerificationTestResult() []string { + return []string{ + string(DnsVerificationTestResultFailed), + string(DnsVerificationTestResultPassed), + string(DnsVerificationTestResultSkipped), + } +} + +func (s *DnsVerificationTestResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsVerificationTestResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsVerificationTestResult(input string) (*DnsVerificationTestResult, error) { + vals := map[string]DnsVerificationTestResult{ + "failed": DnsVerificationTestResultFailed, + "passed": DnsVerificationTestResultPassed, + "skipped": DnsVerificationTestResultSkipped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsVerificationTestResult(input) + return &out, nil +} + +type ForwardProxyConvention string + +const ( + ForwardProxyConventionCustom ForwardProxyConvention = "Custom" + ForwardProxyConventionNoProxy ForwardProxyConvention = "NoProxy" + ForwardProxyConventionStandard ForwardProxyConvention = "Standard" +) + +func PossibleValuesForForwardProxyConvention() []string { + return []string{ + string(ForwardProxyConventionCustom), + string(ForwardProxyConventionNoProxy), + string(ForwardProxyConventionStandard), + } +} + +func (s *ForwardProxyConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardProxyConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForwardProxyConvention(input string) (*ForwardProxyConvention, error) { + vals := map[string]ForwardProxyConvention{ + "custom": ForwardProxyConventionCustom, + "noproxy": ForwardProxyConventionNoProxy, + "standard": ForwardProxyConventionStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForwardProxyConvention(input) + return &out, nil +} + +type FrequencyUnit string + +const ( + FrequencyUnitDay FrequencyUnit = "Day" + FrequencyUnitHour FrequencyUnit = "Hour" +) + +func PossibleValuesForFrequencyUnit() []string { + return []string{ + string(FrequencyUnitDay), + string(FrequencyUnitHour), + } +} + +func (s *FrequencyUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrequencyUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFrequencyUnit(input string) (*FrequencyUnit, error) { + vals := map[string]FrequencyUnit{ + "day": FrequencyUnitDay, + "hour": FrequencyUnitHour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FrequencyUnit(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type HostNameType string + +const ( + HostNameTypeManaged HostNameType = "Managed" + HostNameTypeVerified HostNameType = "Verified" +) + +func PossibleValuesForHostNameType() []string { + return []string{ + string(HostNameTypeManaged), + string(HostNameTypeVerified), + } +} + +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameType(input string) (*HostNameType, error) { + vals := map[string]HostNameType{ + "managed": HostNameTypeManaged, + "verified": HostNameTypeVerified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameType(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type LogLevel string + +const ( + LogLevelError LogLevel = "Error" + LogLevelInformation LogLevel = "Information" + LogLevelOff LogLevel = "Off" + LogLevelVerbose LogLevel = "Verbose" + LogLevelWarning LogLevel = "Warning" +) + +func PossibleValuesForLogLevel() []string { + return []string{ + string(LogLevelError), + string(LogLevelInformation), + string(LogLevelOff), + string(LogLevelVerbose), + string(LogLevelWarning), + } +} + +func (s *LogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogLevel(input string) (*LogLevel, error) { + vals := map[string]LogLevel{ + "error": LogLevelError, + "information": LogLevelInformation, + "off": LogLevelOff, + "verbose": LogLevelVerbose, + "warning": LogLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogLevel(input) + return &out, nil +} + +type MSDeployLogEntryType string + +const ( + MSDeployLogEntryTypeError MSDeployLogEntryType = "Error" + MSDeployLogEntryTypeMessage MSDeployLogEntryType = "Message" + MSDeployLogEntryTypeWarning MSDeployLogEntryType = "Warning" +) + +func PossibleValuesForMSDeployLogEntryType() []string { + return []string{ + string(MSDeployLogEntryTypeError), + string(MSDeployLogEntryTypeMessage), + string(MSDeployLogEntryTypeWarning), + } +} + +func (s *MSDeployLogEntryType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployLogEntryType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMSDeployLogEntryType(input string) (*MSDeployLogEntryType, error) { + vals := map[string]MSDeployLogEntryType{ + "error": MSDeployLogEntryTypeError, + "message": MSDeployLogEntryTypeMessage, + "warning": MSDeployLogEntryTypeWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MSDeployLogEntryType(input) + return &out, nil +} + +type MSDeployProvisioningState string + +const ( + MSDeployProvisioningStateAccepted MSDeployProvisioningState = "accepted" + MSDeployProvisioningStateCanceled MSDeployProvisioningState = "canceled" + MSDeployProvisioningStateFailed MSDeployProvisioningState = "failed" + MSDeployProvisioningStateRunning MSDeployProvisioningState = "running" + MSDeployProvisioningStateSucceeded MSDeployProvisioningState = "succeeded" +) + +func PossibleValuesForMSDeployProvisioningState() []string { + return []string{ + string(MSDeployProvisioningStateAccepted), + string(MSDeployProvisioningStateCanceled), + string(MSDeployProvisioningStateFailed), + string(MSDeployProvisioningStateRunning), + string(MSDeployProvisioningStateSucceeded), + } +} + +func (s *MSDeployProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMSDeployProvisioningState(input string) (*MSDeployProvisioningState, error) { + vals := map[string]MSDeployProvisioningState{ + "accepted": MSDeployProvisioningStateAccepted, + "canceled": MSDeployProvisioningStateCanceled, + "failed": MSDeployProvisioningStateFailed, + "running": MSDeployProvisioningStateRunning, + "succeeded": MSDeployProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MSDeployProvisioningState(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type MySqlMigrationType string + +const ( + MySqlMigrationTypeLocalToRemote MySqlMigrationType = "LocalToRemote" + MySqlMigrationTypeRemoteToLocal MySqlMigrationType = "RemoteToLocal" +) + +func PossibleValuesForMySqlMigrationType() []string { + return []string{ + string(MySqlMigrationTypeLocalToRemote), + string(MySqlMigrationTypeRemoteToLocal), + } +} + +func (s *MySqlMigrationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMySqlMigrationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMySqlMigrationType(input string) (*MySqlMigrationType, error) { + vals := map[string]MySqlMigrationType{ + "localtoremote": MySqlMigrationTypeLocalToRemote, + "remotetolocal": MySqlMigrationTypeRemoteToLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MySqlMigrationType(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreated OperationStatus = "Created" + OperationStatusFailed OperationStatus = "Failed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusSucceeded OperationStatus = "Succeeded" + OperationStatusTimedOut OperationStatus = "TimedOut" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreated), + string(OperationStatusFailed), + string(OperationStatusInProgress), + string(OperationStatusSucceeded), + string(OperationStatusTimedOut), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "created": OperationStatusCreated, + "failed": OperationStatusFailed, + "inprogress": OperationStatusInProgress, + "succeeded": OperationStatusSucceeded, + "timedout": OperationStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type PublicCertificateLocation string + +const ( + PublicCertificateLocationCurrentUserMy PublicCertificateLocation = "CurrentUserMy" + PublicCertificateLocationLocalMachineMy PublicCertificateLocation = "LocalMachineMy" + PublicCertificateLocationUnknown PublicCertificateLocation = "Unknown" +) + +func PossibleValuesForPublicCertificateLocation() []string { + return []string{ + string(PublicCertificateLocationCurrentUserMy), + string(PublicCertificateLocationLocalMachineMy), + string(PublicCertificateLocationUnknown), + } +} + +func (s *PublicCertificateLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicCertificateLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicCertificateLocation(input string) (*PublicCertificateLocation, error) { + vals := map[string]PublicCertificateLocation{ + "currentusermy": PublicCertificateLocationCurrentUserMy, + "localmachinemy": PublicCertificateLocationLocalMachineMy, + "unknown": PublicCertificateLocationUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicCertificateLocation(input) + return &out, nil +} + +type PublishingProfileFormat string + +const ( + PublishingProfileFormatFileZillaThree PublishingProfileFormat = "FileZilla3" + PublishingProfileFormatFtp PublishingProfileFormat = "Ftp" + PublishingProfileFormatWebDeploy PublishingProfileFormat = "WebDeploy" +) + +func PossibleValuesForPublishingProfileFormat() []string { + return []string{ + string(PublishingProfileFormatFileZillaThree), + string(PublishingProfileFormatFtp), + string(PublishingProfileFormatWebDeploy), + } +} + +func (s *PublishingProfileFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublishingProfileFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublishingProfileFormat(input string) (*PublishingProfileFormat, error) { + vals := map[string]PublishingProfileFormat{ + "filezilla3": PublishingProfileFormatFileZillaThree, + "ftp": PublishingProfileFormatFtp, + "webdeploy": PublishingProfileFormatWebDeploy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublishingProfileFormat(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type ResolveStatus string + +const ( + ResolveStatusAccessToKeyVaultDenied ResolveStatus = "AccessToKeyVaultDenied" + ResolveStatusFetchTimedOut ResolveStatus = "FetchTimedOut" + ResolveStatusInitialized ResolveStatus = "Initialized" + ResolveStatusInvalidSyntax ResolveStatus = "InvalidSyntax" + ResolveStatusMSINotEnabled ResolveStatus = "MSINotEnabled" + ResolveStatusOtherReasons ResolveStatus = "OtherReasons" + ResolveStatusResolved ResolveStatus = "Resolved" + ResolveStatusSecretNotFound ResolveStatus = "SecretNotFound" + ResolveStatusSecretVersionNotFound ResolveStatus = "SecretVersionNotFound" + ResolveStatusUnauthorizedClient ResolveStatus = "UnauthorizedClient" + ResolveStatusVaultNotFound ResolveStatus = "VaultNotFound" +) + +func PossibleValuesForResolveStatus() []string { + return []string{ + string(ResolveStatusAccessToKeyVaultDenied), + string(ResolveStatusFetchTimedOut), + string(ResolveStatusInitialized), + string(ResolveStatusInvalidSyntax), + string(ResolveStatusMSINotEnabled), + string(ResolveStatusOtherReasons), + string(ResolveStatusResolved), + string(ResolveStatusSecretNotFound), + string(ResolveStatusSecretVersionNotFound), + string(ResolveStatusUnauthorizedClient), + string(ResolveStatusVaultNotFound), + } +} + +func (s *ResolveStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResolveStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResolveStatus(input string) (*ResolveStatus, error) { + vals := map[string]ResolveStatus{ + "accesstokeyvaultdenied": ResolveStatusAccessToKeyVaultDenied, + "fetchtimedout": ResolveStatusFetchTimedOut, + "initialized": ResolveStatusInitialized, + "invalidsyntax": ResolveStatusInvalidSyntax, + "msinotenabled": ResolveStatusMSINotEnabled, + "otherreasons": ResolveStatusOtherReasons, + "resolved": ResolveStatusResolved, + "secretnotfound": ResolveStatusSecretNotFound, + "secretversionnotfound": ResolveStatusSecretVersionNotFound, + "unauthorizedclient": ResolveStatusUnauthorizedClient, + "vaultnotfound": ResolveStatusVaultNotFound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResolveStatus(input) + return &out, nil +} + +type RouteType string + +const ( + RouteTypeDefault RouteType = "DEFAULT" + RouteTypeINHERITED RouteType = "INHERITED" + RouteTypeSTATIC RouteType = "STATIC" +) + +func PossibleValuesForRouteType() []string { + return []string{ + string(RouteTypeDefault), + string(RouteTypeINHERITED), + string(RouteTypeSTATIC), + } +} + +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteType(input string) (*RouteType, error) { + vals := map[string]RouteType{ + "default": RouteTypeDefault, + "inherited": RouteTypeINHERITED, + "static": RouteTypeSTATIC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteType(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteExtensionType string + +const ( + SiteExtensionTypeGallery SiteExtensionType = "Gallery" + SiteExtensionTypeWebRoot SiteExtensionType = "WebRoot" +) + +func PossibleValuesForSiteExtensionType() []string { + return []string{ + string(SiteExtensionTypeGallery), + string(SiteExtensionTypeWebRoot), + } +} + +func (s *SiteExtensionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteExtensionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteExtensionType(input string) (*SiteExtensionType, error) { + vals := map[string]SiteExtensionType{ + "gallery": SiteExtensionTypeGallery, + "webroot": SiteExtensionTypeWebRoot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteExtensionType(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SiteRuntimeState string + +const ( + SiteRuntimeStateREADY SiteRuntimeState = "READY" + SiteRuntimeStateSTOPPED SiteRuntimeState = "STOPPED" + SiteRuntimeStateUNKNOWN SiteRuntimeState = "UNKNOWN" +) + +func PossibleValuesForSiteRuntimeState() []string { + return []string{ + string(SiteRuntimeStateREADY), + string(SiteRuntimeStateSTOPPED), + string(SiteRuntimeStateUNKNOWN), + } +} + +func (s *SiteRuntimeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteRuntimeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteRuntimeState(input string) (*SiteRuntimeState, error) { + vals := map[string]SiteRuntimeState{ + "ready": SiteRuntimeStateREADY, + "stopped": SiteRuntimeStateSTOPPED, + "unknown": SiteRuntimeStateUNKNOWN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteRuntimeState(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeBlobContainer StorageType = "blobContainer" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeBlobContainer), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "blobcontainer": StorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type TriggeredWebJobStatus string + +const ( + TriggeredWebJobStatusError TriggeredWebJobStatus = "Error" + TriggeredWebJobStatusFailed TriggeredWebJobStatus = "Failed" + TriggeredWebJobStatusSuccess TriggeredWebJobStatus = "Success" +) + +func PossibleValuesForTriggeredWebJobStatus() []string { + return []string{ + string(TriggeredWebJobStatusError), + string(TriggeredWebJobStatusFailed), + string(TriggeredWebJobStatusSuccess), + } +} + +func (s *TriggeredWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggeredWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggeredWebJobStatus(input string) (*TriggeredWebJobStatus, error) { + vals := map[string]TriggeredWebJobStatus{ + "error": TriggeredWebJobStatusError, + "failed": TriggeredWebJobStatusFailed, + "success": TriggeredWebJobStatusSuccess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggeredWebJobStatus(input) + return &out, nil +} + +type UnauthenticatedClientAction string + +const ( + UnauthenticatedClientActionAllowAnonymous UnauthenticatedClientAction = "AllowAnonymous" + UnauthenticatedClientActionRedirectToLoginPage UnauthenticatedClientAction = "RedirectToLoginPage" +) + +func PossibleValuesForUnauthenticatedClientAction() []string { + return []string{ + string(UnauthenticatedClientActionAllowAnonymous), + string(UnauthenticatedClientActionRedirectToLoginPage), + } +} + +func (s *UnauthenticatedClientAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnauthenticatedClientAction(input string) (*UnauthenticatedClientAction, error) { + vals := map[string]UnauthenticatedClientAction{ + "allowanonymous": UnauthenticatedClientActionAllowAnonymous, + "redirecttologinpage": UnauthenticatedClientActionRedirectToLoginPage, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnauthenticatedClientAction(input) + return &out, nil +} + +type UnauthenticatedClientActionV2 string + +const ( + UnauthenticatedClientActionV2AllowAnonymous UnauthenticatedClientActionV2 = "AllowAnonymous" + UnauthenticatedClientActionV2RedirectToLoginPage UnauthenticatedClientActionV2 = "RedirectToLoginPage" + UnauthenticatedClientActionV2ReturnFourZeroOne UnauthenticatedClientActionV2 = "Return401" + UnauthenticatedClientActionV2ReturnFourZeroThree UnauthenticatedClientActionV2 = "Return403" +) + +func PossibleValuesForUnauthenticatedClientActionV2() []string { + return []string{ + string(UnauthenticatedClientActionV2AllowAnonymous), + string(UnauthenticatedClientActionV2RedirectToLoginPage), + string(UnauthenticatedClientActionV2ReturnFourZeroOne), + string(UnauthenticatedClientActionV2ReturnFourZeroThree), + } +} + +func (s *UnauthenticatedClientActionV2) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientActionV2(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnauthenticatedClientActionV2(input string) (*UnauthenticatedClientActionV2, error) { + vals := map[string]UnauthenticatedClientActionV2{ + "allowanonymous": UnauthenticatedClientActionV2AllowAnonymous, + "redirecttologinpage": UnauthenticatedClientActionV2RedirectToLoginPage, + "return401": UnauthenticatedClientActionV2ReturnFourZeroOne, + "return403": UnauthenticatedClientActionV2ReturnFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnauthenticatedClientActionV2(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} + +type WebJobType string + +const ( + WebJobTypeContinuous WebJobType = "Continuous" + WebJobTypeTriggered WebJobType = "Triggered" +) + +func PossibleValuesForWebJobType() []string { + return []string{ + string(WebJobTypeContinuous), + string(WebJobTypeTriggered), + } +} + +func (s *WebJobType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebJobType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebJobType(input string) (*WebJobType, error) { + vals := map[string]WebJobType{ + "continuous": WebJobTypeContinuous, + "triggered": WebJobTypeTriggered, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebJobType(input) + return &out, nil +} + +type WorkflowHealthState string + +const ( + WorkflowHealthStateHealthy WorkflowHealthState = "Healthy" + WorkflowHealthStateNotSpecified WorkflowHealthState = "NotSpecified" + WorkflowHealthStateUnhealthy WorkflowHealthState = "Unhealthy" + WorkflowHealthStateUnknown WorkflowHealthState = "Unknown" +) + +func PossibleValuesForWorkflowHealthState() []string { + return []string{ + string(WorkflowHealthStateHealthy), + string(WorkflowHealthStateNotSpecified), + string(WorkflowHealthStateUnhealthy), + string(WorkflowHealthStateUnknown), + } +} + +func (s *WorkflowHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowHealthState(input string) (*WorkflowHealthState, error) { + vals := map[string]WorkflowHealthState{ + "healthy": WorkflowHealthStateHealthy, + "notspecified": WorkflowHealthStateNotSpecified, + "unhealthy": WorkflowHealthStateUnhealthy, + "unknown": WorkflowHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowHealthState(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/webapps/id_appsetting.go b/resource-manager/web/2023-12-01/webapps/id_appsetting.go new file mode 100644 index 00000000000..f79067efc7a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_appsetting.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AppSettingId{}) +} + +var _ resourceids.ResourceId = &AppSettingId{} + +// AppSettingId is a struct representing the Resource ID for a App Setting +type AppSettingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + AppSettingKey string +} + +// NewAppSettingID returns a new AppSettingId struct +func NewAppSettingID(subscriptionId string, resourceGroupName string, siteName string, appSettingKey string) AppSettingId { + return AppSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + AppSettingKey: appSettingKey, + } +} + +// ParseAppSettingID parses 'input' into a AppSettingId +func ParseAppSettingID(input string) (*AppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAppSettingIDInsensitively parses 'input' case-insensitively into a AppSettingId +// note: this method should only be used for API response data and not user input +func ParseAppSettingIDInsensitively(input string) (*AppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AppSettingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.AppSettingKey, ok = input.Parsed["appSettingKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "appSettingKey", input) + } + + return nil +} + +// ValidateAppSettingID checks that 'input' can be parsed as a App Setting ID +func ValidateAppSettingID(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 := ParseAppSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted App Setting ID +func (id AppSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/configReferences/appSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.AppSettingKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this App Setting ID +func (id AppSettingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticAppSettings", "appSettings", "appSettings"), + resourceids.UserSpecifiedSegment("appSettingKey", "appSettingKeyValue"), + } +} + +// String returns a human-readable description of this App Setting ID +func (id AppSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("App Setting Key: %q", id.AppSettingKey), + } + return fmt.Sprintf("App Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_appsetting_test.go b/resource-manager/web/2023-12-01/webapps/id_appsetting_test.go new file mode 100644 index 00000000000..5ce74b6e974 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_appsetting_test.go @@ -0,0 +1,357 @@ +package webapps + +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 = &AppSettingId{} + +func TestNewAppSettingID(t *testing.T) { + id := NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "appSettingKeyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.AppSettingKey != "appSettingKeyValue" { + t.Fatalf("Expected %q but got %q for Segment 'AppSettingKey'", id.AppSettingKey, "appSettingKeyValue") + } +} + +func TestFormatAppSettingID(t *testing.T) { + actual := NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "appSettingKeyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/appSettings/appSettingKeyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAppSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/appSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/appSettings/appSettingKeyValue", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + AppSettingKey: "appSettingKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/appSettings/appSettingKeyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppSettingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestParseAppSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/appSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/appSettings/appSettingKeyValue", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + AppSettingKey: "appSettingKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/appSettings/appSettingKeyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEyVaLuE", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + AppSettingKey: "aPpSeTtInGkEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppSettingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestSegmentsForAppSettingId(t *testing.T) { + segments := AppSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AppSettingId 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/web/2023-12-01/webapps/id_backup.go b/resource-manager/web/2023-12-01/webapps/id_backup.go new file mode 100644 index 00000000000..c93bb6ba405 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_backup.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupId{}) +} + +var _ resourceids.ResourceId = &BackupId{} + +// BackupId is a struct representing the Resource ID for a Backup +type BackupId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + BackupId string +} + +// NewBackupID returns a new BackupId struct +func NewBackupID(subscriptionId string, resourceGroupName string, siteName string, backupId string) BackupId { + return BackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + BackupId: backupId, + } +} + +// ParseBackupID parses 'input' into a BackupId +func ParseBackupID(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupIDInsensitively parses 'input' case-insensitively into a BackupId +// note: this method should only be used for API response data and not user input +func ParseBackupIDInsensitively(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.BackupId, ok = input.Parsed["backupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupId", input) + } + + return nil +} + +// ValidateBackupID checks that 'input' can be parsed as a Backup ID +func ValidateBackupID(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 := ParseBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup ID +func (id BackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.BackupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup ID +func (id BackupId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupId", "backupIdValue"), + } +} + +// String returns a human-readable description of this Backup ID +func (id BackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Backup: %q", id.BackupId), + } + return fmt.Sprintf("Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_backup_test.go b/resource-manager/web/2023-12-01/webapps/id_backup_test.go new file mode 100644 index 00000000000..9e20eb375d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_backup_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &BackupId{} + +func TestNewBackupID(t *testing.T) { + id := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "backupIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.BackupId != "backupIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupId'", id.BackupId, "backupIdValue") + } +} + +func TestFormatBackupID(t *testing.T) { + actual := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "backupIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/backups/backupIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/backups/backupIdValue", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + BackupId: "backupIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/backups/backupIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestParseBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/backups/backupIdValue", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + BackupId: "backupIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/backups/backupIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/bAcKuPs/bAcKuPiDvAlUe", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + BackupId: "bAcKuPiDvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/bAcKuPs/bAcKuPiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestSegmentsForBackupId(t *testing.T) { + segments := BackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupId 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/web/2023-12-01/webapps/id_configreferenceappsetting.go b/resource-manager/web/2023-12-01/webapps/id_configreferenceappsetting.go new file mode 100644 index 00000000000..68ac42d6ea7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_configreferenceappsetting.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConfigReferenceAppSettingId{}) +} + +var _ resourceids.ResourceId = &ConfigReferenceAppSettingId{} + +// ConfigReferenceAppSettingId is a struct representing the Resource ID for a Config Reference App Setting +type ConfigReferenceAppSettingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + AppSettingKey string +} + +// NewConfigReferenceAppSettingID returns a new ConfigReferenceAppSettingId struct +func NewConfigReferenceAppSettingID(subscriptionId string, resourceGroupName string, siteName string, slotName string, appSettingKey string) ConfigReferenceAppSettingId { + return ConfigReferenceAppSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + AppSettingKey: appSettingKey, + } +} + +// ParseConfigReferenceAppSettingID parses 'input' into a ConfigReferenceAppSettingId +func ParseConfigReferenceAppSettingID(input string) (*ConfigReferenceAppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceAppSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceAppSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigReferenceAppSettingIDInsensitively parses 'input' case-insensitively into a ConfigReferenceAppSettingId +// note: this method should only be used for API response data and not user input +func ParseConfigReferenceAppSettingIDInsensitively(input string) (*ConfigReferenceAppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceAppSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceAppSettingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigReferenceAppSettingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.AppSettingKey, ok = input.Parsed["appSettingKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "appSettingKey", input) + } + + return nil +} + +// ValidateConfigReferenceAppSettingID checks that 'input' can be parsed as a Config Reference App Setting ID +func ValidateConfigReferenceAppSettingID(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 := ParseConfigReferenceAppSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/configReferences/appSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.AppSettingKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticAppSettings", "appSettings", "appSettings"), + resourceids.UserSpecifiedSegment("appSettingKey", "appSettingKeyValue"), + } +} + +// String returns a human-readable description of this Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("App Setting Key: %q", id.AppSettingKey), + } + return fmt.Sprintf("Config Reference App Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_configreferenceappsetting_test.go b/resource-manager/web/2023-12-01/webapps/id_configreferenceappsetting_test.go new file mode 100644 index 00000000000..0eaaa5e60e7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_configreferenceappsetting_test.go @@ -0,0 +1,402 @@ +package webapps + +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 = &ConfigReferenceAppSettingId{} + +func TestNewConfigReferenceAppSettingID(t *testing.T) { + id := NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "appSettingKeyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.AppSettingKey != "appSettingKeyValue" { + t.Fatalf("Expected %q but got %q for Segment 'AppSettingKey'", id.AppSettingKey, "appSettingKeyValue") + } +} + +func TestFormatConfigReferenceAppSettingID(t *testing.T) { + actual := NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "appSettingKeyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/appSettings/appSettingKeyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigReferenceAppSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceAppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/appSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/appSettings/appSettingKeyValue", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + AppSettingKey: "appSettingKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/appSettings/appSettingKeyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceAppSettingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestParseConfigReferenceAppSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceAppSettingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/appSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/appSettings/appSettingKeyValue", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + AppSettingKey: "appSettingKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/appSettings/appSettingKeyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEyVaLuE", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + AppSettingKey: "aPpSeTtInGkEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceAppSettingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestSegmentsForConfigReferenceAppSettingId(t *testing.T) { + segments := ConfigReferenceAppSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigReferenceAppSettingId 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/web/2023-12-01/webapps/id_configreferenceconnectionstring.go b/resource-manager/web/2023-12-01/webapps/id_configreferenceconnectionstring.go new file mode 100644 index 00000000000..73f0b28fde9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_configreferenceconnectionstring.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConfigReferenceConnectionStringId{}) +} + +var _ resourceids.ResourceId = &ConfigReferenceConnectionStringId{} + +// ConfigReferenceConnectionStringId is a struct representing the Resource ID for a Config Reference Connection String +type ConfigReferenceConnectionStringId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ConnectionStringKey string +} + +// NewConfigReferenceConnectionStringID returns a new ConfigReferenceConnectionStringId struct +func NewConfigReferenceConnectionStringID(subscriptionId string, resourceGroupName string, siteName string, slotName string, connectionStringKey string) ConfigReferenceConnectionStringId { + return ConfigReferenceConnectionStringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ConnectionStringKey: connectionStringKey, + } +} + +// ParseConfigReferenceConnectionStringID parses 'input' into a ConfigReferenceConnectionStringId +func ParseConfigReferenceConnectionStringID(input string) (*ConfigReferenceConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceConnectionStringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceConnectionStringId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigReferenceConnectionStringIDInsensitively parses 'input' case-insensitively into a ConfigReferenceConnectionStringId +// note: this method should only be used for API response data and not user input +func ParseConfigReferenceConnectionStringIDInsensitively(input string) (*ConfigReferenceConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceConnectionStringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceConnectionStringId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigReferenceConnectionStringId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ConnectionStringKey, ok = input.Parsed["connectionStringKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionStringKey", input) + } + + return nil +} + +// ValidateConfigReferenceConnectionStringID checks that 'input' can be parsed as a Config Reference Connection String ID +func ValidateConfigReferenceConnectionStringID(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 := ParseConfigReferenceConnectionStringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/configReferences/connectionStrings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ConnectionStringKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticConnectionStrings", "connectionStrings", "connectionStrings"), + resourceids.UserSpecifiedSegment("connectionStringKey", "connectionStringKeyValue"), + } +} + +// String returns a human-readable description of this Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Connection String Key: %q", id.ConnectionStringKey), + } + return fmt.Sprintf("Config Reference Connection String (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_configreferenceconnectionstring_test.go b/resource-manager/web/2023-12-01/webapps/id_configreferenceconnectionstring_test.go new file mode 100644 index 00000000000..a6c616cb885 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_configreferenceconnectionstring_test.go @@ -0,0 +1,402 @@ +package webapps + +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 = &ConfigReferenceConnectionStringId{} + +func TestNewConfigReferenceConnectionStringID(t *testing.T) { + id := NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "connectionStringKeyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.ConnectionStringKey != "connectionStringKeyValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionStringKey'", id.ConnectionStringKey, "connectionStringKeyValue") + } +} + +func TestFormatConfigReferenceConnectionStringID(t *testing.T) { + actual := NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "connectionStringKeyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/connectionStrings/connectionStringKeyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigReferenceConnectionStringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/connectionStrings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/connectionStrings/connectionStringKeyValue", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ConnectionStringKey: "connectionStringKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/connectionStrings/connectionStringKeyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceConnectionStringID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestParseConfigReferenceConnectionStringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/connectionStrings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/connectionStrings/connectionStringKeyValue", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ConnectionStringKey: "connectionStringKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/configReferences/connectionStrings/connectionStringKeyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEyVaLuE", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + ConnectionStringKey: "cOnNeCtIoNsTrInGkEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceConnectionStringIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestSegmentsForConfigReferenceConnectionStringId(t *testing.T) { + segments := ConfigReferenceConnectionStringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigReferenceConnectionStringId 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/web/2023-12-01/webapps/id_connectionstring.go b/resource-manager/web/2023-12-01/webapps/id_connectionstring.go new file mode 100644 index 00000000000..9e8a7bdf65a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_connectionstring.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectionStringId{}) +} + +var _ resourceids.ResourceId = &ConnectionStringId{} + +// ConnectionStringId is a struct representing the Resource ID for a Connection String +type ConnectionStringId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ConnectionStringKey string +} + +// NewConnectionStringID returns a new ConnectionStringId struct +func NewConnectionStringID(subscriptionId string, resourceGroupName string, siteName string, connectionStringKey string) ConnectionStringId { + return ConnectionStringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ConnectionStringKey: connectionStringKey, + } +} + +// ParseConnectionStringID parses 'input' into a ConnectionStringId +func ParseConnectionStringID(input string) (*ConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionStringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionStringId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectionStringIDInsensitively parses 'input' case-insensitively into a ConnectionStringId +// note: this method should only be used for API response data and not user input +func ParseConnectionStringIDInsensitively(input string) (*ConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionStringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionStringId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectionStringId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ConnectionStringKey, ok = input.Parsed["connectionStringKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionStringKey", input) + } + + return nil +} + +// ValidateConnectionStringID checks that 'input' can be parsed as a Connection String ID +func ValidateConnectionStringID(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 := ParseConnectionStringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connection String ID +func (id ConnectionStringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/configReferences/connectionStrings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ConnectionStringKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connection String ID +func (id ConnectionStringId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticConnectionStrings", "connectionStrings", "connectionStrings"), + resourceids.UserSpecifiedSegment("connectionStringKey", "connectionStringKeyValue"), + } +} + +// String returns a human-readable description of this Connection String ID +func (id ConnectionStringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Connection String Key: %q", id.ConnectionStringKey), + } + return fmt.Sprintf("Connection String (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_connectionstring_test.go b/resource-manager/web/2023-12-01/webapps/id_connectionstring_test.go new file mode 100644 index 00000000000..373d7cfae4a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_connectionstring_test.go @@ -0,0 +1,357 @@ +package webapps + +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 = &ConnectionStringId{} + +func TestNewConnectionStringID(t *testing.T) { + id := NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "connectionStringKeyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.ConnectionStringKey != "connectionStringKeyValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionStringKey'", id.ConnectionStringKey, "connectionStringKeyValue") + } +} + +func TestFormatConnectionStringID(t *testing.T) { + actual := NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "connectionStringKeyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/connectionStrings/connectionStringKeyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectionStringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/connectionStrings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/connectionStrings/connectionStringKeyValue", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ConnectionStringKey: "connectionStringKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/connectionStrings/connectionStringKeyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionStringID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestParseConnectionStringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionStringId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/connectionStrings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/connectionStrings/connectionStringKeyValue", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ConnectionStringKey: "connectionStringKeyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/configReferences/connectionStrings/connectionStringKeyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEyVaLuE", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + ConnectionStringKey: "cOnNeCtIoNsTrInGkEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionStringIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestSegmentsForConnectionStringId(t *testing.T) { + segments := ConnectionStringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectionStringId 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/web/2023-12-01/webapps/id_continuouswebjob.go b/resource-manager/web/2023-12-01/webapps/id_continuouswebjob.go new file mode 100644 index 00000000000..bd064699944 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_continuouswebjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContinuousWebJobId{}) +} + +var _ resourceids.ResourceId = &ContinuousWebJobId{} + +// ContinuousWebJobId is a struct representing the Resource ID for a Continuous Web Job +type ContinuousWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ContinuousWebJobName string +} + +// NewContinuousWebJobID returns a new ContinuousWebJobId struct +func NewContinuousWebJobID(subscriptionId string, resourceGroupName string, siteName string, continuousWebJobName string) ContinuousWebJobId { + return ContinuousWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ContinuousWebJobName: continuousWebJobName, + } +} + +// ParseContinuousWebJobID parses 'input' into a ContinuousWebJobId +func ParseContinuousWebJobID(input string) (*ContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContinuousWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContinuousWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContinuousWebJobIDInsensitively parses 'input' case-insensitively into a ContinuousWebJobId +// note: this method should only be used for API response data and not user input +func ParseContinuousWebJobIDInsensitively(input string) (*ContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContinuousWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContinuousWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContinuousWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ContinuousWebJobName, ok = input.Parsed["continuousWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "continuousWebJobName", input) + } + + return nil +} + +// ValidateContinuousWebJobID checks that 'input' can be parsed as a Continuous Web Job ID +func ValidateContinuousWebJobID(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 := ParseContinuousWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Continuous Web Job ID +func (id ContinuousWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/continuousWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ContinuousWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Continuous Web Job ID +func (id ContinuousWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticContinuousWebJobs", "continuousWebJobs", "continuousWebJobs"), + resourceids.UserSpecifiedSegment("continuousWebJobName", "continuousWebJobValue"), + } +} + +// String returns a human-readable description of this Continuous Web Job ID +func (id ContinuousWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Continuous Web Job Name: %q", id.ContinuousWebJobName), + } + return fmt.Sprintf("Continuous Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_continuouswebjob_test.go b/resource-manager/web/2023-12-01/webapps/id_continuouswebjob_test.go new file mode 100644 index 00000000000..7938e57fbb0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_continuouswebjob_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &ContinuousWebJobId{} + +func TestNewContinuousWebJobID(t *testing.T) { + id := NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "continuousWebJobValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.ContinuousWebJobName != "continuousWebJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContinuousWebJobName'", id.ContinuousWebJobName, "continuousWebJobValue") + } +} + +func TestFormatContinuousWebJobID(t *testing.T) { + actual := NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "continuousWebJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/continuousWebJobs/continuousWebJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContinuousWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/continuousWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/continuousWebJobs/continuousWebJobValue", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ContinuousWebJobName: "continuousWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/continuousWebJobs/continuousWebJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContinuousWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestParseContinuousWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/continuousWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnTiNuOuSwEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/continuousWebJobs/continuousWebJobValue", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ContinuousWebJobName: "continuousWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/continuousWebJobs/continuousWebJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBvAlUe", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + ContinuousWebJobName: "cOnTiNuOuSwEbJoBvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContinuousWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestSegmentsForContinuousWebJobId(t *testing.T) { + segments := ContinuousWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContinuousWebJobId 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/web/2023-12-01/webapps/id_default.go b/resource-manager/web/2023-12-01/webapps/id_default.go new file mode 100644 index 00000000000..c191cc07347 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_default.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DefaultId{}) +} + +var _ resourceids.ResourceId = &DefaultId{} + +// DefaultId is a struct representing the Resource ID for a Default +type DefaultId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DefaultName string + KeyName string +} + +// NewDefaultID returns a new DefaultId struct +func NewDefaultID(subscriptionId string, resourceGroupName string, siteName string, defaultName string, keyName string) DefaultId { + return DefaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DefaultName: defaultName, + KeyName: keyName, + } +} + +// ParseDefaultID parses 'input' into a DefaultId +func ParseDefaultID(input string) (*DefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDefaultIDInsensitively parses 'input' case-insensitively into a DefaultId +// note: this method should only be used for API response data and not user input +func ParseDefaultIDInsensitively(input string) (*DefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DefaultId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DefaultName, ok = input.Parsed["defaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "defaultName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateDefaultID checks that 'input' can be parsed as a Default ID +func ValidateDefaultID(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 := ParseDefaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Default ID +func (id DefaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/host/default/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DefaultName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Default ID +func (id DefaultId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHost", "host", "host"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.UserSpecifiedSegment("defaultName", "defaultValue"), + resourceids.UserSpecifiedSegment("keyName", "keyValue"), + } +} + +// String returns a human-readable description of this Default ID +func (id DefaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Default Name: %q", id.DefaultName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Default (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_default_test.go b/resource-manager/web/2023-12-01/webapps/id_default_test.go new file mode 100644 index 00000000000..687b8221b8d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_default_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &DefaultId{} + +func TestNewDefaultID(t *testing.T) { + id := NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "defaultValue", "keyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.DefaultName != "defaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'DefaultName'", id.DefaultName, "defaultValue") + } + + if id.KeyName != "keyValue" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyValue") + } +} + +func TestFormatDefaultID(t *testing.T) { + actual := NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "defaultValue", "keyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default/defaultValue/keyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDefaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default/defaultValue", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default/defaultValue/keyValue", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DefaultName: "defaultValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default/defaultValue/keyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseDefaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsT/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default/defaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsT/dEfAuLt/dEfAuLtVaLuE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default/defaultValue/keyValue", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DefaultName: "defaultValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/host/default/defaultValue/keyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsT/dEfAuLt/dEfAuLtVaLuE/kEyVaLuE", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + DefaultName: "dEfAuLtVaLuE", + KeyName: "kEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsT/dEfAuLt/dEfAuLtVaLuE/kEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForDefaultId(t *testing.T) { + segments := DefaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DefaultId 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/web/2023-12-01/webapps/id_deployment.go b/resource-manager/web/2023-12-01/webapps/id_deployment.go new file mode 100644 index 00000000000..a9c9751643f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_deployment.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeploymentId{}) +} + +var _ resourceids.ResourceId = &DeploymentId{} + +// DeploymentId is a struct representing the Resource ID for a Deployment +type DeploymentId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DeploymentName string +} + +// NewDeploymentID returns a new DeploymentId struct +func NewDeploymentID(subscriptionId string, resourceGroupName string, siteName string, deploymentName string) DeploymentId { + return DeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DeploymentName: deploymentName, + } +} + +// ParseDeploymentID parses 'input' into a DeploymentId +func ParseDeploymentID(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeploymentIDInsensitively parses 'input' case-insensitively into a DeploymentId +// note: this method should only be used for API response data and not user input +func ParseDeploymentIDInsensitively(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeploymentId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateDeploymentID checks that 'input' can be parsed as a Deployment ID +func ValidateDeploymentID(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 := ParseDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deployment ID +func (id DeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deployment ID +func (id DeploymentId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentValue"), + } +} + +// String returns a human-readable description of this Deployment ID +func (id DeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_deployment_test.go b/resource-manager/web/2023-12-01/webapps/id_deployment_test.go new file mode 100644 index 00000000000..e86fbdf8e94 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_deployment_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &DeploymentId{} + +func TestNewDeploymentID(t *testing.T) { + id := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "deploymentValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.DeploymentName != "deploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentValue") + } +} + +func TestFormatDeploymentID(t *testing.T) { + actual := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "deploymentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/deployments/deploymentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/deployments/deploymentValue", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DeploymentName: "deploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/deployments/deploymentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/deployments/deploymentValue", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DeploymentName: "deploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/deployments/deploymentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dEpLoYmEnTs/dEpLoYmEnTvAlUe", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + DeploymentName: "dEpLoYmEnTvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/dEpLoYmEnTs/dEpLoYmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForDeploymentId(t *testing.T) { + segments := DeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeploymentId 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/web/2023-12-01/webapps/id_domainownershipidentifier.go b/resource-manager/web/2023-12-01/webapps/id_domainownershipidentifier.go new file mode 100644 index 00000000000..45cb4c5271d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_domainownershipidentifier.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &DomainOwnershipIdentifierId{} + +// DomainOwnershipIdentifierId is a struct representing the Resource ID for a Domain Ownership Identifier +type DomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DomainOwnershipIdentifierName string +} + +// NewDomainOwnershipIdentifierID returns a new DomainOwnershipIdentifierId struct +func NewDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, siteName string, domainOwnershipIdentifierName string) DomainOwnershipIdentifierId { + return DomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseDomainOwnershipIdentifierID parses 'input' into a DomainOwnershipIdentifierId +func ParseDomainOwnershipIdentifierID(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a DomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseDomainOwnershipIdentifierIDInsensitively(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainOwnershipIdentifierId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateDomainOwnershipIdentifierID checks that 'input' can be parsed as a Domain Ownership Identifier ID +func ValidateDomainOwnershipIdentifierID(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 := ParseDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierValue"), + } +} + +// String returns a human-readable description of this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_domainownershipidentifier_test.go b/resource-manager/web/2023-12-01/webapps/id_domainownershipidentifier_test.go new file mode 100644 index 00000000000..b8de9c1a5bc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_domainownershipidentifier_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &DomainOwnershipIdentifierId{} + +func TestNewDomainOwnershipIdentifierID(t *testing.T) { + id := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "domainOwnershipIdentifierValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierValue" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierValue") + } +} + +func TestFormatDomainOwnershipIdentifierID(t *testing.T) { + actual := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "domainOwnershipIdentifierValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErVaLuE", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForDomainOwnershipIdentifierId(t *testing.T) { + segments := DomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DomainOwnershipIdentifierId 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/web/2023-12-01/webapps/id_function.go b/resource-manager/web/2023-12-01/webapps/id_function.go new file mode 100644 index 00000000000..4b864194a47 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_function.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FunctionId{}) +} + +var _ resourceids.ResourceId = &FunctionId{} + +// FunctionId is a struct representing the Resource ID for a Function +type FunctionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + FunctionName string +} + +// NewFunctionID returns a new FunctionId struct +func NewFunctionID(subscriptionId string, resourceGroupName string, siteName string, functionName string) FunctionId { + return FunctionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + FunctionName: functionName, + } +} + +// ParseFunctionID parses 'input' into a FunctionId +func ParseFunctionID(input string) (*FunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFunctionIDInsensitively parses 'input' case-insensitively into a FunctionId +// note: this method should only be used for API response data and not user input +func ParseFunctionIDInsensitively(input string) (*FunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FunctionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + return nil +} + +// ValidateFunctionID checks that 'input' can be parsed as a Function ID +func ValidateFunctionID(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 := ParseFunctionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Function ID +func (id FunctionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/functions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.FunctionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Function ID +func (id FunctionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionValue"), + } +} + +// String returns a human-readable description of this Function ID +func (id FunctionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + } + return fmt.Sprintf("Function (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_function_test.go b/resource-manager/web/2023-12-01/webapps/id_function_test.go new file mode 100644 index 00000000000..ea32a88560e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_function_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &FunctionId{} + +func TestNewFunctionID(t *testing.T) { + id := NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.FunctionName != "functionValue" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionValue") + } +} + +func TestFormatFunctionID(t *testing.T) { + actual := NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFunctionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + FunctionName: "functionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestParseFunctionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/fUnCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + FunctionName: "functionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/fUnCtIoNs/fUnCtIoNvAlUe", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + FunctionName: "fUnCtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestSegmentsForFunctionId(t *testing.T) { + segments := FunctionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FunctionId 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/web/2023-12-01/webapps/id_functionkey.go b/resource-manager/web/2023-12-01/webapps/id_functionkey.go new file mode 100644 index 00000000000..0e8c227341e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_functionkey.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FunctionKeyId{}) +} + +var _ resourceids.ResourceId = &FunctionKeyId{} + +// FunctionKeyId is a struct representing the Resource ID for a Function Key +type FunctionKeyId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + FunctionName string + KeyName string +} + +// NewFunctionKeyID returns a new FunctionKeyId struct +func NewFunctionKeyID(subscriptionId string, resourceGroupName string, siteName string, slotName string, functionName string, keyName string) FunctionKeyId { + return FunctionKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + FunctionName: functionName, + KeyName: keyName, + } +} + +// ParseFunctionKeyID parses 'input' into a FunctionKeyId +func ParseFunctionKeyID(input string) (*FunctionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionKeyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFunctionKeyIDInsensitively parses 'input' case-insensitively into a FunctionKeyId +// note: this method should only be used for API response data and not user input +func ParseFunctionKeyIDInsensitively(input string) (*FunctionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionKeyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FunctionKeyId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateFunctionKeyID checks that 'input' can be parsed as a Function Key ID +func ValidateFunctionKeyID(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 := ParseFunctionKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Function Key ID +func (id FunctionKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/functions/%s/keys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.FunctionName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Function Key ID +func (id FunctionKeyId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionValue"), + resourceids.StaticSegment("staticKeys", "keys", "keys"), + resourceids.UserSpecifiedSegment("keyName", "keyValue"), + } +} + +// String returns a human-readable description of this Function Key ID +func (id FunctionKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Function Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_functionkey_test.go b/resource-manager/web/2023-12-01/webapps/id_functionkey_test.go new file mode 100644 index 00000000000..472d4a72821 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_functionkey_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &FunctionKeyId{} + +func TestNewFunctionKeyID(t *testing.T) { + id := NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue", "keyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.FunctionName != "functionValue" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionValue") + } + + if id.KeyName != "keyValue" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyValue") + } +} + +func TestFormatFunctionKeyID(t *testing.T) { + actual := NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue", "keyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/keys/keyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFunctionKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionKeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/keys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/keys/keyValue", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + FunctionName: "functionValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/keys/keyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionKeyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseFunctionKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionKeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs/fUnCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/keys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/kEyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/keys/keyValue", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + FunctionName: "functionValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/keys/keyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/kEyS/kEyVaLuE", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + FunctionName: "fUnCtIoNvAlUe", + KeyName: "kEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/kEyS/kEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionKeyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForFunctionKeyId(t *testing.T) { + segments := FunctionKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FunctionKeyId 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/web/2023-12-01/webapps/id_gateway.go b/resource-manager/web/2023-12-01/webapps/id_gateway.go new file mode 100644 index 00000000000..ca31ece2066 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_gateway.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&GatewayId{}) +} + +var _ resourceids.ResourceId = &GatewayId{} + +// GatewayId is a struct representing the Resource ID for a Gateway +type GatewayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewGatewayID returns a new GatewayId struct +func NewGatewayID(subscriptionId string, resourceGroupName string, siteName string, virtualNetworkConnectionName string, gatewayName string) GatewayId { + return GatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseGatewayID parses 'input' into a GatewayId +func ParseGatewayID(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGatewayIDInsensitively parses 'input' case-insensitively into a GatewayId +// note: this method should only be used for API response data and not user input +func ParseGatewayIDInsensitively(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GatewayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateGatewayID checks that 'input' can be parsed as a Gateway ID +func ValidateGatewayID(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 := ParseGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gateway ID +func (id GatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gateway ID +func (id GatewayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionValue"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayValue"), + } +} + +// String returns a human-readable description of this Gateway ID +func (id GatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_gateway_test.go b/resource-manager/web/2023-12-01/webapps/id_gateway_test.go new file mode 100644 index 00000000000..4333af91e77 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_gateway_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &GatewayId{} + +func TestNewGatewayID(t *testing.T) { + id := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue", "gatewayValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionValue") + } + + if id.GatewayName != "gatewayValue" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayValue") + } +} + +func TestFormatGatewayID(t *testing.T) { + actual := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue", "gatewayValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + GatewayName: "gatewayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + GatewayName: "gatewayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS/gAtEwAyVaLuE", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + GatewayName: "gAtEwAyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS/gAtEwAyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForGatewayId(t *testing.T) { + segments := GatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GatewayId 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/web/2023-12-01/webapps/id_history.go b/resource-manager/web/2023-12-01/webapps/id_history.go new file mode 100644 index 00000000000..27f2d61eb6e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_history.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HistoryId{}) +} + +var _ resourceids.ResourceId = &HistoryId{} + +// HistoryId is a struct representing the Resource ID for a History +type HistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + TriggeredWebJobName string + HistoryName string +} + +// NewHistoryID returns a new HistoryId struct +func NewHistoryID(subscriptionId string, resourceGroupName string, siteName string, triggeredWebJobName string, historyName string) HistoryId { + return HistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + TriggeredWebJobName: triggeredWebJobName, + HistoryName: historyName, + } +} + +// ParseHistoryID parses 'input' into a HistoryId +func ParseHistoryID(input string) (*HistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&HistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHistoryIDInsensitively parses 'input' case-insensitively into a HistoryId +// note: this method should only be used for API response data and not user input +func ParseHistoryIDInsensitively(input string) (*HistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&HistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateHistoryID checks that 'input' can be parsed as a History ID +func ValidateHistoryID(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 := ParseHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted History ID +func (id HistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/triggeredWebJobs/%s/history/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.TriggeredWebJobName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this History ID +func (id HistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobValue"), + resourceids.StaticSegment("staticHistory", "history", "history"), + resourceids.UserSpecifiedSegment("historyName", "historyValue"), + } +} + +// String returns a human-readable description of this History ID +func (id HistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_history_test.go b/resource-manager/web/2023-12-01/webapps/id_history_test.go new file mode 100644 index 00000000000..e43c61cc17b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_history_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &HistoryId{} + +func TestNewHistoryID(t *testing.T) { + id := NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue", "historyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.TriggeredWebJobName != "triggeredWebJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobValue") + } + + if id.HistoryName != "historyValue" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyValue") + } +} + +func TestFormatHistoryID(t *testing.T) { + actual := NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue", "historyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/history", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + TriggeredWebJobName: "triggeredWebJobValue", + HistoryName: "historyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/history", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/hIsToRy", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + TriggeredWebJobName: "triggeredWebJobValue", + HistoryName: "historyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/hIsToRy/hIsToRyVaLuE", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + TriggeredWebJobName: "tRiGgErEdWeBjObVaLuE", + HistoryName: "hIsToRyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/hIsToRy/hIsToRyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForHistoryId(t *testing.T) { + segments := HistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HistoryId 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/web/2023-12-01/webapps/id_hostdefault.go b/resource-manager/web/2023-12-01/webapps/id_hostdefault.go new file mode 100644 index 00000000000..5278463ffbf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_hostdefault.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostDefaultId{}) +} + +var _ resourceids.ResourceId = &HostDefaultId{} + +// HostDefaultId is a struct representing the Resource ID for a Host Default +type HostDefaultId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DefaultName string + KeyName string +} + +// NewHostDefaultID returns a new HostDefaultId struct +func NewHostDefaultID(subscriptionId string, resourceGroupName string, siteName string, slotName string, defaultName string, keyName string) HostDefaultId { + return HostDefaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DefaultName: defaultName, + KeyName: keyName, + } +} + +// ParseHostDefaultID parses 'input' into a HostDefaultId +func ParseHostDefaultID(input string) (*HostDefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostDefaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostDefaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostDefaultIDInsensitively parses 'input' case-insensitively into a HostDefaultId +// note: this method should only be used for API response data and not user input +func ParseHostDefaultIDInsensitively(input string) (*HostDefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostDefaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostDefaultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostDefaultId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DefaultName, ok = input.Parsed["defaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "defaultName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateHostDefaultID checks that 'input' can be parsed as a Host Default ID +func ValidateHostDefaultID(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 := ParseHostDefaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Default ID +func (id HostDefaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/host/default/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DefaultName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Default ID +func (id HostDefaultId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticHost", "host", "host"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.UserSpecifiedSegment("defaultName", "defaultValue"), + resourceids.UserSpecifiedSegment("keyName", "keyValue"), + } +} + +// String returns a human-readable description of this Host Default ID +func (id HostDefaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Default Name: %q", id.DefaultName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Host Default (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_hostdefault_test.go b/resource-manager/web/2023-12-01/webapps/id_hostdefault_test.go new file mode 100644 index 00000000000..495f5a30b27 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_hostdefault_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &HostDefaultId{} + +func TestNewHostDefaultID(t *testing.T) { + id := NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "defaultValue", "keyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.DefaultName != "defaultValue" { + t.Fatalf("Expected %q but got %q for Segment 'DefaultName'", id.DefaultName, "defaultValue") + } + + if id.KeyName != "keyValue" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyValue") + } +} + +func TestFormatHostDefaultID(t *testing.T) { + actual := NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "defaultValue", "keyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default/defaultValue/keyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostDefaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostDefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default/defaultValue", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default/defaultValue/keyValue", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DefaultName: "defaultValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default/defaultValue/keyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostDefaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseHostDefaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostDefaultId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsT/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default/defaultValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsT/dEfAuLt/dEfAuLtVaLuE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default/defaultValue/keyValue", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DefaultName: "defaultValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/host/default/defaultValue/keyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsT/dEfAuLt/dEfAuLtVaLuE/kEyVaLuE", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + DefaultName: "dEfAuLtVaLuE", + KeyName: "kEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsT/dEfAuLt/dEfAuLtVaLuE/kEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostDefaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForHostDefaultId(t *testing.T) { + segments := HostDefaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostDefaultId 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/web/2023-12-01/webapps/id_hostnamebinding.go b/resource-manager/web/2023-12-01/webapps/id_hostnamebinding.go new file mode 100644 index 00000000000..dd781b22a7b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_hostnamebinding.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostNameBindingId{}) +} + +var _ resourceids.ResourceId = &HostNameBindingId{} + +// HostNameBindingId is a struct representing the Resource ID for a Host Name Binding +type HostNameBindingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HostNameBindingName string +} + +// NewHostNameBindingID returns a new HostNameBindingId struct +func NewHostNameBindingID(subscriptionId string, resourceGroupName string, siteName string, hostNameBindingName string) HostNameBindingId { + return HostNameBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HostNameBindingName: hostNameBindingName, + } +} + +// ParseHostNameBindingID parses 'input' into a HostNameBindingId +func ParseHostNameBindingID(input string) (*HostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostNameBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostNameBindingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostNameBindingIDInsensitively parses 'input' case-insensitively into a HostNameBindingId +// note: this method should only be used for API response data and not user input +func ParseHostNameBindingIDInsensitively(input string) (*HostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostNameBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostNameBindingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostNameBindingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HostNameBindingName, ok = input.Parsed["hostNameBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostNameBindingName", input) + } + + return nil +} + +// ValidateHostNameBindingID checks that 'input' can be parsed as a Host Name Binding ID +func ValidateHostNameBindingID(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 := ParseHostNameBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Name Binding ID +func (id HostNameBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostNameBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HostNameBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Name Binding ID +func (id HostNameBindingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostNameBindings", "hostNameBindings", "hostNameBindings"), + resourceids.UserSpecifiedSegment("hostNameBindingName", "hostNameBindingValue"), + } +} + +// String returns a human-readable description of this Host Name Binding ID +func (id HostNameBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Host Name Binding Name: %q", id.HostNameBindingName), + } + return fmt.Sprintf("Host Name Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_hostnamebinding_test.go b/resource-manager/web/2023-12-01/webapps/id_hostnamebinding_test.go new file mode 100644 index 00000000000..0bf52c36248 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_hostnamebinding_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &HostNameBindingId{} + +func TestNewHostNameBindingID(t *testing.T) { + id := NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hostNameBindingValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.HostNameBindingName != "hostNameBindingValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostNameBindingName'", id.HostNameBindingName, "hostNameBindingValue") + } +} + +func TestFormatHostNameBindingID(t *testing.T) { + actual := NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hostNameBindingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostNameBindings/hostNameBindingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostNameBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostNameBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostNameBindings/hostNameBindingValue", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + HostNameBindingName: "hostNameBindingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostNameBindings/hostNameBindingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostNameBindingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestParseHostNameBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostNameBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTnAmEbInDiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostNameBindings/hostNameBindingValue", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + HostNameBindingName: "hostNameBindingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostNameBindings/hostNameBindingValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgVaLuE", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + HostNameBindingName: "hOsTnAmEbInDiNgVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostNameBindingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestSegmentsForHostNameBindingId(t *testing.T) { + segments := HostNameBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostNameBindingId 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/web/2023-12-01/webapps/id_hybridconnection.go b/resource-manager/web/2023-12-01/webapps/id_hybridconnection.go new file mode 100644 index 00000000000..01b9c8a8590 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_hybridconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HybridConnectionId{}) +} + +var _ resourceids.ResourceId = &HybridConnectionId{} + +// HybridConnectionId is a struct representing the Resource ID for a Hybrid Connection +type HybridConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HybridConnectionName string +} + +// NewHybridConnectionID returns a new HybridConnectionId struct +func NewHybridConnectionID(subscriptionId string, resourceGroupName string, siteName string, hybridConnectionName string) HybridConnectionId { + return HybridConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HybridConnectionName: hybridConnectionName, + } +} + +// ParseHybridConnectionID parses 'input' into a HybridConnectionId +func ParseHybridConnectionID(input string) (*HybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHybridConnectionIDInsensitively parses 'input' case-insensitively into a HybridConnectionId +// note: this method should only be used for API response data and not user input +func ParseHybridConnectionIDInsensitively(input string) (*HybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HybridConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HybridConnectionName, ok = input.Parsed["hybridConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionName", input) + } + + return nil +} + +// ValidateHybridConnectionID checks that 'input' can be parsed as a Hybrid Connection ID +func ValidateHybridConnectionID(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 := ParseHybridConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hybrid Connection ID +func (id HybridConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hybridConnection/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HybridConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hybrid Connection ID +func (id HybridConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHybridConnection", "hybridConnection", "hybridConnection"), + resourceids.UserSpecifiedSegment("hybridConnectionName", "hybridConnectionValue"), + } +} + +// String returns a human-readable description of this Hybrid Connection ID +func (id HybridConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Hybrid Connection Name: %q", id.HybridConnectionName), + } + return fmt.Sprintf("Hybrid Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_hybridconnection_test.go b/resource-manager/web/2023-12-01/webapps/id_hybridconnection_test.go new file mode 100644 index 00000000000..620c5e8e1b2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_hybridconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &HybridConnectionId{} + +func TestNewHybridConnectionID(t *testing.T) { + id := NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.HybridConnectionName != "hybridConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionName'", id.HybridConnectionName, "hybridConnectionValue") + } +} + +func TestFormatHybridConnectionID(t *testing.T) { + actual := NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnection/hybridConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHybridConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnection", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnection/hybridConnectionValue", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + HybridConnectionName: "hybridConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnection/hybridConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestParseHybridConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnection/hybridConnectionValue", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + HybridConnectionName: "hybridConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnection/hybridConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNvAlUe", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + HybridConnectionName: "hYbRiDcOnNeCtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestSegmentsForHybridConnectionId(t *testing.T) { + segments := HybridConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HybridConnectionId 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/web/2023-12-01/webapps/id_instance.go b/resource-manager/web/2023-12-01/webapps/id_instance.go new file mode 100644 index 00000000000..f32fdae320a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_instance.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InstanceId{}) +} + +var _ resourceids.ResourceId = &InstanceId{} + +// InstanceId is a struct representing the Resource ID for a Instance +type InstanceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string +} + +// NewInstanceID returns a new InstanceId struct +func NewInstanceID(subscriptionId string, resourceGroupName string, siteName string, instanceId string) InstanceId { + return InstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + } +} + +// ParseInstanceID parses 'input' into a InstanceId +func ParseInstanceID(input string) (*InstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceIDInsensitively parses 'input' case-insensitively into a InstanceId +// note: this method should only be used for API response data and not user input +func ParseInstanceIDInsensitively(input string) (*InstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + return nil +} + +// ValidateInstanceID checks that 'input' can be parsed as a Instance ID +func ValidateInstanceID(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 := ParseInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance ID +func (id InstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance ID +func (id InstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceIdValue"), + } +} + +// String returns a human-readable description of this Instance ID +func (id InstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + } + return fmt.Sprintf("Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_instance_test.go b/resource-manager/web/2023-12-01/webapps/id_instance_test.go new file mode 100644 index 00000000000..c2d4408812f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_instance_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &InstanceId{} + +func TestNewInstanceID(t *testing.T) { + id := NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.InstanceId != "instanceIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceIdValue") + } +} + +func TestFormatInstanceID(t *testing.T) { + actual := NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + InstanceId: "instanceIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestParseInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + InstanceId: "instanceIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + InstanceId: "iNsTaNcEiDvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestSegmentsForInstanceId(t *testing.T) { + segments := InstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceId 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/web/2023-12-01/webapps/id_instanceprocess.go b/resource-manager/web/2023-12-01/webapps/id_instanceprocess.go new file mode 100644 index 00000000000..e5913d50a18 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_instanceprocess.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InstanceProcessId{}) +} + +var _ resourceids.ResourceId = &InstanceProcessId{} + +// InstanceProcessId is a struct representing the Resource ID for a Instance Process +type InstanceProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string + ProcessId string +} + +// NewInstanceProcessID returns a new InstanceProcessId struct +func NewInstanceProcessID(subscriptionId string, resourceGroupName string, siteName string, instanceId string, processId string) InstanceProcessId { + return InstanceProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + ProcessId: processId, + } +} + +// ParseInstanceProcessID parses 'input' into a InstanceProcessId +func ParseInstanceProcessID(input string) (*InstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceProcessIDInsensitively parses 'input' case-insensitively into a InstanceProcessId +// note: this method should only be used for API response data and not user input +func ParseInstanceProcessIDInsensitively(input string) (*InstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateInstanceProcessID checks that 'input' can be parsed as a Instance Process ID +func ValidateInstanceProcessID(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 := ParseInstanceProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Process ID +func (id InstanceProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Process ID +func (id InstanceProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceIdValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + } +} + +// String returns a human-readable description of this Instance Process ID +func (id InstanceProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Instance Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_instanceprocess_test.go b/resource-manager/web/2023-12-01/webapps/id_instanceprocess_test.go new file mode 100644 index 00000000000..7a477d260c5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_instanceprocess_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &InstanceProcessId{} + +func TestNewInstanceProcessID(t *testing.T) { + id := NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.InstanceId != "instanceIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceIdValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } +} + +func TestFormatInstanceProcessID(t *testing.T) { + actual := NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseInstanceProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + InstanceId: "iNsTaNcEiDvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForInstanceProcessId(t *testing.T) { + segments := InstanceProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceProcessId 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/web/2023-12-01/webapps/id_instanceprocessmodule.go b/resource-manager/web/2023-12-01/webapps/id_instanceprocessmodule.go new file mode 100644 index 00000000000..d905ee1acd0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_instanceprocessmodule.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InstanceProcessModuleId{}) +} + +var _ resourceids.ResourceId = &InstanceProcessModuleId{} + +// InstanceProcessModuleId is a struct representing the Resource ID for a Instance Process Module +type InstanceProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string + ProcessId string + ModuleName string +} + +// NewInstanceProcessModuleID returns a new InstanceProcessModuleId struct +func NewInstanceProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, instanceId string, processId string, moduleName string) InstanceProcessModuleId { + return InstanceProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseInstanceProcessModuleID parses 'input' into a InstanceProcessModuleId +func ParseInstanceProcessModuleID(input string) (*InstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceProcessModuleIDInsensitively parses 'input' case-insensitively into a InstanceProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseInstanceProcessModuleIDInsensitively(input string) (*InstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceProcessModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateInstanceProcessModuleID checks that 'input' can be parsed as a Instance Process Module ID +func ValidateInstanceProcessModuleID(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 := ParseInstanceProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Process Module ID +func (id InstanceProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Process Module ID +func (id InstanceProcessModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceIdValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleValue"), + } +} + +// String returns a human-readable description of this Instance Process Module ID +func (id InstanceProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Instance Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_instanceprocessmodule_test.go b/resource-manager/web/2023-12-01/webapps/id_instanceprocessmodule_test.go new file mode 100644 index 00000000000..487a8532519 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_instanceprocessmodule_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &InstanceProcessModuleId{} + +func TestNewInstanceProcessModuleID(t *testing.T) { + id := NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue", "moduleValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.InstanceId != "instanceIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceIdValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } + + if id.ModuleName != "moduleValue" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleValue") + } +} + +func TestFormatInstanceProcessModuleID(t *testing.T) { + actual := NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "instanceIdValue", "processIdValue", "moduleValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseInstanceProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + InstanceId: "iNsTaNcEiDvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + ModuleName: "mOdUlEvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForInstanceProcessModuleId(t *testing.T) { + segments := InstanceProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceProcessModuleId 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/web/2023-12-01/webapps/id_key.go b/resource-manager/web/2023-12-01/webapps/id_key.go new file mode 100644 index 00000000000..cbdd8974ed7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_key.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&KeyId{}) +} + +var _ resourceids.ResourceId = &KeyId{} + +// KeyId is a struct representing the Resource ID for a Key +type KeyId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + FunctionName string + KeyName string +} + +// NewKeyID returns a new KeyId struct +func NewKeyID(subscriptionId string, resourceGroupName string, siteName string, functionName string, keyName string) KeyId { + return KeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + FunctionName: functionName, + KeyName: keyName, + } +} + +// ParseKeyID parses 'input' into a KeyId +func ParseKeyID(input string) (*KeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKeyIDInsensitively parses 'input' case-insensitively into a KeyId +// note: this method should only be used for API response data and not user input +func ParseKeyIDInsensitively(input string) (*KeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KeyId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateKeyID checks that 'input' can be parsed as a Key ID +func ValidateKeyID(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 := ParseKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Key ID +func (id KeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/functions/%s/keys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.FunctionName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Key ID +func (id KeyId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionValue"), + resourceids.StaticSegment("staticKeys", "keys", "keys"), + resourceids.UserSpecifiedSegment("keyName", "keyValue"), + } +} + +// String returns a human-readable description of this Key ID +func (id KeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_key_test.go b/resource-manager/web/2023-12-01/webapps/id_key_test.go new file mode 100644 index 00000000000..3a4b0e1aa6c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_key_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &KeyId{} + +func TestNewKeyID(t *testing.T) { + id := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue", "keyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.FunctionName != "functionValue" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionValue") + } + + if id.KeyName != "keyValue" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyValue") + } +} + +func TestFormatKeyID(t *testing.T) { + actual := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "functionValue", "keyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/keys/keyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/keys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/keys/keyValue", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + FunctionName: "functionValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/keys/keyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/fUnCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/fUnCtIoNs/fUnCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/keys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/kEyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/keys/keyValue", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + FunctionName: "functionValue", + KeyName: "keyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/functions/functionValue/keys/keyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/kEyS/kEyVaLuE", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + FunctionName: "fUnCtIoNvAlUe", + KeyName: "kEyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/kEyS/kEyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForKeyId(t *testing.T) { + segments := KeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KeyId 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/web/2023-12-01/webapps/id_module.go b/resource-manager/web/2023-12-01/webapps/id_module.go new file mode 100644 index 00000000000..fa4c8e1c74c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_module.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ModuleId{}) +} + +var _ resourceids.ResourceId = &ModuleId{} + +// ModuleId is a struct representing the Resource ID for a Module +type ModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ProcessId string + ModuleName string +} + +// NewModuleID returns a new ModuleId struct +func NewModuleID(subscriptionId string, resourceGroupName string, siteName string, processId string, moduleName string) ModuleId { + return ModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseModuleID parses 'input' into a ModuleId +func ParseModuleID(input string) (*ModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseModuleIDInsensitively parses 'input' case-insensitively into a ModuleId +// note: this method should only be used for API response data and not user input +func ParseModuleIDInsensitively(input string) (*ModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateModuleID checks that 'input' can be parsed as a Module ID +func ValidateModuleID(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 := ParseModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Module ID +func (id ModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Module ID +func (id ModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleValue"), + } +} + +// String returns a human-readable description of this Module ID +func (id ModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_module_test.go b/resource-manager/web/2023-12-01/webapps/id_module_test.go new file mode 100644 index 00000000000..cd39346019d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_module_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &ModuleId{} + +func TestNewModuleID(t *testing.T) { + id := NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue", "moduleValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } + + if id.ModuleName != "moduleValue" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleValue") + } +} + +func TestFormatModuleID(t *testing.T) { + actual := NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue", "moduleValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/modules/moduleValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/modules/moduleValue", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/modules/moduleValue", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + ModuleName: "mOdUlEvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForModuleId(t *testing.T) { + segments := ModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ModuleId 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/web/2023-12-01/webapps/id_networkfeature.go b/resource-manager/web/2023-12-01/webapps/id_networkfeature.go new file mode 100644 index 00000000000..392453252e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_networkfeature.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkFeatureId{}) +} + +var _ resourceids.ResourceId = &NetworkFeatureId{} + +// NetworkFeatureId is a struct representing the Resource ID for a Network Feature +type NetworkFeatureId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + NetworkFeatureName string +} + +// NewNetworkFeatureID returns a new NetworkFeatureId struct +func NewNetworkFeatureID(subscriptionId string, resourceGroupName string, siteName string, networkFeatureName string) NetworkFeatureId { + return NetworkFeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + NetworkFeatureName: networkFeatureName, + } +} + +// ParseNetworkFeatureID parses 'input' into a NetworkFeatureId +func ParseNetworkFeatureID(input string) (*NetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkFeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkFeatureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkFeatureIDInsensitively parses 'input' case-insensitively into a NetworkFeatureId +// note: this method should only be used for API response data and not user input +func ParseNetworkFeatureIDInsensitively(input string) (*NetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkFeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkFeatureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkFeatureId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.NetworkFeatureName, ok = input.Parsed["networkFeatureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkFeatureName", input) + } + + return nil +} + +// ValidateNetworkFeatureID checks that 'input' can be parsed as a Network Feature ID +func ValidateNetworkFeatureID(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 := ParseNetworkFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Feature ID +func (id NetworkFeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkFeatures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.NetworkFeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Feature ID +func (id NetworkFeatureId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticNetworkFeatures", "networkFeatures", "networkFeatures"), + resourceids.UserSpecifiedSegment("networkFeatureName", "networkFeatureValue"), + } +} + +// String returns a human-readable description of this Network Feature ID +func (id NetworkFeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Network Feature Name: %q", id.NetworkFeatureName), + } + return fmt.Sprintf("Network Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_networkfeature_test.go b/resource-manager/web/2023-12-01/webapps/id_networkfeature_test.go new file mode 100644 index 00000000000..0b1e2dc93c0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_networkfeature_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &NetworkFeatureId{} + +func TestNewNetworkFeatureID(t *testing.T) { + id := NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "networkFeatureValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.NetworkFeatureName != "networkFeatureValue" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkFeatureName'", id.NetworkFeatureName, "networkFeatureValue") + } +} + +func TestFormatNetworkFeatureID(t *testing.T) { + actual := NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "networkFeatureValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkFeatures/networkFeatureValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkFeatures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkFeatures/networkFeatureValue", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + NetworkFeatureName: "networkFeatureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkFeatures/networkFeatureValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkFeatureID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestParseNetworkFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkFeatures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/nEtWoRkFeAtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkFeatures/networkFeatureValue", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + NetworkFeatureName: "networkFeatureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkFeatures/networkFeatureValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEvAlUe", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + NetworkFeatureName: "nEtWoRkFeAtUrEvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkFeatureIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestSegmentsForNetworkFeatureId(t *testing.T) { + segments := NetworkFeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkFeatureId 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/web/2023-12-01/webapps/id_networktrace.go b/resource-manager/web/2023-12-01/webapps/id_networktrace.go new file mode 100644 index 00000000000..28b0b24703c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_networktrace.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkTraceId{}) +} + +var _ resourceids.ResourceId = &NetworkTraceId{} + +// NetworkTraceId is a struct representing the Resource ID for a Network Trace +type NetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + OperationId string +} + +// NewNetworkTraceID returns a new NetworkTraceId struct +func NewNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, operationId string) NetworkTraceId { + return NetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + OperationId: operationId, + } +} + +// ParseNetworkTraceID parses 'input' into a NetworkTraceId +func ParseNetworkTraceID(input string) (*NetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkTraceIDInsensitively parses 'input' case-insensitively into a NetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseNetworkTraceIDInsensitively(input string) (*NetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateNetworkTraceID checks that 'input' can be parsed as a Network Trace ID +func ValidateNetworkTraceID(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 := ParseNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Trace ID +func (id NetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkTrace/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Trace ID +func (id NetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticNetworkTrace", "networkTrace", "networkTrace"), + resourceids.UserSpecifiedSegment("operationId", "operationIdValue"), + } +} + +// String returns a human-readable description of this Network Trace ID +func (id NetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_networktrace_test.go b/resource-manager/web/2023-12-01/webapps/id_networktrace_test.go new file mode 100644 index 00000000000..942b83bb4a5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_networktrace_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &NetworkTraceId{} + +func TestNewNetworkTraceID(t *testing.T) { + id := NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "operationIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.OperationId != "operationIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationIdValue") + } +} + +func TestFormatNetworkTraceID(t *testing.T) { + actual := NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "operationIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTrace/operationIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTrace", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTrace/operationIdValue", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTrace/operationIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTrace", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/nEtWoRkTrAcE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTrace/operationIdValue", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTrace/operationIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/nEtWoRkTrAcE/oPeRaTiOnIdVaLuE", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + OperationId: "oPeRaTiOnIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/nEtWoRkTrAcE/oPeRaTiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForNetworkTraceId(t *testing.T) { + segments := NetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkTraceId 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/web/2023-12-01/webapps/id_premieraddon.go b/resource-manager/web/2023-12-01/webapps/id_premieraddon.go new file mode 100644 index 00000000000..dfee9125f05 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_premieraddon.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PremierAddonId{}) +} + +var _ resourceids.ResourceId = &PremierAddonId{} + +// PremierAddonId is a struct representing the Resource ID for a Premier Addon +type PremierAddonId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PremierAddonName string +} + +// NewPremierAddonID returns a new PremierAddonId struct +func NewPremierAddonID(subscriptionId string, resourceGroupName string, siteName string, premierAddonName string) PremierAddonId { + return PremierAddonId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PremierAddonName: premierAddonName, + } +} + +// ParsePremierAddonID parses 'input' into a PremierAddonId +func ParsePremierAddonID(input string) (*PremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&PremierAddonId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PremierAddonId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePremierAddonIDInsensitively parses 'input' case-insensitively into a PremierAddonId +// note: this method should only be used for API response data and not user input +func ParsePremierAddonIDInsensitively(input string) (*PremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&PremierAddonId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PremierAddonId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PremierAddonId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PremierAddonName, ok = input.Parsed["premierAddonName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "premierAddonName", input) + } + + return nil +} + +// ValidatePremierAddonID checks that 'input' can be parsed as a Premier Addon ID +func ValidatePremierAddonID(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 := ParsePremierAddonID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Premier Addon ID +func (id PremierAddonId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/premierAddons/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PremierAddonName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Premier Addon ID +func (id PremierAddonId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticPremierAddons", "premierAddons", "premierAddons"), + resourceids.UserSpecifiedSegment("premierAddonName", "premierAddonValue"), + } +} + +// String returns a human-readable description of this Premier Addon ID +func (id PremierAddonId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Premier Addon Name: %q", id.PremierAddonName), + } + return fmt.Sprintf("Premier Addon (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_premieraddon_test.go b/resource-manager/web/2023-12-01/webapps/id_premieraddon_test.go new file mode 100644 index 00000000000..8804412b498 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_premieraddon_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &PremierAddonId{} + +func TestNewPremierAddonID(t *testing.T) { + id := NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "premierAddonValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.PremierAddonName != "premierAddonValue" { + t.Fatalf("Expected %q but got %q for Segment 'PremierAddonName'", id.PremierAddonName, "premierAddonValue") + } +} + +func TestFormatPremierAddonID(t *testing.T) { + actual := NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "premierAddonValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/premierAddons/premierAddonValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePremierAddonID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/premierAddons", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/premierAddons/premierAddonValue", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + PremierAddonName: "premierAddonValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/premierAddons/premierAddonValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePremierAddonID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestParsePremierAddonIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/premierAddons", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pReMiErAdDoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/premierAddons/premierAddonValue", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + PremierAddonName: "premierAddonValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/premierAddons/premierAddonValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pReMiErAdDoNs/pReMiErAdDoNvAlUe", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + PremierAddonName: "pReMiErAdDoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/pReMiErAdDoNs/pReMiErAdDoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePremierAddonIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestSegmentsForPremierAddonId(t *testing.T) { + segments := PremierAddonId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PremierAddonId 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/web/2023-12-01/webapps/id_privateendpointconnection.go b/resource-manager/web/2023-12-01/webapps/id_privateendpointconnection.go new file mode 100644 index 00000000000..30ff5bd5111 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, siteName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_privateendpointconnection_test.go b/resource-manager/web/2023-12-01/webapps/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..1f8102acb98 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2023-12-01/webapps/id_process.go b/resource-manager/web/2023-12-01/webapps/id_process.go new file mode 100644 index 00000000000..f50f0ce9a31 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_process.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProcessId{}) +} + +var _ resourceids.ResourceId = &ProcessId{} + +// ProcessId is a struct representing the Resource ID for a Process +type ProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ProcessId string +} + +// NewProcessID returns a new ProcessId struct +func NewProcessID(subscriptionId string, resourceGroupName string, siteName string, processId string) ProcessId { + return ProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ProcessId: processId, + } +} + +// ParseProcessID parses 'input' into a ProcessId +func ParseProcessID(input string) (*ProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProcessIDInsensitively parses 'input' case-insensitively into a ProcessId +// note: this method should only be used for API response data and not user input +func ParseProcessIDInsensitively(input string) (*ProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateProcessID checks that 'input' can be parsed as a Process ID +func ValidateProcessID(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 := ParseProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Process ID +func (id ProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Process ID +func (id ProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + } +} + +// String returns a human-readable description of this Process ID +func (id ProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_process_test.go b/resource-manager/web/2023-12-01/webapps/id_process_test.go new file mode 100644 index 00000000000..a15f4cb4c0f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_process_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &ProcessId{} + +func TestNewProcessID(t *testing.T) { + id := NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } +} + +func TestFormatProcessID(t *testing.T) { + actual := NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "processIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/processes/processIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForProcessId(t *testing.T) { + segments := ProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProcessId 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/web/2023-12-01/webapps/id_processmodule.go b/resource-manager/web/2023-12-01/webapps/id_processmodule.go new file mode 100644 index 00000000000..d82b0bb7c2a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_processmodule.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProcessModuleId{}) +} + +var _ resourceids.ResourceId = &ProcessModuleId{} + +// ProcessModuleId is a struct representing the Resource ID for a Process Module +type ProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ProcessId string + ModuleName string +} + +// NewProcessModuleID returns a new ProcessModuleId struct +func NewProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, slotName string, processId string, moduleName string) ProcessModuleId { + return ProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseProcessModuleID parses 'input' into a ProcessModuleId +func ParseProcessModuleID(input string) (*ProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProcessModuleIDInsensitively parses 'input' case-insensitively into a ProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseProcessModuleIDInsensitively(input string) (*ProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProcessModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateProcessModuleID checks that 'input' can be parsed as a Process Module ID +func ValidateProcessModuleID(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 := ParseProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Process Module ID +func (id ProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Process Module ID +func (id ProcessModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleValue"), + } +} + +// String returns a human-readable description of this Process Module ID +func (id ProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_processmodule_test.go b/resource-manager/web/2023-12-01/webapps/id_processmodule_test.go new file mode 100644 index 00000000000..ce23c1e2432 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_processmodule_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &ProcessModuleId{} + +func TestNewProcessModuleID(t *testing.T) { + id := NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue", "moduleValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } + + if id.ModuleName != "moduleValue" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleValue") + } +} + +func TestFormatProcessModuleID(t *testing.T) { + actual := NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue", "moduleValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/modules/moduleValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/modules/moduleValue", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/modules/moduleValue", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + ModuleName: "mOdUlEvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForProcessModuleId(t *testing.T) { + segments := ProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProcessModuleId 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/web/2023-12-01/webapps/id_publiccertificate.go b/resource-manager/web/2023-12-01/webapps/id_publiccertificate.go new file mode 100644 index 00000000000..73c217f6800 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_publiccertificate.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PublicCertificateId{}) +} + +var _ resourceids.ResourceId = &PublicCertificateId{} + +// PublicCertificateId is a struct representing the Resource ID for a Public Certificate +type PublicCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PublicCertificateName string +} + +// NewPublicCertificateID returns a new PublicCertificateId struct +func NewPublicCertificateID(subscriptionId string, resourceGroupName string, siteName string, publicCertificateName string) PublicCertificateId { + return PublicCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PublicCertificateName: publicCertificateName, + } +} + +// ParsePublicCertificateID parses 'input' into a PublicCertificateId +func ParsePublicCertificateID(input string) (*PublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePublicCertificateIDInsensitively parses 'input' case-insensitively into a PublicCertificateId +// note: this method should only be used for API response data and not user input +func ParsePublicCertificateIDInsensitively(input string) (*PublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PublicCertificateId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PublicCertificateName, ok = input.Parsed["publicCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "publicCertificateName", input) + } + + return nil +} + +// ValidatePublicCertificateID checks that 'input' can be parsed as a Public Certificate ID +func ValidatePublicCertificateID(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 := ParsePublicCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Public Certificate ID +func (id PublicCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/publicCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PublicCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Public Certificate ID +func (id PublicCertificateId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticPublicCertificates", "publicCertificates", "publicCertificates"), + resourceids.UserSpecifiedSegment("publicCertificateName", "publicCertificateValue"), + } +} + +// String returns a human-readable description of this Public Certificate ID +func (id PublicCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Public Certificate Name: %q", id.PublicCertificateName), + } + return fmt.Sprintf("Public Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_publiccertificate_test.go b/resource-manager/web/2023-12-01/webapps/id_publiccertificate_test.go new file mode 100644 index 00000000000..c55ae073f16 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_publiccertificate_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &PublicCertificateId{} + +func TestNewPublicCertificateID(t *testing.T) { + id := NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "publicCertificateValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.PublicCertificateName != "publicCertificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'PublicCertificateName'", id.PublicCertificateName, "publicCertificateValue") + } +} + +func TestFormatPublicCertificateID(t *testing.T) { + actual := NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "publicCertificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/publicCertificates/publicCertificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePublicCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/publicCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/publicCertificates/publicCertificateValue", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + PublicCertificateName: "publicCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/publicCertificates/publicCertificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestParsePublicCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/publicCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pUbLiCcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/publicCertificates/publicCertificateValue", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + PublicCertificateName: "publicCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/publicCertificates/publicCertificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeVaLuE", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + PublicCertificateName: "pUbLiCcErTiFiCaTeVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestSegmentsForPublicCertificateId(t *testing.T) { + segments := PublicCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PublicCertificateId 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/web/2023-12-01/webapps/id_relay.go b/resource-manager/web/2023-12-01/webapps/id_relay.go new file mode 100644 index 00000000000..52a8e92c8f5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_relay.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RelayId{}) +} + +var _ resourceids.ResourceId = &RelayId{} + +// RelayId is a struct representing the Resource ID for a Relay +type RelayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewRelayID returns a new RelayId struct +func NewRelayID(subscriptionId string, resourceGroupName string, siteName string, hybridConnectionNamespaceName string, relayName string) RelayId { + return RelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseRelayID parses 'input' into a RelayId +func ParseRelayID(input string) (*RelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&RelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RelayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRelayIDInsensitively parses 'input' case-insensitively into a RelayId +// note: this method should only be used for API response data and not user input +func ParseRelayIDInsensitively(input string) (*RelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&RelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RelayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RelayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateRelayID checks that 'input' can be parsed as a Relay ID +func ValidateRelayID(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 := ParseRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Relay ID +func (id RelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Relay ID +func (id RelayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceValue"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayValue"), + } +} + +// String returns a human-readable description of this Relay ID +func (id RelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_relay_test.go b/resource-manager/web/2023-12-01/webapps/id_relay_test.go new file mode 100644 index 00000000000..f3f0f840060 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_relay_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &RelayId{} + +func TestNewRelayID(t *testing.T) { + id := NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionNamespaceValue", "relayValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceValue") + } + + if id.RelayName != "relayValue" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayValue") + } +} + +func TestFormatRelayID(t *testing.T) { + actual := NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "hybridConnectionNamespaceValue", "relayValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + HybridConnectionNamespaceName: "hybridConnectionNamespaceValue", + RelayName: "relayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRelayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + HybridConnectionNamespaceName: "hybridConnectionNamespaceValue", + RelayName: "relayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS/rElAyVaLuE", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE", + RelayName: "rElAyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS/rElAyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRelayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForRelayId(t *testing.T) { + segments := RelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RelayId 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/web/2023-12-01/webapps/id_sitecontainer.go b/resource-manager/web/2023-12-01/webapps/id_sitecontainer.go new file mode 100644 index 00000000000..27ca4fa3c10 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_sitecontainer.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SitecontainerId{}) +} + +var _ resourceids.ResourceId = &SitecontainerId{} + +// SitecontainerId is a struct representing the Resource ID for a Sitecontainer +type SitecontainerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SitecontainerName string +} + +// NewSitecontainerID returns a new SitecontainerId struct +func NewSitecontainerID(subscriptionId string, resourceGroupName string, siteName string, sitecontainerName string) SitecontainerId { + return SitecontainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SitecontainerName: sitecontainerName, + } +} + +// ParseSitecontainerID parses 'input' into a SitecontainerId +func ParseSitecontainerID(input string) (*SitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SitecontainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SitecontainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSitecontainerIDInsensitively parses 'input' case-insensitively into a SitecontainerId +// note: this method should only be used for API response data and not user input +func ParseSitecontainerIDInsensitively(input string) (*SitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SitecontainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SitecontainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SitecontainerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SitecontainerName, ok = input.Parsed["sitecontainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sitecontainerName", input) + } + + return nil +} + +// ValidateSitecontainerID checks that 'input' can be parsed as a Sitecontainer ID +func ValidateSitecontainerID(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 := ParseSitecontainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sitecontainer ID +func (id SitecontainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/sitecontainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SitecontainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sitecontainer ID +func (id SitecontainerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSitecontainers", "sitecontainers", "sitecontainers"), + resourceids.UserSpecifiedSegment("sitecontainerName", "sitecontainerValue"), + } +} + +// String returns a human-readable description of this Sitecontainer ID +func (id SitecontainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Sitecontainer Name: %q", id.SitecontainerName), + } + return fmt.Sprintf("Sitecontainer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_sitecontainer_test.go b/resource-manager/web/2023-12-01/webapps/id_sitecontainer_test.go new file mode 100644 index 00000000000..8911160c0ee --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_sitecontainer_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SitecontainerId{} + +func TestNewSitecontainerID(t *testing.T) { + id := NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "sitecontainerValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SitecontainerName != "sitecontainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'SitecontainerName'", id.SitecontainerName, "sitecontainerValue") + } +} + +func TestFormatSitecontainerID(t *testing.T) { + actual := NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "sitecontainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/sitecontainers/sitecontainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSitecontainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/sitecontainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/sitecontainers/sitecontainerValue", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SitecontainerName: "sitecontainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/sitecontainers/sitecontainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSitecontainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestParseSitecontainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/sitecontainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sItEcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/sitecontainers/sitecontainerValue", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SitecontainerName: "sitecontainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/sitecontainers/sitecontainerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sItEcOnTaInErS/sItEcOnTaInErVaLuE", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SitecontainerName: "sItEcOnTaInErVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sItEcOnTaInErS/sItEcOnTaInErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSitecontainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestSegmentsForSitecontainerId(t *testing.T) { + segments := SitecontainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SitecontainerId 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/web/2023-12-01/webapps/id_siteextension.go b/resource-manager/web/2023-12-01/webapps/id_siteextension.go new file mode 100644 index 00000000000..769e3f2466e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_siteextension.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteExtensionId{}) +} + +var _ resourceids.ResourceId = &SiteExtensionId{} + +// SiteExtensionId is a struct representing the Resource ID for a Site Extension +type SiteExtensionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SiteExtensionId string +} + +// NewSiteExtensionID returns a new SiteExtensionId struct +func NewSiteExtensionID(subscriptionId string, resourceGroupName string, siteName string, siteExtensionId string) SiteExtensionId { + return SiteExtensionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SiteExtensionId: siteExtensionId, + } +} + +// ParseSiteExtensionID parses 'input' into a SiteExtensionId +func ParseSiteExtensionID(input string) (*SiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteExtensionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteExtensionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteExtensionIDInsensitively parses 'input' case-insensitively into a SiteExtensionId +// note: this method should only be used for API response data and not user input +func ParseSiteExtensionIDInsensitively(input string) (*SiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteExtensionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteExtensionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteExtensionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SiteExtensionId, ok = input.Parsed["siteExtensionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteExtensionId", input) + } + + return nil +} + +// ValidateSiteExtensionID checks that 'input' can be parsed as a Site Extension ID +func ValidateSiteExtensionID(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 := ParseSiteExtensionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Extension ID +func (id SiteExtensionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/siteExtensions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SiteExtensionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Extension ID +func (id SiteExtensionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSiteExtensions", "siteExtensions", "siteExtensions"), + resourceids.UserSpecifiedSegment("siteExtensionId", "siteExtensionIdValue"), + } +} + +// String returns a human-readable description of this Site Extension ID +func (id SiteExtensionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Site Extension: %q", id.SiteExtensionId), + } + return fmt.Sprintf("Site Extension (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_siteextension_test.go b/resource-manager/web/2023-12-01/webapps/id_siteextension_test.go new file mode 100644 index 00000000000..021f5563300 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_siteextension_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SiteExtensionId{} + +func TestNewSiteExtensionID(t *testing.T) { + id := NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "siteExtensionIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SiteExtensionId != "siteExtensionIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteExtensionId'", id.SiteExtensionId, "siteExtensionIdValue") + } +} + +func TestFormatSiteExtensionID(t *testing.T) { + actual := NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "siteExtensionIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/siteExtensions/siteExtensionIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteExtensionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/siteExtensions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/siteExtensions/siteExtensionIdValue", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SiteExtensionId: "siteExtensionIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/siteExtensions/siteExtensionIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteExtensionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestParseSiteExtensionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/siteExtensions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sItEeXtEnSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/siteExtensions/siteExtensionIdValue", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SiteExtensionId: "siteExtensionIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/siteExtensions/siteExtensionIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sItEeXtEnSiOnS/sItEeXtEnSiOnIdVaLuE", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SiteExtensionId: "sItEeXtEnSiOnIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sItEeXtEnSiOnS/sItEeXtEnSiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteExtensionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestSegmentsForSiteExtensionId(t *testing.T) { + segments := SiteExtensionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteExtensionId 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/web/2023-12-01/webapps/id_sitenetworktrace.go b/resource-manager/web/2023-12-01/webapps/id_sitenetworktrace.go new file mode 100644 index 00000000000..69b7e658c0c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_sitenetworktrace.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SiteNetworkTraceId{} + +// SiteNetworkTraceId is a struct representing the Resource ID for a Site Network Trace +type SiteNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + OperationId string +} + +// NewSiteNetworkTraceID returns a new SiteNetworkTraceId struct +func NewSiteNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, operationId string) SiteNetworkTraceId { + return SiteNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + OperationId: operationId, + } +} + +// ParseSiteNetworkTraceID parses 'input' into a SiteNetworkTraceId +func ParseSiteNetworkTraceID(input string) (*SiteNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteNetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteNetworkTraceIDInsensitively parses 'input' case-insensitively into a SiteNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSiteNetworkTraceIDInsensitively(input string) (*SiteNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteNetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteNetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSiteNetworkTraceID checks that 'input' can be parsed as a Site Network Trace ID +func ValidateSiteNetworkTraceID(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 := ParseSiteNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Network Trace ID +func (id SiteNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkTraces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Network Trace ID +func (id SiteNetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticNetworkTraces", "networkTraces", "networkTraces"), + resourceids.UserSpecifiedSegment("operationId", "operationIdValue"), + } +} + +// String returns a human-readable description of this Site Network Trace ID +func (id SiteNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Site Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_sitenetworktrace_test.go b/resource-manager/web/2023-12-01/webapps/id_sitenetworktrace_test.go new file mode 100644 index 00000000000..0908f924623 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_sitenetworktrace_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SiteNetworkTraceId{} + +func TestNewSiteNetworkTraceID(t *testing.T) { + id := NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "operationIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.OperationId != "operationIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationIdValue") + } +} + +func TestFormatSiteNetworkTraceID(t *testing.T) { + actual := NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "operationIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTraces/operationIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTraces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTraces/operationIdValue", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTraces/operationIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSiteNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTraces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/nEtWoRkTrAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTraces/operationIdValue", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/networkTraces/operationIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/nEtWoRkTrAcEs/oPeRaTiOnIdVaLuE", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + OperationId: "oPeRaTiOnIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/nEtWoRkTrAcEs/oPeRaTiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSiteNetworkTraceId(t *testing.T) { + segments := SiteNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteNetworkTraceId 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/web/2023-12-01/webapps/id_siteslotnetworktrace.go b/resource-manager/web/2023-12-01/webapps/id_siteslotnetworktrace.go new file mode 100644 index 00000000000..0ce16071841 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_siteslotnetworktrace.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteSlotNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SiteSlotNetworkTraceId{} + +// SiteSlotNetworkTraceId is a struct representing the Resource ID for a Site Slot Network Trace +type SiteSlotNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + OperationId string +} + +// NewSiteSlotNetworkTraceID returns a new SiteSlotNetworkTraceId struct +func NewSiteSlotNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, operationId string) SiteSlotNetworkTraceId { + return SiteSlotNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + OperationId: operationId, + } +} + +// ParseSiteSlotNetworkTraceID parses 'input' into a SiteSlotNetworkTraceId +func ParseSiteSlotNetworkTraceID(input string) (*SiteSlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteSlotNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteSlotNetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteSlotNetworkTraceIDInsensitively parses 'input' case-insensitively into a SiteSlotNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSiteSlotNetworkTraceIDInsensitively(input string) (*SiteSlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteSlotNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteSlotNetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteSlotNetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSiteSlotNetworkTraceID checks that 'input' can be parsed as a Site Slot Network Trace ID +func ValidateSiteSlotNetworkTraceID(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 := ParseSiteSlotNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkTraces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticNetworkTraces", "networkTraces", "networkTraces"), + resourceids.UserSpecifiedSegment("operationId", "operationIdValue"), + } +} + +// String returns a human-readable description of this Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Site Slot Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_siteslotnetworktrace_test.go b/resource-manager/web/2023-12-01/webapps/id_siteslotnetworktrace_test.go new file mode 100644 index 00000000000..afdec2c615a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_siteslotnetworktrace_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SiteSlotNetworkTraceId{} + +func TestNewSiteSlotNetworkTraceID(t *testing.T) { + id := NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "operationIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.OperationId != "operationIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationIdValue") + } +} + +func TestFormatSiteSlotNetworkTraceID(t *testing.T) { + actual := NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "operationIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTraces/operationIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteSlotNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteSlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTraces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTraces/operationIdValue", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTraces/operationIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteSlotNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSiteSlotNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteSlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTraces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkTrAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTraces/operationIdValue", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTraces/operationIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkTrAcEs/oPeRaTiOnIdVaLuE", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + OperationId: "oPeRaTiOnIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkTrAcEs/oPeRaTiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteSlotNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSiteSlotNetworkTraceId(t *testing.T) { + segments := SiteSlotNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteSlotNetworkTraceId 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/web/2023-12-01/webapps/id_slot.go b/resource-manager/web/2023-12-01/webapps/id_slot.go new file mode 100644 index 00000000000..37093c01152 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slot.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(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 := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slot_test.go b/resource-manager/web/2023-12-01/webapps/id_slot_test.go new file mode 100644 index 00000000000..4b5a683d0b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slot_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId 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/web/2023-12-01/webapps/id_slotbackup.go b/resource-manager/web/2023-12-01/webapps/id_slotbackup.go new file mode 100644 index 00000000000..7e922478028 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotbackup.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotBackupId{}) +} + +var _ resourceids.ResourceId = &SlotBackupId{} + +// SlotBackupId is a struct representing the Resource ID for a Slot Backup +type SlotBackupId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + BackupId string +} + +// NewSlotBackupID returns a new SlotBackupId struct +func NewSlotBackupID(subscriptionId string, resourceGroupName string, siteName string, slotName string, backupId string) SlotBackupId { + return SlotBackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + BackupId: backupId, + } +} + +// ParseSlotBackupID parses 'input' into a SlotBackupId +func ParseSlotBackupID(input string) (*SlotBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotBackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotBackupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotBackupIDInsensitively parses 'input' case-insensitively into a SlotBackupId +// note: this method should only be used for API response data and not user input +func ParseSlotBackupIDInsensitively(input string) (*SlotBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotBackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotBackupId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotBackupId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.BackupId, ok = input.Parsed["backupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupId", input) + } + + return nil +} + +// ValidateSlotBackupID checks that 'input' can be parsed as a Slot Backup ID +func ValidateSlotBackupID(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 := ParseSlotBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Backup ID +func (id SlotBackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.BackupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Backup ID +func (id SlotBackupId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupId", "backupIdValue"), + } +} + +// String returns a human-readable description of this Slot Backup ID +func (id SlotBackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Backup: %q", id.BackupId), + } + return fmt.Sprintf("Slot Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotbackup_test.go b/resource-manager/web/2023-12-01/webapps/id_slotbackup_test.go new file mode 100644 index 00000000000..3cfbf36492f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotbackup_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotBackupId{} + +func TestNewSlotBackupID(t *testing.T) { + id := NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "backupIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.BackupId != "backupIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'BackupId'", id.BackupId, "backupIdValue") + } +} + +func TestFormatSlotBackupID(t *testing.T) { + actual := NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "backupIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/backups/backupIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotBackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/backups/backupIdValue", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + BackupId: "backupIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/backups/backupIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotBackupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestParseSlotBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotBackupId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/backups/backupIdValue", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + BackupId: "backupIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/backups/backupIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/bAcKuPs/bAcKuPiDvAlUe", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + BackupId: "bAcKuPiDvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/bAcKuPs/bAcKuPiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotBackupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestSegmentsForSlotBackupId(t *testing.T) { + segments := SlotBackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotBackupId 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/web/2023-12-01/webapps/id_slotcontinuouswebjob.go b/resource-manager/web/2023-12-01/webapps/id_slotcontinuouswebjob.go new file mode 100644 index 00000000000..4c005d225dd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotcontinuouswebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotContinuousWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotContinuousWebJobId{} + +// SlotContinuousWebJobId is a struct representing the Resource ID for a Slot Continuous Web Job +type SlotContinuousWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ContinuousWebJobName string +} + +// NewSlotContinuousWebJobID returns a new SlotContinuousWebJobId struct +func NewSlotContinuousWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, continuousWebJobName string) SlotContinuousWebJobId { + return SlotContinuousWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ContinuousWebJobName: continuousWebJobName, + } +} + +// ParseSlotContinuousWebJobID parses 'input' into a SlotContinuousWebJobId +func ParseSlotContinuousWebJobID(input string) (*SlotContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotContinuousWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotContinuousWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotContinuousWebJobIDInsensitively parses 'input' case-insensitively into a SlotContinuousWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotContinuousWebJobIDInsensitively(input string) (*SlotContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotContinuousWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotContinuousWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotContinuousWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ContinuousWebJobName, ok = input.Parsed["continuousWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "continuousWebJobName", input) + } + + return nil +} + +// ValidateSlotContinuousWebJobID checks that 'input' can be parsed as a Slot Continuous Web Job ID +func ValidateSlotContinuousWebJobID(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 := ParseSlotContinuousWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/continuousWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ContinuousWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticContinuousWebJobs", "continuousWebJobs", "continuousWebJobs"), + resourceids.UserSpecifiedSegment("continuousWebJobName", "continuousWebJobValue"), + } +} + +// String returns a human-readable description of this Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Continuous Web Job Name: %q", id.ContinuousWebJobName), + } + return fmt.Sprintf("Slot Continuous Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotcontinuouswebjob_test.go b/resource-manager/web/2023-12-01/webapps/id_slotcontinuouswebjob_test.go new file mode 100644 index 00000000000..0e1722dde71 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotcontinuouswebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotContinuousWebJobId{} + +func TestNewSlotContinuousWebJobID(t *testing.T) { + id := NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "continuousWebJobValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.ContinuousWebJobName != "continuousWebJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'ContinuousWebJobName'", id.ContinuousWebJobName, "continuousWebJobValue") + } +} + +func TestFormatSlotContinuousWebJobID(t *testing.T) { + actual := NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "continuousWebJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/continuousWebJobs/continuousWebJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotContinuousWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/continuousWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/continuousWebJobs/continuousWebJobValue", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ContinuousWebJobName: "continuousWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/continuousWebJobs/continuousWebJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotContinuousWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestParseSlotContinuousWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotContinuousWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/continuousWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnTiNuOuSwEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/continuousWebJobs/continuousWebJobValue", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ContinuousWebJobName: "continuousWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/continuousWebJobs/continuousWebJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBvAlUe", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + ContinuousWebJobName: "cOnTiNuOuSwEbJoBvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotContinuousWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestSegmentsForSlotContinuousWebJobId(t *testing.T) { + segments := SlotContinuousWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotContinuousWebJobId 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/web/2023-12-01/webapps/id_slotdeployment.go b/resource-manager/web/2023-12-01/webapps/id_slotdeployment.go new file mode 100644 index 00000000000..c98c86d914f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotdeployment.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDeploymentId{}) +} + +var _ resourceids.ResourceId = &SlotDeploymentId{} + +// SlotDeploymentId is a struct representing the Resource ID for a Slot Deployment +type SlotDeploymentId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DeploymentName string +} + +// NewSlotDeploymentID returns a new SlotDeploymentId struct +func NewSlotDeploymentID(subscriptionId string, resourceGroupName string, siteName string, slotName string, deploymentName string) SlotDeploymentId { + return SlotDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DeploymentName: deploymentName, + } +} + +// ParseSlotDeploymentID parses 'input' into a SlotDeploymentId +func ParseSlotDeploymentID(input string) (*SlotDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDeploymentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDeploymentIDInsensitively parses 'input' case-insensitively into a SlotDeploymentId +// note: this method should only be used for API response data and not user input +func ParseSlotDeploymentIDInsensitively(input string) (*SlotDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDeploymentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDeploymentId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateSlotDeploymentID checks that 'input' can be parsed as a Slot Deployment ID +func ValidateSlotDeploymentID(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 := ParseSlotDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Deployment ID +func (id SlotDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Deployment ID +func (id SlotDeploymentId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentValue"), + } +} + +// String returns a human-readable description of this Slot Deployment ID +func (id SlotDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Slot Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotdeployment_test.go b/resource-manager/web/2023-12-01/webapps/id_slotdeployment_test.go new file mode 100644 index 00000000000..ea5811ea291 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotdeployment_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotDeploymentId{} + +func TestNewSlotDeploymentID(t *testing.T) { + id := NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "deploymentValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.DeploymentName != "deploymentValue" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentValue") + } +} + +func TestFormatSlotDeploymentID(t *testing.T) { + actual := NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "deploymentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/deployments/deploymentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/deployments/deploymentValue", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DeploymentName: "deploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/deployments/deploymentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseSlotDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDeploymentId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/deployments/deploymentValue", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DeploymentName: "deploymentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/deployments/deploymentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dEpLoYmEnTs/dEpLoYmEnTvAlUe", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + DeploymentName: "dEpLoYmEnTvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dEpLoYmEnTs/dEpLoYmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForSlotDeploymentId(t *testing.T) { + segments := SlotDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDeploymentId 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/web/2023-12-01/webapps/id_slotdomainownershipidentifier.go b/resource-manager/web/2023-12-01/webapps/id_slotdomainownershipidentifier.go new file mode 100644 index 00000000000..d8889a92f84 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotdomainownershipidentifier.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &SlotDomainOwnershipIdentifierId{} + +// SlotDomainOwnershipIdentifierId is a struct representing the Resource ID for a Slot Domain Ownership Identifier +type SlotDomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DomainOwnershipIdentifierName string +} + +// NewSlotDomainOwnershipIdentifierID returns a new SlotDomainOwnershipIdentifierId struct +func NewSlotDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, siteName string, slotName string, domainOwnershipIdentifierName string) SlotDomainOwnershipIdentifierId { + return SlotDomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseSlotDomainOwnershipIdentifierID parses 'input' into a SlotDomainOwnershipIdentifierId +func ParseSlotDomainOwnershipIdentifierID(input string) (*SlotDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDomainOwnershipIdentifierId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a SlotDomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseSlotDomainOwnershipIdentifierIDInsensitively(input string) (*SlotDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDomainOwnershipIdentifierId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDomainOwnershipIdentifierId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateSlotDomainOwnershipIdentifierID checks that 'input' can be parsed as a Slot Domain Ownership Identifier ID +func ValidateSlotDomainOwnershipIdentifierID(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 := ParseSlotDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierValue"), + } +} + +// String returns a human-readable description of this Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Slot Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotdomainownershipidentifier_test.go b/resource-manager/web/2023-12-01/webapps/id_slotdomainownershipidentifier_test.go new file mode 100644 index 00000000000..0e877aee928 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotdomainownershipidentifier_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotDomainOwnershipIdentifierId{} + +func TestNewSlotDomainOwnershipIdentifierID(t *testing.T) { + id := NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "domainOwnershipIdentifierValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierValue" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierValue") + } +} + +func TestFormatSlotDomainOwnershipIdentifierID(t *testing.T) { + actual := NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "domainOwnershipIdentifierValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDomainOwnershipIdentifierID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseSlotDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDomainOwnershipIdentifierId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/domainOwnershipIdentifiers/domainOwnershipIdentifierValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErVaLuE", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDomainOwnershipIdentifierIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForSlotDomainOwnershipIdentifierId(t *testing.T) { + segments := SlotDomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDomainOwnershipIdentifierId 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/web/2023-12-01/webapps/id_slotfunction.go b/resource-manager/web/2023-12-01/webapps/id_slotfunction.go new file mode 100644 index 00000000000..5578c099117 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotfunction.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotFunctionId{}) +} + +var _ resourceids.ResourceId = &SlotFunctionId{} + +// SlotFunctionId is a struct representing the Resource ID for a Slot Function +type SlotFunctionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + FunctionName string +} + +// NewSlotFunctionID returns a new SlotFunctionId struct +func NewSlotFunctionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, functionName string) SlotFunctionId { + return SlotFunctionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + FunctionName: functionName, + } +} + +// ParseSlotFunctionID parses 'input' into a SlotFunctionId +func ParseSlotFunctionID(input string) (*SlotFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotFunctionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotFunctionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotFunctionIDInsensitively parses 'input' case-insensitively into a SlotFunctionId +// note: this method should only be used for API response data and not user input +func ParseSlotFunctionIDInsensitively(input string) (*SlotFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotFunctionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotFunctionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotFunctionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + return nil +} + +// ValidateSlotFunctionID checks that 'input' can be parsed as a Slot Function ID +func ValidateSlotFunctionID(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 := ParseSlotFunctionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Function ID +func (id SlotFunctionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/functions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.FunctionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Function ID +func (id SlotFunctionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionValue"), + } +} + +// String returns a human-readable description of this Slot Function ID +func (id SlotFunctionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + } + return fmt.Sprintf("Slot Function (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotfunction_test.go b/resource-manager/web/2023-12-01/webapps/id_slotfunction_test.go new file mode 100644 index 00000000000..0a3d1be8f13 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotfunction_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotFunctionId{} + +func TestNewSlotFunctionID(t *testing.T) { + id := NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.FunctionName != "functionValue" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionValue") + } +} + +func TestFormatSlotFunctionID(t *testing.T) { + actual := NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "functionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotFunctionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotFunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + FunctionName: "functionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotFunctionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestParseSlotFunctionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotFunctionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + FunctionName: "functionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/functions/functionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs/fUnCtIoNvAlUe", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + FunctionName: "fUnCtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/fUnCtIoNs/fUnCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotFunctionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestSegmentsForSlotFunctionId(t *testing.T) { + segments := SlotFunctionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotFunctionId 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/web/2023-12-01/webapps/id_slothostnamebinding.go b/resource-manager/web/2023-12-01/webapps/id_slothostnamebinding.go new file mode 100644 index 00000000000..5e5e069e779 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slothostnamebinding.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotHostNameBindingId{}) +} + +var _ resourceids.ResourceId = &SlotHostNameBindingId{} + +// SlotHostNameBindingId is a struct representing the Resource ID for a Slot Host Name Binding +type SlotHostNameBindingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HostNameBindingName string +} + +// NewSlotHostNameBindingID returns a new SlotHostNameBindingId struct +func NewSlotHostNameBindingID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hostNameBindingName string) SlotHostNameBindingId { + return SlotHostNameBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HostNameBindingName: hostNameBindingName, + } +} + +// ParseSlotHostNameBindingID parses 'input' into a SlotHostNameBindingId +func ParseSlotHostNameBindingID(input string) (*SlotHostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHostNameBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHostNameBindingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHostNameBindingIDInsensitively parses 'input' case-insensitively into a SlotHostNameBindingId +// note: this method should only be used for API response data and not user input +func ParseSlotHostNameBindingIDInsensitively(input string) (*SlotHostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHostNameBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHostNameBindingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHostNameBindingId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HostNameBindingName, ok = input.Parsed["hostNameBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostNameBindingName", input) + } + + return nil +} + +// ValidateSlotHostNameBindingID checks that 'input' can be parsed as a Slot Host Name Binding ID +func ValidateSlotHostNameBindingID(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 := ParseSlotHostNameBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Host Name Binding ID +func (id SlotHostNameBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hostNameBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HostNameBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Host Name Binding ID +func (id SlotHostNameBindingId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticHostNameBindings", "hostNameBindings", "hostNameBindings"), + resourceids.UserSpecifiedSegment("hostNameBindingName", "hostNameBindingValue"), + } +} + +// String returns a human-readable description of this Slot Host Name Binding ID +func (id SlotHostNameBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Host Name Binding Name: %q", id.HostNameBindingName), + } + return fmt.Sprintf("Slot Host Name Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slothostnamebinding_test.go b/resource-manager/web/2023-12-01/webapps/id_slothostnamebinding_test.go new file mode 100644 index 00000000000..11cf5324057 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slothostnamebinding_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotHostNameBindingId{} + +func TestNewSlotHostNameBindingID(t *testing.T) { + id := NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hostNameBindingValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.HostNameBindingName != "hostNameBindingValue" { + t.Fatalf("Expected %q but got %q for Segment 'HostNameBindingName'", id.HostNameBindingName, "hostNameBindingValue") + } +} + +func TestFormatSlotHostNameBindingID(t *testing.T) { + actual := NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hostNameBindingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hostNameBindings/hostNameBindingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHostNameBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hostNameBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hostNameBindings/hostNameBindingValue", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + HostNameBindingName: "hostNameBindingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hostNameBindings/hostNameBindingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHostNameBindingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestParseSlotHostNameBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHostNameBindingId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hostNameBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsTnAmEbInDiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hostNameBindings/hostNameBindingValue", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + HostNameBindingName: "hostNameBindingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hostNameBindings/hostNameBindingValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgVaLuE", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + HostNameBindingName: "hOsTnAmEbInDiNgVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHostNameBindingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestSegmentsForSlotHostNameBindingId(t *testing.T) { + segments := SlotHostNameBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHostNameBindingId 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/web/2023-12-01/webapps/id_slothybridconnection.go b/resource-manager/web/2023-12-01/webapps/id_slothybridconnection.go new file mode 100644 index 00000000000..c59108e4984 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slothybridconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotHybridConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotHybridConnectionId{} + +// SlotHybridConnectionId is a struct representing the Resource ID for a Slot Hybrid Connection +type SlotHybridConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HybridConnectionName string +} + +// NewSlotHybridConnectionID returns a new SlotHybridConnectionId struct +func NewSlotHybridConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hybridConnectionName string) SlotHybridConnectionId { + return SlotHybridConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HybridConnectionName: hybridConnectionName, + } +} + +// ParseSlotHybridConnectionID parses 'input' into a SlotHybridConnectionId +func ParseSlotHybridConnectionID(input string) (*SlotHybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHybridConnectionIDInsensitively parses 'input' case-insensitively into a SlotHybridConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotHybridConnectionIDInsensitively(input string) (*SlotHybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHybridConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HybridConnectionName, ok = input.Parsed["hybridConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionName", input) + } + + return nil +} + +// ValidateSlotHybridConnectionID checks that 'input' can be parsed as a Slot Hybrid Connection ID +func ValidateSlotHybridConnectionID(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 := ParseSlotHybridConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Hybrid Connection ID +func (id SlotHybridConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hybridConnection/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HybridConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Hybrid Connection ID +func (id SlotHybridConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticHybridConnection", "hybridConnection", "hybridConnection"), + resourceids.UserSpecifiedSegment("hybridConnectionName", "hybridConnectionValue"), + } +} + +// String returns a human-readable description of this Slot Hybrid Connection ID +func (id SlotHybridConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Hybrid Connection Name: %q", id.HybridConnectionName), + } + return fmt.Sprintf("Slot Hybrid Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slothybridconnection_test.go b/resource-manager/web/2023-12-01/webapps/id_slothybridconnection_test.go new file mode 100644 index 00000000000..b3e102e19e7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slothybridconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotHybridConnectionId{} + +func TestNewSlotHybridConnectionID(t *testing.T) { + id := NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.HybridConnectionName != "hybridConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionName'", id.HybridConnectionName, "hybridConnectionValue") + } +} + +func TestFormatSlotHybridConnectionID(t *testing.T) { + actual := NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnection/hybridConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHybridConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnection", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnection/hybridConnectionValue", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + HybridConnectionName: "hybridConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnection/hybridConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestParseSlotHybridConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnection/hybridConnectionValue", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + HybridConnectionName: "hybridConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnection/hybridConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNvAlUe", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + HybridConnectionName: "hYbRiDcOnNeCtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestSegmentsForSlotHybridConnectionId(t *testing.T) { + segments := SlotHybridConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHybridConnectionId 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/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay.go b/resource-manager/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay.go new file mode 100644 index 00000000000..a990de1a626 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotHybridConnectionNamespaceRelayId{}) +} + +var _ resourceids.ResourceId = &SlotHybridConnectionNamespaceRelayId{} + +// SlotHybridConnectionNamespaceRelayId is a struct representing the Resource ID for a Slot Hybrid Connection Namespace Relay +type SlotHybridConnectionNamespaceRelayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewSlotHybridConnectionNamespaceRelayID returns a new SlotHybridConnectionNamespaceRelayId struct +func NewSlotHybridConnectionNamespaceRelayID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hybridConnectionNamespaceName string, relayName string) SlotHybridConnectionNamespaceRelayId { + return SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseSlotHybridConnectionNamespaceRelayID parses 'input' into a SlotHybridConnectionNamespaceRelayId +func ParseSlotHybridConnectionNamespaceRelayID(input string) (*SlotHybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionNamespaceRelayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHybridConnectionNamespaceRelayIDInsensitively parses 'input' case-insensitively into a SlotHybridConnectionNamespaceRelayId +// note: this method should only be used for API response data and not user input +func ParseSlotHybridConnectionNamespaceRelayIDInsensitively(input string) (*SlotHybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionNamespaceRelayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHybridConnectionNamespaceRelayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateSlotHybridConnectionNamespaceRelayID checks that 'input' can be parsed as a Slot Hybrid Connection Namespace Relay ID +func ValidateSlotHybridConnectionNamespaceRelayID(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 := ParseSlotHybridConnectionNamespaceRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceValue"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayValue"), + } +} + +// String returns a human-readable description of this Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Slot Hybrid Connection Namespace Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay_test.go b/resource-manager/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay_test.go new file mode 100644 index 00000000000..33c9b474181 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slothybridconnectionnamespacerelay_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &SlotHybridConnectionNamespaceRelayId{} + +func TestNewSlotHybridConnectionNamespaceRelayID(t *testing.T) { + id := NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionNamespaceValue", "relayValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceValue" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceValue") + } + + if id.RelayName != "relayValue" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayValue") + } +} + +func TestFormatSlotHybridConnectionNamespaceRelayID(t *testing.T) { + actual := NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "hybridConnectionNamespaceValue", "relayValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHybridConnectionNamespaceRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + HybridConnectionNamespaceName: "hybridConnectionNamespaceValue", + RelayName: "relayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionNamespaceRelayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseSlotHybridConnectionNamespaceRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionNamespaceRelayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + HybridConnectionNamespaceName: "hybridConnectionNamespaceValue", + RelayName: "relayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/hybridConnectionNamespaces/hybridConnectionNamespaceValue/relays/relayValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS/rElAyVaLuE", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE", + RelayName: "rElAyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeVaLuE/rElAyS/rElAyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionNamespaceRelayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForSlotHybridConnectionNamespaceRelayId(t *testing.T) { + segments := SlotHybridConnectionNamespaceRelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHybridConnectionNamespaceRelayId 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/web/2023-12-01/webapps/id_slotinstance.go b/resource-manager/web/2023-12-01/webapps/id_slotinstance.go new file mode 100644 index 00000000000..982475e3199 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotinstance.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotInstanceId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceId{} + +// SlotInstanceId is a struct representing the Resource ID for a Slot Instance +type SlotInstanceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string +} + +// NewSlotInstanceID returns a new SlotInstanceId struct +func NewSlotInstanceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string) SlotInstanceId { + return SlotInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + } +} + +// ParseSlotInstanceID parses 'input' into a SlotInstanceId +func ParseSlotInstanceID(input string) (*SlotInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceIDInsensitively parses 'input' case-insensitively into a SlotInstanceId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceIDInsensitively(input string) (*SlotInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + return nil +} + +// ValidateSlotInstanceID checks that 'input' can be parsed as a Slot Instance ID +func ValidateSlotInstanceID(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 := ParseSlotInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance ID +func (id SlotInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance ID +func (id SlotInstanceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceIdValue"), + } +} + +// String returns a human-readable description of this Slot Instance ID +func (id SlotInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + } + return fmt.Sprintf("Slot Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotinstance_test.go b/resource-manager/web/2023-12-01/webapps/id_slotinstance_test.go new file mode 100644 index 00000000000..7676b27043c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotinstance_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotInstanceId{} + +func TestNewSlotInstanceID(t *testing.T) { + id := NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.InstanceId != "instanceIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceIdValue") + } +} + +func TestFormatSlotInstanceID(t *testing.T) { + actual := NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + InstanceId: "instanceIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestParseSlotInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + InstanceId: "instanceIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + InstanceId: "iNsTaNcEiDvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestSegmentsForSlotInstanceId(t *testing.T) { + segments := SlotInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceId 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/web/2023-12-01/webapps/id_slotinstanceprocess.go b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocess.go new file mode 100644 index 00000000000..bec31e27acc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocess.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotInstanceProcessId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceProcessId{} + +// SlotInstanceProcessId is a struct representing the Resource ID for a Slot Instance Process +type SlotInstanceProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string + ProcessId string +} + +// NewSlotInstanceProcessID returns a new SlotInstanceProcessId struct +func NewSlotInstanceProcessID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string, processId string) SlotInstanceProcessId { + return SlotInstanceProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + ProcessId: processId, + } +} + +// ParseSlotInstanceProcessID parses 'input' into a SlotInstanceProcessId +func ParseSlotInstanceProcessID(input string) (*SlotInstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceProcessIDInsensitively parses 'input' case-insensitively into a SlotInstanceProcessId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceProcessIDInsensitively(input string) (*SlotInstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateSlotInstanceProcessID checks that 'input' can be parsed as a Slot Instance Process ID +func ValidateSlotInstanceProcessID(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 := ParseSlotInstanceProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance Process ID +func (id SlotInstanceProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance Process ID +func (id SlotInstanceProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceIdValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + } +} + +// String returns a human-readable description of this Slot Instance Process ID +func (id SlotInstanceProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Slot Instance Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocess_test.go b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocess_test.go new file mode 100644 index 00000000000..b6f5494ff6c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocess_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &SlotInstanceProcessId{} + +func TestNewSlotInstanceProcessID(t *testing.T) { + id := NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.InstanceId != "instanceIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceIdValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } +} + +func TestFormatSlotInstanceProcessID(t *testing.T) { + actual := NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseSlotInstanceProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + InstanceId: "iNsTaNcEiDvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForSlotInstanceProcessId(t *testing.T) { + segments := SlotInstanceProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceProcessId 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/web/2023-12-01/webapps/id_slotinstanceprocessmodule.go b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocessmodule.go new file mode 100644 index 00000000000..f1d5cdb11e7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocessmodule.go @@ -0,0 +1,166 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotInstanceProcessModuleId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceProcessModuleId{} + +// SlotInstanceProcessModuleId is a struct representing the Resource ID for a Slot Instance Process Module +type SlotInstanceProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string + ProcessId string + ModuleName string +} + +// NewSlotInstanceProcessModuleID returns a new SlotInstanceProcessModuleId struct +func NewSlotInstanceProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string, processId string, moduleName string) SlotInstanceProcessModuleId { + return SlotInstanceProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseSlotInstanceProcessModuleID parses 'input' into a SlotInstanceProcessModuleId +func ParseSlotInstanceProcessModuleID(input string) (*SlotInstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceProcessModuleIDInsensitively parses 'input' case-insensitively into a SlotInstanceProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceProcessModuleIDInsensitively(input string) (*SlotInstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessModuleId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceProcessModuleId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateSlotInstanceProcessModuleID checks that 'input' can be parsed as a Slot Instance Process Module ID +func ValidateSlotInstanceProcessModuleID(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 := ParseSlotInstanceProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceIdValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleValue"), + } +} + +// String returns a human-readable description of this Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Slot Instance Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocessmodule_test.go b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocessmodule_test.go new file mode 100644 index 00000000000..521b501b729 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotinstanceprocessmodule_test.go @@ -0,0 +1,462 @@ +package webapps + +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 = &SlotInstanceProcessModuleId{} + +func TestNewSlotInstanceProcessModuleID(t *testing.T) { + id := NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue", "moduleValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.InstanceId != "instanceIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceIdValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } + + if id.ModuleName != "moduleValue" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleValue") + } +} + +func TestFormatSlotInstanceProcessModuleID(t *testing.T) { + actual := NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "instanceIdValue", "processIdValue", "moduleValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseSlotInstanceProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessModuleId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + InstanceId: "instanceIdValue", + ProcessId: "processIdValue", + ModuleName: "moduleValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/instances/instanceIdValue/processes/processIdValue/modules/moduleValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + InstanceId: "iNsTaNcEiDvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + ModuleName: "mOdUlEvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/iNsTaNcEs/iNsTaNcEiDvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/mOdUlEs/mOdUlEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForSlotInstanceProcessModuleId(t *testing.T) { + segments := SlotInstanceProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceProcessModuleId 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/web/2023-12-01/webapps/id_slotnetworkfeature.go b/resource-manager/web/2023-12-01/webapps/id_slotnetworkfeature.go new file mode 100644 index 00000000000..9a2a2655b20 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotnetworkfeature.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotNetworkFeatureId{}) +} + +var _ resourceids.ResourceId = &SlotNetworkFeatureId{} + +// SlotNetworkFeatureId is a struct representing the Resource ID for a Slot Network Feature +type SlotNetworkFeatureId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + NetworkFeatureName string +} + +// NewSlotNetworkFeatureID returns a new SlotNetworkFeatureId struct +func NewSlotNetworkFeatureID(subscriptionId string, resourceGroupName string, siteName string, slotName string, networkFeatureName string) SlotNetworkFeatureId { + return SlotNetworkFeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + NetworkFeatureName: networkFeatureName, + } +} + +// ParseSlotNetworkFeatureID parses 'input' into a SlotNetworkFeatureId +func ParseSlotNetworkFeatureID(input string) (*SlotNetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkFeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkFeatureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotNetworkFeatureIDInsensitively parses 'input' case-insensitively into a SlotNetworkFeatureId +// note: this method should only be used for API response data and not user input +func ParseSlotNetworkFeatureIDInsensitively(input string) (*SlotNetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkFeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkFeatureId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotNetworkFeatureId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.NetworkFeatureName, ok = input.Parsed["networkFeatureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkFeatureName", input) + } + + return nil +} + +// ValidateSlotNetworkFeatureID checks that 'input' can be parsed as a Slot Network Feature ID +func ValidateSlotNetworkFeatureID(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 := ParseSlotNetworkFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Network Feature ID +func (id SlotNetworkFeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkFeatures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.NetworkFeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Network Feature ID +func (id SlotNetworkFeatureId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticNetworkFeatures", "networkFeatures", "networkFeatures"), + resourceids.UserSpecifiedSegment("networkFeatureName", "networkFeatureValue"), + } +} + +// String returns a human-readable description of this Slot Network Feature ID +func (id SlotNetworkFeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Network Feature Name: %q", id.NetworkFeatureName), + } + return fmt.Sprintf("Slot Network Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotnetworkfeature_test.go b/resource-manager/web/2023-12-01/webapps/id_slotnetworkfeature_test.go new file mode 100644 index 00000000000..8a14a32898c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotnetworkfeature_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotNetworkFeatureId{} + +func TestNewSlotNetworkFeatureID(t *testing.T) { + id := NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "networkFeatureValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.NetworkFeatureName != "networkFeatureValue" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkFeatureName'", id.NetworkFeatureName, "networkFeatureValue") + } +} + +func TestFormatSlotNetworkFeatureID(t *testing.T) { + actual := NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "networkFeatureValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkFeatures/networkFeatureValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotNetworkFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkFeatures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkFeatures/networkFeatureValue", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + NetworkFeatureName: "networkFeatureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkFeatures/networkFeatureValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkFeatureID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestParseSlotNetworkFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkFeatureId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkFeatures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkFeAtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkFeatures/networkFeatureValue", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + NetworkFeatureName: "networkFeatureValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkFeatures/networkFeatureValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEvAlUe", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + NetworkFeatureName: "nEtWoRkFeAtUrEvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkFeatureIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestSegmentsForSlotNetworkFeatureId(t *testing.T) { + segments := SlotNetworkFeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotNetworkFeatureId 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/web/2023-12-01/webapps/id_slotnetworktrace.go b/resource-manager/web/2023-12-01/webapps/id_slotnetworktrace.go new file mode 100644 index 00000000000..f0baafea877 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotnetworktrace.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SlotNetworkTraceId{} + +// SlotNetworkTraceId is a struct representing the Resource ID for a Slot Network Trace +type SlotNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + OperationId string +} + +// NewSlotNetworkTraceID returns a new SlotNetworkTraceId struct +func NewSlotNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, operationId string) SlotNetworkTraceId { + return SlotNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + OperationId: operationId, + } +} + +// ParseSlotNetworkTraceID parses 'input' into a SlotNetworkTraceId +func ParseSlotNetworkTraceID(input string) (*SlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotNetworkTraceIDInsensitively parses 'input' case-insensitively into a SlotNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSlotNetworkTraceIDInsensitively(input string) (*SlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkTraceId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotNetworkTraceId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSlotNetworkTraceID checks that 'input' can be parsed as a Slot Network Trace ID +func ValidateSlotNetworkTraceID(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 := ParseSlotNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Network Trace ID +func (id SlotNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkTrace/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Network Trace ID +func (id SlotNetworkTraceId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticNetworkTrace", "networkTrace", "networkTrace"), + resourceids.UserSpecifiedSegment("operationId", "operationIdValue"), + } +} + +// String returns a human-readable description of this Slot Network Trace ID +func (id SlotNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Slot Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotnetworktrace_test.go b/resource-manager/web/2023-12-01/webapps/id_slotnetworktrace_test.go new file mode 100644 index 00000000000..cb8ec411938 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotnetworktrace_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotNetworkTraceId{} + +func TestNewSlotNetworkTraceID(t *testing.T) { + id := NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "operationIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.OperationId != "operationIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationIdValue") + } +} + +func TestFormatSlotNetworkTraceID(t *testing.T) { + actual := NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "operationIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTrace/operationIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTrace", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTrace/operationIdValue", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTrace/operationIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSlotNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkTraceId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTrace", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkTrAcE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTrace/operationIdValue", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + OperationId: "operationIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/networkTrace/operationIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkTrAcE/oPeRaTiOnIdVaLuE", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + OperationId: "oPeRaTiOnIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/nEtWoRkTrAcE/oPeRaTiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSlotNetworkTraceId(t *testing.T) { + segments := SlotNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotNetworkTraceId 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/web/2023-12-01/webapps/id_slotpremieraddon.go b/resource-manager/web/2023-12-01/webapps/id_slotpremieraddon.go new file mode 100644 index 00000000000..363aac4042d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotpremieraddon.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotPremierAddonId{}) +} + +var _ resourceids.ResourceId = &SlotPremierAddonId{} + +// SlotPremierAddonId is a struct representing the Resource ID for a Slot Premier Addon +type SlotPremierAddonId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PremierAddonName string +} + +// NewSlotPremierAddonID returns a new SlotPremierAddonId struct +func NewSlotPremierAddonID(subscriptionId string, resourceGroupName string, siteName string, slotName string, premierAddonName string) SlotPremierAddonId { + return SlotPremierAddonId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PremierAddonName: premierAddonName, + } +} + +// ParseSlotPremierAddonID parses 'input' into a SlotPremierAddonId +func ParseSlotPremierAddonID(input string) (*SlotPremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPremierAddonId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPremierAddonId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPremierAddonIDInsensitively parses 'input' case-insensitively into a SlotPremierAddonId +// note: this method should only be used for API response data and not user input +func ParseSlotPremierAddonIDInsensitively(input string) (*SlotPremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPremierAddonId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPremierAddonId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPremierAddonId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PremierAddonName, ok = input.Parsed["premierAddonName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "premierAddonName", input) + } + + return nil +} + +// ValidateSlotPremierAddonID checks that 'input' can be parsed as a Slot Premier Addon ID +func ValidateSlotPremierAddonID(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 := ParseSlotPremierAddonID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Premier Addon ID +func (id SlotPremierAddonId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/premierAddons/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PremierAddonName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Premier Addon ID +func (id SlotPremierAddonId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticPremierAddons", "premierAddons", "premierAddons"), + resourceids.UserSpecifiedSegment("premierAddonName", "premierAddonValue"), + } +} + +// String returns a human-readable description of this Slot Premier Addon ID +func (id SlotPremierAddonId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Premier Addon Name: %q", id.PremierAddonName), + } + return fmt.Sprintf("Slot Premier Addon (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotpremieraddon_test.go b/resource-manager/web/2023-12-01/webapps/id_slotpremieraddon_test.go new file mode 100644 index 00000000000..57c94e704c6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotpremieraddon_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotPremierAddonId{} + +func TestNewSlotPremierAddonID(t *testing.T) { + id := NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "premierAddonValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.PremierAddonName != "premierAddonValue" { + t.Fatalf("Expected %q but got %q for Segment 'PremierAddonName'", id.PremierAddonName, "premierAddonValue") + } +} + +func TestFormatSlotPremierAddonID(t *testing.T) { + actual := NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "premierAddonValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/premierAddons/premierAddonValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPremierAddonID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/premierAddons", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/premierAddons/premierAddonValue", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + PremierAddonName: "premierAddonValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/premierAddons/premierAddonValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPremierAddonID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestParseSlotPremierAddonIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPremierAddonId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/premierAddons", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pReMiErAdDoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/premierAddons/premierAddonValue", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + PremierAddonName: "premierAddonValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/premierAddons/premierAddonValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pReMiErAdDoNs/pReMiErAdDoNvAlUe", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + PremierAddonName: "pReMiErAdDoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pReMiErAdDoNs/pReMiErAdDoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPremierAddonIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestSegmentsForSlotPremierAddonId(t *testing.T) { + segments := SlotPremierAddonId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPremierAddonId 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/web/2023-12-01/webapps/id_slotprivateendpointconnection.go b/resource-manager/web/2023-12-01/webapps/id_slotprivateendpointconnection.go new file mode 100644 index 00000000000..06c33c64213 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotprivateendpointconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotPrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotPrivateEndpointConnectionId{} + +// SlotPrivateEndpointConnectionId is a struct representing the Resource ID for a Slot Private Endpoint Connection +type SlotPrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PrivateEndpointConnectionName string +} + +// NewSlotPrivateEndpointConnectionID returns a new SlotPrivateEndpointConnectionId struct +func NewSlotPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, privateEndpointConnectionName string) SlotPrivateEndpointConnectionId { + return SlotPrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseSlotPrivateEndpointConnectionID parses 'input' into a SlotPrivateEndpointConnectionId +func ParseSlotPrivateEndpointConnectionID(input string) (*SlotPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a SlotPrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotPrivateEndpointConnectionIDInsensitively(input string) (*SlotPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPrivateEndpointConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateSlotPrivateEndpointConnectionID checks that 'input' can be parsed as a Slot Private Endpoint Connection ID +func ValidateSlotPrivateEndpointConnectionID(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 := ParseSlotPrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Slot Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotprivateendpointconnection_test.go b/resource-manager/web/2023-12-01/webapps/id_slotprivateendpointconnection_test.go new file mode 100644 index 00000000000..c9e26908b4c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotprivateendpointconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotPrivateEndpointConnectionId{} + +func TestNewSlotPrivateEndpointConnectionID(t *testing.T) { + id := NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatSlotPrivateEndpointConnectionID(t *testing.T) { + actual := NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseSlotPrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPrivateEndpointConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForSlotPrivateEndpointConnectionId(t *testing.T) { + segments := SlotPrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPrivateEndpointConnectionId 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/web/2023-12-01/webapps/id_slotprocess.go b/resource-manager/web/2023-12-01/webapps/id_slotprocess.go new file mode 100644 index 00000000000..85065bd680f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotprocess.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotProcessId{}) +} + +var _ resourceids.ResourceId = &SlotProcessId{} + +// SlotProcessId is a struct representing the Resource ID for a Slot Process +type SlotProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ProcessId string +} + +// NewSlotProcessID returns a new SlotProcessId struct +func NewSlotProcessID(subscriptionId string, resourceGroupName string, siteName string, slotName string, processId string) SlotProcessId { + return SlotProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ProcessId: processId, + } +} + +// ParseSlotProcessID parses 'input' into a SlotProcessId +func ParseSlotProcessID(input string) (*SlotProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotProcessIDInsensitively parses 'input' case-insensitively into a SlotProcessId +// note: this method should only be used for API response data and not user input +func ParseSlotProcessIDInsensitively(input string) (*SlotProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotProcessId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotProcessId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateSlotProcessID checks that 'input' can be parsed as a Slot Process ID +func ValidateSlotProcessID(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 := ParseSlotProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Process ID +func (id SlotProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Process ID +func (id SlotProcessId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processIdValue"), + } +} + +// String returns a human-readable description of this Slot Process ID +func (id SlotProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Slot Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotprocess_test.go b/resource-manager/web/2023-12-01/webapps/id_slotprocess_test.go new file mode 100644 index 00000000000..f058db8e849 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotprocess_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotProcessId{} + +func TestNewSlotProcessID(t *testing.T) { + id := NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.ProcessId != "processIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processIdValue") + } +} + +func TestFormatSlotProcessID(t *testing.T) { + actual := NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "processIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseSlotProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotProcessId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + ProcessId: "processIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/processes/processIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + ProcessId: "pRoCeSsIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pRoCeSsEs/pRoCeSsIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForSlotProcessId(t *testing.T) { + segments := SlotProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotProcessId 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/web/2023-12-01/webapps/id_slotpubliccertificate.go b/resource-manager/web/2023-12-01/webapps/id_slotpubliccertificate.go new file mode 100644 index 00000000000..9cc7df5ef0f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotpubliccertificate.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotPublicCertificateId{}) +} + +var _ resourceids.ResourceId = &SlotPublicCertificateId{} + +// SlotPublicCertificateId is a struct representing the Resource ID for a Slot Public Certificate +type SlotPublicCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PublicCertificateName string +} + +// NewSlotPublicCertificateID returns a new SlotPublicCertificateId struct +func NewSlotPublicCertificateID(subscriptionId string, resourceGroupName string, siteName string, slotName string, publicCertificateName string) SlotPublicCertificateId { + return SlotPublicCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PublicCertificateName: publicCertificateName, + } +} + +// ParseSlotPublicCertificateID parses 'input' into a SlotPublicCertificateId +func ParseSlotPublicCertificateID(input string) (*SlotPublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPublicCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPublicCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPublicCertificateIDInsensitively parses 'input' case-insensitively into a SlotPublicCertificateId +// note: this method should only be used for API response data and not user input +func ParseSlotPublicCertificateIDInsensitively(input string) (*SlotPublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPublicCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPublicCertificateId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPublicCertificateId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PublicCertificateName, ok = input.Parsed["publicCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "publicCertificateName", input) + } + + return nil +} + +// ValidateSlotPublicCertificateID checks that 'input' can be parsed as a Slot Public Certificate ID +func ValidateSlotPublicCertificateID(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 := ParseSlotPublicCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Public Certificate ID +func (id SlotPublicCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/publicCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PublicCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Public Certificate ID +func (id SlotPublicCertificateId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticPublicCertificates", "publicCertificates", "publicCertificates"), + resourceids.UserSpecifiedSegment("publicCertificateName", "publicCertificateValue"), + } +} + +// String returns a human-readable description of this Slot Public Certificate ID +func (id SlotPublicCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Public Certificate Name: %q", id.PublicCertificateName), + } + return fmt.Sprintf("Slot Public Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotpubliccertificate_test.go b/resource-manager/web/2023-12-01/webapps/id_slotpubliccertificate_test.go new file mode 100644 index 00000000000..9b4ebc415a2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotpubliccertificate_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotPublicCertificateId{} + +func TestNewSlotPublicCertificateID(t *testing.T) { + id := NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "publicCertificateValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.PublicCertificateName != "publicCertificateValue" { + t.Fatalf("Expected %q but got %q for Segment 'PublicCertificateName'", id.PublicCertificateName, "publicCertificateValue") + } +} + +func TestFormatSlotPublicCertificateID(t *testing.T) { + actual := NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "publicCertificateValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/publicCertificates/publicCertificateValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPublicCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/publicCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/publicCertificates/publicCertificateValue", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + PublicCertificateName: "publicCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/publicCertificates/publicCertificateValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPublicCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestParseSlotPublicCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPublicCertificateId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/publicCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pUbLiCcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/publicCertificates/publicCertificateValue", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + PublicCertificateName: "publicCertificateValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/publicCertificates/publicCertificateValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeVaLuE", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + PublicCertificateName: "pUbLiCcErTiFiCaTeVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPublicCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestSegmentsForSlotPublicCertificateId(t *testing.T) { + segments := SlotPublicCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPublicCertificateId 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/web/2023-12-01/webapps/id_slotsitecontainer.go b/resource-manager/web/2023-12-01/webapps/id_slotsitecontainer.go new file mode 100644 index 00000000000..8866f09575f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotsitecontainer.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotSitecontainerId{}) +} + +var _ resourceids.ResourceId = &SlotSitecontainerId{} + +// SlotSitecontainerId is a struct representing the Resource ID for a Slot Sitecontainer +type SlotSitecontainerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SitecontainerName string +} + +// NewSlotSitecontainerID returns a new SlotSitecontainerId struct +func NewSlotSitecontainerID(subscriptionId string, resourceGroupName string, siteName string, slotName string, sitecontainerName string) SlotSitecontainerId { + return SlotSitecontainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SitecontainerName: sitecontainerName, + } +} + +// ParseSlotSitecontainerID parses 'input' into a SlotSitecontainerId +func ParseSlotSitecontainerID(input string) (*SlotSitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSitecontainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSitecontainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotSitecontainerIDInsensitively parses 'input' case-insensitively into a SlotSitecontainerId +// note: this method should only be used for API response data and not user input +func ParseSlotSitecontainerIDInsensitively(input string) (*SlotSitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSitecontainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSitecontainerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotSitecontainerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SitecontainerName, ok = input.Parsed["sitecontainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sitecontainerName", input) + } + + return nil +} + +// ValidateSlotSitecontainerID checks that 'input' can be parsed as a Slot Sitecontainer ID +func ValidateSlotSitecontainerID(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 := ParseSlotSitecontainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Sitecontainer ID +func (id SlotSitecontainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/sitecontainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SitecontainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Sitecontainer ID +func (id SlotSitecontainerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticSitecontainers", "sitecontainers", "sitecontainers"), + resourceids.UserSpecifiedSegment("sitecontainerName", "sitecontainerValue"), + } +} + +// String returns a human-readable description of this Slot Sitecontainer ID +func (id SlotSitecontainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Sitecontainer Name: %q", id.SitecontainerName), + } + return fmt.Sprintf("Slot Sitecontainer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotsitecontainer_test.go b/resource-manager/web/2023-12-01/webapps/id_slotsitecontainer_test.go new file mode 100644 index 00000000000..205ad9211c6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotsitecontainer_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotSitecontainerId{} + +func TestNewSlotSitecontainerID(t *testing.T) { + id := NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "sitecontainerValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.SitecontainerName != "sitecontainerValue" { + t.Fatalf("Expected %q but got %q for Segment 'SitecontainerName'", id.SitecontainerName, "sitecontainerValue") + } +} + +func TestFormatSlotSitecontainerID(t *testing.T) { + actual := NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "sitecontainerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/sitecontainers/sitecontainerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotSitecontainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/sitecontainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/sitecontainers/sitecontainerValue", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + SitecontainerName: "sitecontainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/sitecontainers/sitecontainerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSitecontainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestParseSlotSitecontainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSitecontainerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/sitecontainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/sItEcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/sitecontainers/sitecontainerValue", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + SitecontainerName: "sitecontainerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/sitecontainers/sitecontainerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/sItEcOnTaInErS/sItEcOnTaInErVaLuE", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + SitecontainerName: "sItEcOnTaInErVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/sItEcOnTaInErS/sItEcOnTaInErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSitecontainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestSegmentsForSlotSitecontainerId(t *testing.T) { + segments := SlotSitecontainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotSitecontainerId 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/web/2023-12-01/webapps/id_slotsiteextension.go b/resource-manager/web/2023-12-01/webapps/id_slotsiteextension.go new file mode 100644 index 00000000000..24d7fa27fec --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotsiteextension.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotSiteExtensionId{}) +} + +var _ resourceids.ResourceId = &SlotSiteExtensionId{} + +// SlotSiteExtensionId is a struct representing the Resource ID for a Slot Site Extension +type SlotSiteExtensionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SiteExtensionId string +} + +// NewSlotSiteExtensionID returns a new SlotSiteExtensionId struct +func NewSlotSiteExtensionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, siteExtensionId string) SlotSiteExtensionId { + return SlotSiteExtensionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SiteExtensionId: siteExtensionId, + } +} + +// ParseSlotSiteExtensionID parses 'input' into a SlotSiteExtensionId +func ParseSlotSiteExtensionID(input string) (*SlotSiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSiteExtensionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSiteExtensionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotSiteExtensionIDInsensitively parses 'input' case-insensitively into a SlotSiteExtensionId +// note: this method should only be used for API response data and not user input +func ParseSlotSiteExtensionIDInsensitively(input string) (*SlotSiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSiteExtensionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSiteExtensionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotSiteExtensionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SiteExtensionId, ok = input.Parsed["siteExtensionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteExtensionId", input) + } + + return nil +} + +// ValidateSlotSiteExtensionID checks that 'input' can be parsed as a Slot Site Extension ID +func ValidateSlotSiteExtensionID(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 := ParseSlotSiteExtensionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Site Extension ID +func (id SlotSiteExtensionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/siteExtensions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SiteExtensionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Site Extension ID +func (id SlotSiteExtensionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticSiteExtensions", "siteExtensions", "siteExtensions"), + resourceids.UserSpecifiedSegment("siteExtensionId", "siteExtensionIdValue"), + } +} + +// String returns a human-readable description of this Slot Site Extension ID +func (id SlotSiteExtensionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Site Extension: %q", id.SiteExtensionId), + } + return fmt.Sprintf("Slot Site Extension (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotsiteextension_test.go b/resource-manager/web/2023-12-01/webapps/id_slotsiteextension_test.go new file mode 100644 index 00000000000..71b33313dbf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotsiteextension_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotSiteExtensionId{} + +func TestNewSlotSiteExtensionID(t *testing.T) { + id := NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "siteExtensionIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.SiteExtensionId != "siteExtensionIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteExtensionId'", id.SiteExtensionId, "siteExtensionIdValue") + } +} + +func TestFormatSlotSiteExtensionID(t *testing.T) { + actual := NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "siteExtensionIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/siteExtensions/siteExtensionIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotSiteExtensionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/siteExtensions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/siteExtensions/siteExtensionIdValue", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + SiteExtensionId: "siteExtensionIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/siteExtensions/siteExtensionIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSiteExtensionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestParseSlotSiteExtensionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSiteExtensionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/siteExtensions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/sItEeXtEnSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/siteExtensions/siteExtensionIdValue", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + SiteExtensionId: "siteExtensionIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/siteExtensions/siteExtensionIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/sItEeXtEnSiOnS/sItEeXtEnSiOnIdVaLuE", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + SiteExtensionId: "sItEeXtEnSiOnIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/sItEeXtEnSiOnS/sItEeXtEnSiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSiteExtensionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestSegmentsForSlotSiteExtensionId(t *testing.T) { + segments := SlotSiteExtensionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotSiteExtensionId 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/web/2023-12-01/webapps/id_slottriggeredwebjob.go b/resource-manager/web/2023-12-01/webapps/id_slottriggeredwebjob.go new file mode 100644 index 00000000000..8fcdb7a3629 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slottriggeredwebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotTriggeredWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotTriggeredWebJobId{} + +// SlotTriggeredWebJobId is a struct representing the Resource ID for a Slot Triggered Web Job +type SlotTriggeredWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + TriggeredWebJobName string +} + +// NewSlotTriggeredWebJobID returns a new SlotTriggeredWebJobId struct +func NewSlotTriggeredWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, triggeredWebJobName string) SlotTriggeredWebJobId { + return SlotTriggeredWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + TriggeredWebJobName: triggeredWebJobName, + } +} + +// ParseSlotTriggeredWebJobID parses 'input' into a SlotTriggeredWebJobId +func ParseSlotTriggeredWebJobID(input string) (*SlotTriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotTriggeredWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotTriggeredWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotTriggeredWebJobIDInsensitively parses 'input' case-insensitively into a SlotTriggeredWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotTriggeredWebJobIDInsensitively(input string) (*SlotTriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotTriggeredWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotTriggeredWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotTriggeredWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + return nil +} + +// ValidateSlotTriggeredWebJobID checks that 'input' can be parsed as a Slot Triggered Web Job ID +func ValidateSlotTriggeredWebJobID(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 := ParseSlotTriggeredWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/triggeredWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.TriggeredWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobValue"), + } +} + +// String returns a human-readable description of this Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + } + return fmt.Sprintf("Slot Triggered Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slottriggeredwebjob_test.go b/resource-manager/web/2023-12-01/webapps/id_slottriggeredwebjob_test.go new file mode 100644 index 00000000000..2b2c138656f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slottriggeredwebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotTriggeredWebJobId{} + +func TestNewSlotTriggeredWebJobID(t *testing.T) { + id := NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.TriggeredWebJobName != "triggeredWebJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobValue") + } +} + +func TestFormatSlotTriggeredWebJobID(t *testing.T) { + actual := NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotTriggeredWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotTriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + TriggeredWebJobName: "triggeredWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotTriggeredWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestParseSlotTriggeredWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotTriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + TriggeredWebJobName: "triggeredWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + TriggeredWebJobName: "tRiGgErEdWeBjObVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotTriggeredWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestSegmentsForSlotTriggeredWebJobId(t *testing.T) { + segments := SlotTriggeredWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotTriggeredWebJobId 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/web/2023-12-01/webapps/id_slotvirtualnetworkconnection.go b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnection.go new file mode 100644 index 00000000000..a5612467edd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotVirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionId{} + +// SlotVirtualNetworkConnectionId is a struct representing the Resource ID for a Slot Virtual Network Connection +type SlotVirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + VirtualNetworkConnectionName string +} + +// NewSlotVirtualNetworkConnectionID returns a new SlotVirtualNetworkConnectionId struct +func NewSlotVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, virtualNetworkConnectionName string) SlotVirtualNetworkConnectionId { + return SlotVirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseSlotVirtualNetworkConnectionID parses 'input' into a SlotVirtualNetworkConnectionId +func ParseSlotVirtualNetworkConnectionID(input string) (*SlotVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a SlotVirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotVirtualNetworkConnectionIDInsensitively(input string) (*SlotVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotVirtualNetworkConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateSlotVirtualNetworkConnectionID checks that 'input' can be parsed as a Slot Virtual Network Connection ID +func ValidateSlotVirtualNetworkConnectionID(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 := ParseSlotVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionValue"), + } +} + +// String returns a human-readable description of this Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Slot Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnection_test.go b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnection_test.go new file mode 100644 index 00000000000..eaf3319367e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotVirtualNetworkConnectionId{} + +func TestNewSlotVirtualNetworkConnectionID(t *testing.T) { + id := NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionValue") + } +} + +func TestFormatSlotVirtualNetworkConnectionID(t *testing.T) { + actual := NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseSlotVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForSlotVirtualNetworkConnectionId(t *testing.T) { + segments := SlotVirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotVirtualNetworkConnectionId 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/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway.go b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway.go new file mode 100644 index 00000000000..c730133f642 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotVirtualNetworkConnectionGatewayId{}) +} + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionGatewayId{} + +// SlotVirtualNetworkConnectionGatewayId is a struct representing the Resource ID for a Slot Virtual Network Connection Gateway +type SlotVirtualNetworkConnectionGatewayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewSlotVirtualNetworkConnectionGatewayID returns a new SlotVirtualNetworkConnectionGatewayId struct +func NewSlotVirtualNetworkConnectionGatewayID(subscriptionId string, resourceGroupName string, siteName string, slotName string, virtualNetworkConnectionName string, gatewayName string) SlotVirtualNetworkConnectionGatewayId { + return SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseSlotVirtualNetworkConnectionGatewayID parses 'input' into a SlotVirtualNetworkConnectionGatewayId +func ParseSlotVirtualNetworkConnectionGatewayID(input string) (*SlotVirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionGatewayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotVirtualNetworkConnectionGatewayIDInsensitively parses 'input' case-insensitively into a SlotVirtualNetworkConnectionGatewayId +// note: this method should only be used for API response data and not user input +func ParseSlotVirtualNetworkConnectionGatewayIDInsensitively(input string) (*SlotVirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionGatewayId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotVirtualNetworkConnectionGatewayId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateSlotVirtualNetworkConnectionGatewayID checks that 'input' can be parsed as a Slot Virtual Network Connection Gateway ID +func ValidateSlotVirtualNetworkConnectionGatewayID(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 := ParseSlotVirtualNetworkConnectionGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionValue"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayValue"), + } +} + +// String returns a human-readable description of this Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Slot Virtual Network Connection Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go new file mode 100644 index 00000000000..d6c0f5be78d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &SlotVirtualNetworkConnectionGatewayId{} + +func TestNewSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + id := NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue", "gatewayValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionValue") + } + + if id.GatewayName != "gatewayValue" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayValue") + } +} + +func TestFormatSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + actual := NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "virtualNetworkConnectionValue", "gatewayValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + GatewayName: "gatewayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseSlotVirtualNetworkConnectionGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionGatewayId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + GatewayName: "gatewayValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/virtualNetworkConnections/virtualNetworkConnectionValue/gateways/gatewayValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS/gAtEwAyVaLuE", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + GatewayName: "gAtEwAyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/gAtEwAyS/gAtEwAyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForSlotVirtualNetworkConnectionGatewayId(t *testing.T) { + segments := SlotVirtualNetworkConnectionGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotVirtualNetworkConnectionGatewayId 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/web/2023-12-01/webapps/id_slotwebjob.go b/resource-manager/web/2023-12-01/webapps/id_slotwebjob.go new file mode 100644 index 00000000000..2d33ce09820 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotwebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotWebJobId{} + +// SlotWebJobId is a struct representing the Resource ID for a Slot Web Job +type SlotWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + WebJobName string +} + +// NewSlotWebJobID returns a new SlotWebJobId struct +func NewSlotWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, webJobName string) SlotWebJobId { + return SlotWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + WebJobName: webJobName, + } +} + +// ParseSlotWebJobID parses 'input' into a SlotWebJobId +func ParseSlotWebJobID(input string) (*SlotWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotWebJobIDInsensitively parses 'input' case-insensitively into a SlotWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotWebJobIDInsensitively(input string) (*SlotWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.WebJobName, ok = input.Parsed["webJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webJobName", input) + } + + return nil +} + +// ValidateSlotWebJobID checks that 'input' can be parsed as a Slot Web Job ID +func ValidateSlotWebJobID(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 := ParseSlotWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Web Job ID +func (id SlotWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/webJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.WebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Web Job ID +func (id SlotWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticWebJobs", "webJobs", "webJobs"), + resourceids.UserSpecifiedSegment("webJobName", "webJobValue"), + } +} + +// String returns a human-readable description of this Slot Web Job ID +func (id SlotWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Web Job Name: %q", id.WebJobName), + } + return fmt.Sprintf("Slot Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotwebjob_test.go b/resource-manager/web/2023-12-01/webapps/id_slotwebjob_test.go new file mode 100644 index 00000000000..4fe7d088f70 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotwebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotWebJobId{} + +func TestNewSlotWebJobID(t *testing.T) { + id := NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "webJobValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.WebJobName != "webJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebJobName'", id.WebJobName, "webJobValue") + } +} + +func TestFormatSlotWebJobID(t *testing.T) { + actual := NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "webJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/webJobs/webJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/webJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/webJobs/webJobValue", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + WebJobName: "webJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/webJobs/webJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestParseSlotWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/webJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/wEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/webJobs/webJobValue", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + WebJobName: "webJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/webJobs/webJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/wEbJoBs/wEbJoBvAlUe", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + WebJobName: "wEbJoBvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/wEbJoBs/wEbJoBvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestSegmentsForSlotWebJobId(t *testing.T) { + segments := SlotWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotWebJobId 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/web/2023-12-01/webapps/id_slotworkflow.go b/resource-manager/web/2023-12-01/webapps/id_slotworkflow.go new file mode 100644 index 00000000000..cc9df4ec42e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotworkflow.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotWorkflowId{}) +} + +var _ resourceids.ResourceId = &SlotWorkflowId{} + +// SlotWorkflowId is a struct representing the Resource ID for a Slot Workflow +type SlotWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + WorkflowName string +} + +// NewSlotWorkflowID returns a new SlotWorkflowId struct +func NewSlotWorkflowID(subscriptionId string, resourceGroupName string, siteName string, slotName string, workflowName string) SlotWorkflowId { + return SlotWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + WorkflowName: workflowName, + } +} + +// ParseSlotWorkflowID parses 'input' into a SlotWorkflowId +func ParseSlotWorkflowID(input string) (*SlotWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotWorkflowIDInsensitively parses 'input' case-insensitively into a SlotWorkflowId +// note: this method should only be used for API response data and not user input +func ParseSlotWorkflowIDInsensitively(input string) (*SlotWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateSlotWorkflowID checks that 'input' can be parsed as a Slot Workflow ID +func ValidateSlotWorkflowID(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 := ParseSlotWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Workflow ID +func (id SlotWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Workflow ID +func (id SlotWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + } +} + +// String returns a human-readable description of this Slot Workflow ID +func (id SlotWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Slot Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_slotworkflow_test.go b/resource-manager/web/2023-12-01/webapps/id_slotworkflow_test.go new file mode 100644 index 00000000000..4ffc7cc736f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_slotworkflow_test.go @@ -0,0 +1,372 @@ +package webapps + +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 = &SlotWorkflowId{} + +func TestNewSlotWorkflowID(t *testing.T) { + id := NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "workflowValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } +} + +func TestFormatSlotWorkflowID(t *testing.T) { + actual := NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "workflowValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/workflows/workflowValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/workflows/workflowValue", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/workflows/workflowValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseSlotWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/workflows/workflowValue", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/workflows/workflowValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/wOrKfLoWs/wOrKfLoWvAlUe", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/wOrKfLoWs/wOrKfLoWvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForSlotWorkflowId(t *testing.T) { + segments := SlotWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotWorkflowId 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/web/2023-12-01/webapps/id_snapshot.go b/resource-manager/web/2023-12-01/webapps/id_snapshot.go new file mode 100644 index 00000000000..acd841b4273 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_snapshot.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SnapshotId{}) +} + +var _ resourceids.ResourceId = &SnapshotId{} + +// SnapshotId is a struct representing the Resource ID for a Snapshot +type SnapshotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SnapshotId string +} + +// NewSnapshotID returns a new SnapshotId struct +func NewSnapshotID(subscriptionId string, resourceGroupName string, siteName string, snapshotId string) SnapshotId { + return SnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SnapshotId: snapshotId, + } +} + +// ParseSnapshotID parses 'input' into a SnapshotId +func ParseSnapshotID(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSnapshotIDInsensitively parses 'input' case-insensitively into a SnapshotId +// note: this method should only be used for API response data and not user input +func ParseSnapshotIDInsensitively(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SnapshotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SnapshotId, ok = input.Parsed["snapshotId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotId", input) + } + + return nil +} + +// ValidateSnapshotID checks that 'input' can be parsed as a Snapshot ID +func ValidateSnapshotID(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 := ParseSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Snapshot ID +func (id SnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/web/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SnapshotId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Snapshot ID +func (id SnapshotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticWeb", "web", "web"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotId", "snapshotIdValue"), + } +} + +// String returns a human-readable description of this Snapshot ID +func (id SnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Snapshot: %q", id.SnapshotId), + } + return fmt.Sprintf("Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_snapshot_test.go b/resource-manager/web/2023-12-01/webapps/id_snapshot_test.go new file mode 100644 index 00000000000..d7907114594 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_snapshot_test.go @@ -0,0 +1,357 @@ +package webapps + +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 = &SnapshotId{} + +func TestNewSnapshotID(t *testing.T) { + id := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "snapshotIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SnapshotId != "snapshotIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotId'", id.SnapshotId, "snapshotIdValue") + } +} + +func TestFormatSnapshotID(t *testing.T) { + actual := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "snapshotIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web/snapshots/snapshotIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web/snapshots/snapshotIdValue", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SnapshotId: "snapshotIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web/snapshots/snapshotIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestParseSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/wEb/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web/snapshots/snapshotIdValue", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SnapshotId: "snapshotIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/config/web/snapshots/snapshotIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiDvAlUe", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SnapshotId: "sNaPsHoTiDvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestSegmentsForSnapshotId(t *testing.T) { + segments := SnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SnapshotId 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/web/2023-12-01/webapps/id_triggeredwebjob.go b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjob.go new file mode 100644 index 00000000000..7d689de870f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggeredWebJobId{}) +} + +var _ resourceids.ResourceId = &TriggeredWebJobId{} + +// TriggeredWebJobId is a struct representing the Resource ID for a Triggered Web Job +type TriggeredWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + TriggeredWebJobName string +} + +// NewTriggeredWebJobID returns a new TriggeredWebJobId struct +func NewTriggeredWebJobID(subscriptionId string, resourceGroupName string, siteName string, triggeredWebJobName string) TriggeredWebJobId { + return TriggeredWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + TriggeredWebJobName: triggeredWebJobName, + } +} + +// ParseTriggeredWebJobID parses 'input' into a TriggeredWebJobId +func ParseTriggeredWebJobID(input string) (*TriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggeredWebJobIDInsensitively parses 'input' case-insensitively into a TriggeredWebJobId +// note: this method should only be used for API response data and not user input +func ParseTriggeredWebJobIDInsensitively(input string) (*TriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggeredWebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + return nil +} + +// ValidateTriggeredWebJobID checks that 'input' can be parsed as a Triggered Web Job ID +func ValidateTriggeredWebJobID(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 := ParseTriggeredWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Triggered Web Job ID +func (id TriggeredWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/triggeredWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.TriggeredWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Triggered Web Job ID +func (id TriggeredWebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobValue"), + } +} + +// String returns a human-readable description of this Triggered Web Job ID +func (id TriggeredWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + } + return fmt.Sprintf("Triggered Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_triggeredwebjob_test.go b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjob_test.go new file mode 100644 index 00000000000..db20663207b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjob_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &TriggeredWebJobId{} + +func TestNewTriggeredWebJobID(t *testing.T) { + id := NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.TriggeredWebJobName != "triggeredWebJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobValue") + } +} + +func TestFormatTriggeredWebJobID(t *testing.T) { + actual := NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "triggeredWebJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggeredWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + TriggeredWebJobName: "triggeredWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestParseTriggeredWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + TriggeredWebJobName: "triggeredWebJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/triggeredWebJobs/triggeredWebJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + TriggeredWebJobName: "tRiGgErEdWeBjObVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestSegmentsForTriggeredWebJobId(t *testing.T) { + segments := TriggeredWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggeredWebJobId 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/web/2023-12-01/webapps/id_triggeredwebjobhistory.go b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjobhistory.go new file mode 100644 index 00000000000..cf7cd111d53 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjobhistory.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggeredWebJobHistoryId{}) +} + +var _ resourceids.ResourceId = &TriggeredWebJobHistoryId{} + +// TriggeredWebJobHistoryId is a struct representing the Resource ID for a Triggered Web Job History +type TriggeredWebJobHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + TriggeredWebJobName string + HistoryName string +} + +// NewTriggeredWebJobHistoryID returns a new TriggeredWebJobHistoryId struct +func NewTriggeredWebJobHistoryID(subscriptionId string, resourceGroupName string, siteName string, slotName string, triggeredWebJobName string, historyName string) TriggeredWebJobHistoryId { + return TriggeredWebJobHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + TriggeredWebJobName: triggeredWebJobName, + HistoryName: historyName, + } +} + +// ParseTriggeredWebJobHistoryID parses 'input' into a TriggeredWebJobHistoryId +func ParseTriggeredWebJobHistoryID(input string) (*TriggeredWebJobHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobHistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggeredWebJobHistoryIDInsensitively parses 'input' case-insensitively into a TriggeredWebJobHistoryId +// note: this method should only be used for API response data and not user input +func ParseTriggeredWebJobHistoryIDInsensitively(input string) (*TriggeredWebJobHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobHistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggeredWebJobHistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateTriggeredWebJobHistoryID checks that 'input' can be parsed as a Triggered Web Job History ID +func ValidateTriggeredWebJobHistoryID(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 := ParseTriggeredWebJobHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/triggeredWebJobs/%s/history/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.TriggeredWebJobName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobValue"), + resourceids.StaticSegment("staticHistory", "history", "history"), + resourceids.UserSpecifiedSegment("historyName", "historyValue"), + } +} + +// String returns a human-readable description of this Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("Triggered Web Job History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_triggeredwebjobhistory_test.go b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjobhistory_test.go new file mode 100644 index 00000000000..5fe5b38fff8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_triggeredwebjobhistory_test.go @@ -0,0 +1,417 @@ +package webapps + +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 = &TriggeredWebJobHistoryId{} + +func TestNewTriggeredWebJobHistoryID(t *testing.T) { + id := NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue", "historyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.TriggeredWebJobName != "triggeredWebJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobValue") + } + + if id.HistoryName != "historyValue" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyValue") + } +} + +func TestFormatTriggeredWebJobHistoryID(t *testing.T) { + actual := NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "triggeredWebJobValue", "historyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggeredWebJobHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/history", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + TriggeredWebJobName: "triggeredWebJobValue", + HistoryName: "historyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseTriggeredWebJobHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/history", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/hIsToRy", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + TriggeredWebJobName: "triggeredWebJobValue", + HistoryName: "historyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/triggeredWebJobs/triggeredWebJobValue/history/historyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/hIsToRy/hIsToRyVaLuE", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + TriggeredWebJobName: "tRiGgErEdWeBjObVaLuE", + HistoryName: "hIsToRyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/tRiGgErEdWeBjObS/tRiGgErEdWeBjObVaLuE/hIsToRy/hIsToRyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForTriggeredWebJobHistoryId(t *testing.T) { + segments := TriggeredWebJobHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggeredWebJobHistoryId 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/web/2023-12-01/webapps/id_virtualnetworkconnection.go b/resource-manager/web/2023-12-01/webapps/id_virtualnetworkconnection.go new file mode 100644 index 00000000000..7ac96780e13 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_virtualnetworkconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkConnectionId{} + +// VirtualNetworkConnectionId is a struct representing the Resource ID for a Virtual Network Connection +type VirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + VirtualNetworkConnectionName string +} + +// NewVirtualNetworkConnectionID returns a new VirtualNetworkConnectionId struct +func NewVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, siteName string, virtualNetworkConnectionName string) VirtualNetworkConnectionId { + return VirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseVirtualNetworkConnectionID parses 'input' into a VirtualNetworkConnectionId +func ParseVirtualNetworkConnectionID(input string) (*VirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a VirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkConnectionIDInsensitively(input string) (*VirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkConnectionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateVirtualNetworkConnectionID checks that 'input' can be parsed as a Virtual Network Connection ID +func ValidateVirtualNetworkConnectionID(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 := ParseVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Connection ID +func (id VirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Connection ID +func (id VirtualNetworkConnectionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionValue"), + } +} + +// String returns a human-readable description of this Virtual Network Connection ID +func (id VirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_virtualnetworkconnection_test.go b/resource-manager/web/2023-12-01/webapps/id_virtualnetworkconnection_test.go new file mode 100644 index 00000000000..a1e55c8e614 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_virtualnetworkconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &VirtualNetworkConnectionId{} + +func TestNewVirtualNetworkConnectionID(t *testing.T) { + id := NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionValue") + } +} + +func TestFormatVirtualNetworkConnectionID(t *testing.T) { + actual := NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "virtualNetworkConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + VirtualNetworkConnectionName: "virtualNetworkConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/virtualNetworkConnections/virtualNetworkConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForVirtualNetworkConnectionId(t *testing.T) { + segments := VirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkConnectionId 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/web/2023-12-01/webapps/id_webjob.go b/resource-manager/web/2023-12-01/webapps/id_webjob.go new file mode 100644 index 00000000000..1f27a30a1ec --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_webjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WebJobId{}) +} + +var _ resourceids.ResourceId = &WebJobId{} + +// WebJobId is a struct representing the Resource ID for a Web Job +type WebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WebJobName string +} + +// NewWebJobID returns a new WebJobId struct +func NewWebJobID(subscriptionId string, resourceGroupName string, siteName string, webJobName string) WebJobId { + return WebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WebJobName: webJobName, + } +} + +// ParseWebJobID parses 'input' into a WebJobId +func ParseWebJobID(input string) (*WebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWebJobIDInsensitively parses 'input' case-insensitively into a WebJobId +// note: this method should only be used for API response data and not user input +func ParseWebJobIDInsensitively(input string) (*WebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebJobId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WebJobId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WebJobName, ok = input.Parsed["webJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webJobName", input) + } + + return nil +} + +// ValidateWebJobID checks that 'input' can be parsed as a Web Job ID +func ValidateWebJobID(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 := ParseWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Web Job ID +func (id WebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/webJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Web Job ID +func (id WebJobId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticWebJobs", "webJobs", "webJobs"), + resourceids.UserSpecifiedSegment("webJobName", "webJobValue"), + } +} + +// String returns a human-readable description of this Web Job ID +func (id WebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Web Job Name: %q", id.WebJobName), + } + return fmt.Sprintf("Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_webjob_test.go b/resource-manager/web/2023-12-01/webapps/id_webjob_test.go new file mode 100644 index 00000000000..14cde80d8d6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_webjob_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &WebJobId{} + +func TestNewWebJobID(t *testing.T) { + id := NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "webJobValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WebJobName != "webJobValue" { + t.Fatalf("Expected %q but got %q for Segment 'WebJobName'", id.WebJobName, "webJobValue") + } +} + +func TestFormatWebJobID(t *testing.T) { + actual := NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "webJobValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/webJobs/webJobValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/webJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/webJobs/webJobValue", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WebJobName: "webJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/webJobs/webJobValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestParseWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebJobId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/webJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/wEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/webJobs/webJobValue", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WebJobName: "webJobValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/webJobs/webJobValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/wEbJoBs/wEbJoBvAlUe", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WebJobName: "wEbJoBvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/wEbJoBs/wEbJoBvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestSegmentsForWebJobId(t *testing.T) { + segments := WebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WebJobId 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/web/2023-12-01/webapps/id_websnapshot.go b/resource-manager/web/2023-12-01/webapps/id_websnapshot.go new file mode 100644 index 00000000000..705a6fbcaf9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_websnapshot.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WebSnapshotId{}) +} + +var _ resourceids.ResourceId = &WebSnapshotId{} + +// WebSnapshotId is a struct representing the Resource ID for a Web Snapshot +type WebSnapshotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SnapshotId string +} + +// NewWebSnapshotID returns a new WebSnapshotId struct +func NewWebSnapshotID(subscriptionId string, resourceGroupName string, siteName string, slotName string, snapshotId string) WebSnapshotId { + return WebSnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SnapshotId: snapshotId, + } +} + +// ParseWebSnapshotID parses 'input' into a WebSnapshotId +func ParseWebSnapshotID(input string) (*WebSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebSnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebSnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWebSnapshotIDInsensitively parses 'input' case-insensitively into a WebSnapshotId +// note: this method should only be used for API response data and not user input +func ParseWebSnapshotIDInsensitively(input string) (*WebSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebSnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebSnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WebSnapshotId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SnapshotId, ok = input.Parsed["snapshotId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotId", input) + } + + return nil +} + +// ValidateWebSnapshotID checks that 'input' can be parsed as a Web Snapshot ID +func ValidateWebSnapshotID(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 := ParseWebSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Web Snapshot ID +func (id WebSnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/web/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SnapshotId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Web Snapshot ID +func (id WebSnapshotId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotValue"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticWeb", "web", "web"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotId", "snapshotIdValue"), + } +} + +// String returns a human-readable description of this Web Snapshot ID +func (id WebSnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Snapshot: %q", id.SnapshotId), + } + return fmt.Sprintf("Web Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_websnapshot_test.go b/resource-manager/web/2023-12-01/webapps/id_websnapshot_test.go new file mode 100644 index 00000000000..3f1596b334d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_websnapshot_test.go @@ -0,0 +1,402 @@ +package webapps + +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 = &WebSnapshotId{} + +func TestNewWebSnapshotID(t *testing.T) { + id := NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "snapshotIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.SlotName != "slotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotValue") + } + + if id.SnapshotId != "snapshotIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotId'", id.SnapshotId, "snapshotIdValue") + } +} + +func TestFormatWebSnapshotID(t *testing.T) { + actual := NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "slotValue", "snapshotIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web/snapshots/snapshotIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWebSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebSnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web/snapshots/snapshotIdValue", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + SnapshotId: "snapshotIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web/snapshots/snapshotIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebSnapshotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestParseWebSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebSnapshotId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/wEb/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web/snapshots/snapshotIdValue", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + SlotName: "slotValue", + SnapshotId: "snapshotIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/slots/slotValue/config/web/snapshots/snapshotIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiDvAlUe", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + SlotName: "sLoTvAlUe", + SnapshotId: "sNaPsHoTiDvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/sLoTs/sLoTvAlUe/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebSnapshotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestSegmentsForWebSnapshotId(t *testing.T) { + segments := WebSnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WebSnapshotId 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/web/2023-12-01/webapps/id_workflow.go b/resource-manager/web/2023-12-01/webapps/id_workflow.go new file mode 100644 index 00000000000..4519773f55f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_workflow.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkflowId{}) +} + +var _ resourceids.ResourceId = &WorkflowId{} + +// WorkflowId is a struct representing the Resource ID for a Workflow +type WorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewWorkflowID returns a new WorkflowId struct +func NewWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) WorkflowId { + return WorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseWorkflowID parses 'input' into a WorkflowId +func ParseWorkflowID(input string) (*WorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkflowIDInsensitively parses 'input' case-insensitively into a WorkflowId +// note: this method should only be used for API response data and not user input +func ParseWorkflowIDInsensitively(input string) (*WorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateWorkflowID checks that 'input' can be parsed as a Workflow ID +func ValidateWorkflowID(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 := ParseWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workflow ID +func (id WorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workflow ID +func (id WorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + } +} + +// String returns a human-readable description of this Workflow ID +func (id WorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/webapps/id_workflow_test.go b/resource-manager/web/2023-12-01/webapps/id_workflow_test.go new file mode 100644 index 00000000000..cbcd55682b3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/id_workflow_test.go @@ -0,0 +1,327 @@ +package webapps + +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 = &WorkflowId{} + +func TestNewWorkflowID(t *testing.T) { + id := NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } +} + +func TestFormatWorkflowID(t *testing.T) { + actual := NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/workflows/workflowValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/workflows/workflowValue", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/workflows/workflowValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/workflows/workflowValue", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/workflows/workflowValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/wOrKfLoWs/wOrKfLoWvAlUe", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/wOrKfLoWs/wOrKfLoWvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForWorkflowId(t *testing.T) { + segments := WorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkflowId 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/web/2023-12-01/webapps/method_addpremieraddon.go b/resource-manager/web/2023-12-01/webapps/method_addpremieraddon.go new file mode 100644 index 00000000000..7faf7f7e01c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_addpremieraddon.go @@ -0,0 +1,58 @@ +package webapps + +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 AddPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOn ... +func (c WebAppsClient) AddPremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOn) (result AddPremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_addpremieraddonslot.go b/resource-manager/web/2023-12-01/webapps/method_addpremieraddonslot.go new file mode 100644 index 00000000000..5a4fa5470e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_addpremieraddonslot.go @@ -0,0 +1,58 @@ +package webapps + +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 AddPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOnSlot ... +func (c WebAppsClient) AddPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOn) (result AddPremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_analyzecustomhostname.go b/resource-manager/web/2023-12-01/webapps/method_analyzecustomhostname.go new file mode 100644 index 00000000000..6f783084cf7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_analyzecustomhostname.go @@ -0,0 +1,84 @@ +package webapps + +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 AnalyzeCustomHostnameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameOperationOptions() AnalyzeCustomHostnameOperationOptions { + return AnalyzeCustomHostnameOperationOptions{} +} + +func (o AnalyzeCustomHostnameOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostname ... +func (c WebAppsClient) AnalyzeCustomHostname(ctx context.Context, id commonids.AppServiceId, options AnalyzeCustomHostnameOperationOptions) (result AnalyzeCustomHostnameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyzeCustomHostname", 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 + } + + var model CustomHostnameAnalysisResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_analyzecustomhostnameslot.go b/resource-manager/web/2023-12-01/webapps/method_analyzecustomhostnameslot.go new file mode 100644 index 00000000000..a0f093109eb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_analyzecustomhostnameslot.go @@ -0,0 +1,83 @@ +package webapps + +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 AnalyzeCustomHostnameSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameSlotOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameSlotOperationOptions() AnalyzeCustomHostnameSlotOperationOptions { + return AnalyzeCustomHostnameSlotOperationOptions{} +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostnameSlot ... +func (c WebAppsClient) AnalyzeCustomHostnameSlot(ctx context.Context, id SlotId, options AnalyzeCustomHostnameSlotOperationOptions) (result AnalyzeCustomHostnameSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/analyzeCustomHostname", 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 + } + + var model CustomHostnameAnalysisResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_applyslotconfigtoproduction.go b/resource-manager/web/2023-12-01/webapps/method_applyslotconfigtoproduction.go new file mode 100644 index 00000000000..8a4030be7ce --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_applyslotconfigtoproduction.go @@ -0,0 +1,52 @@ +package webapps + +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 ApplySlotConfigToProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigToProduction ... +func (c WebAppsClient) ApplySlotConfigToProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result ApplySlotConfigToProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_applyslotconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_applyslotconfigurationslot.go new file mode 100644 index 00000000000..a17a32e4ddb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_applyslotconfigurationslot.go @@ -0,0 +1,51 @@ +package webapps + +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 ApplySlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigurationSlot ... +func (c WebAppsClient) ApplySlotConfigurationSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ApplySlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..11c42e04fc1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package webapps + +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 ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, 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 +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnectionslot.go new file mode 100644 index 00000000000..92ad203c214 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_approveorrejectprivateendpointconnectionslot.go @@ -0,0 +1,75 @@ +package webapps + +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 ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnectionSlot ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse, 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 +} + +// ApproveOrRejectPrivateEndpointConnectionSlotThenPoll performs ApproveOrRejectPrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnectionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_backup.go b/resource-manager/web/2023-12-01/webapps/method_backup.go new file mode 100644 index 00000000000..e8c66757e12 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_backup.go @@ -0,0 +1,60 @@ +package webapps + +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 BackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// Backup ... +func (c WebAppsClient) Backup(ctx context.Context, id commonids.AppServiceId, input BackupRequest) (result BackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_backupslot.go b/resource-manager/web/2023-12-01/webapps/method_backupslot.go new file mode 100644 index 00000000000..81ab5d55571 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_backupslot.go @@ -0,0 +1,59 @@ +package webapps + +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 BackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// BackupSlot ... +func (c WebAppsClient) BackupSlot(ctx context.Context, id SlotId, input BackupRequest) (result BackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createdeployment.go b/resource-manager/web/2023-12-01/webapps/method_createdeployment.go new file mode 100644 index 00000000000..2be253afc7e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createdeployment.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeployment ... +func (c WebAppsClient) CreateDeployment(ctx context.Context, id DeploymentId, input Deployment) (result CreateDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createdeploymentslot.go b/resource-manager/web/2023-12-01/webapps/method_createdeploymentslot.go new file mode 100644 index 00000000000..6cf4e309a20 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createdeploymentslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeploymentSlot ... +func (c WebAppsClient) CreateDeploymentSlot(ctx context.Context, id SlotDeploymentId, input Deployment) (result CreateDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createfunction.go b/resource-manager/web/2023-12-01/webapps/method_createfunction.go new file mode 100644 index 00000000000..43f93d7412e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createfunction.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateFunctionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// CreateFunction ... +func (c WebAppsClient) CreateFunction(ctx context.Context, id FunctionId, input FunctionEnvelope) (result CreateFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// CreateFunctionThenPoll performs CreateFunction then polls until it's completed +func (c WebAppsClient) CreateFunctionThenPoll(ctx context.Context, id FunctionId, input FunctionEnvelope) error { + result, err := c.CreateFunction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateFunction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateFunction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createinstancefunctionslot.go b/resource-manager/web/2023-12-01/webapps/method_createinstancefunctionslot.go new file mode 100644 index 00000000000..7a4fc6b316e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createinstancefunctionslot.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateInstanceFunctionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// CreateInstanceFunctionSlot ... +func (c WebAppsClient) CreateInstanceFunctionSlot(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) (result CreateInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + 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 +} + +// CreateInstanceFunctionSlotThenPoll performs CreateInstanceFunctionSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceFunctionSlotThenPoll(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) error { + result, err := c.CreateInstanceFunctionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceFunctionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceFunctionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperation.go b/resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperation.go new file mode 100644 index 00000000000..f2335f4f87d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperation.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateInstanceMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateInstanceMSDeployOperation ... +func (c WebAppsClient) CreateInstanceMSDeployOperation(ctx context.Context, id InstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateInstanceMSDeployOperationThenPoll performs CreateInstanceMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationThenPoll(ctx context.Context, id InstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperationslot.go b/resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperationslot.go new file mode 100644 index 00000000000..3688efbb8d8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createinstancemsdeployoperationslot.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateInstanceMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateInstanceMSDeployOperationSlot ... +func (c WebAppsClient) CreateInstanceMSDeployOperationSlot(ctx context.Context, id SlotInstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateInstanceMSDeployOperationSlotThenPoll performs CreateInstanceMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationSlotThenPoll(ctx context.Context, id SlotInstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createmsdeployoperation.go b/resource-manager/web/2023-12-01/webapps/method_createmsdeployoperation.go new file mode 100644 index 00000000000..d6d6f41436d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createmsdeployoperation.go @@ -0,0 +1,75 @@ +package webapps + +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/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 CreateMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateMSDeployOperation ... +func (c WebAppsClient) CreateMSDeployOperation(ctx context.Context, id commonids.AppServiceId, input MSDeploy) (result CreateMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateMSDeployOperationThenPoll performs CreateMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationThenPoll(ctx context.Context, id commonids.AppServiceId, input MSDeploy) error { + result, err := c.CreateMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createmsdeployoperationslot.go b/resource-manager/web/2023-12-01/webapps/method_createmsdeployoperationslot.go new file mode 100644 index 00000000000..429022fa814 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createmsdeployoperationslot.go @@ -0,0 +1,74 @@ +package webapps + +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 CreateMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateMSDeployOperationSlot ... +func (c WebAppsClient) CreateMSDeployOperationSlot(ctx context.Context, id SlotId, input MSDeploy) (result CreateMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", 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 +} + +// CreateMSDeployOperationSlotThenPoll performs CreateMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationSlotThenPoll(ctx context.Context, id SlotId, input MSDeploy) error { + result, err := c.CreateMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createonedeployoperation.go b/resource-manager/web/2023-12-01/webapps/method_createonedeployoperation.go new file mode 100644 index 00000000000..38e5c6a38a1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createonedeployoperation.go @@ -0,0 +1,56 @@ +package webapps + +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 CreateOneDeployOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// CreateOneDeployOperation ... +func (c WebAppsClient) CreateOneDeployOperation(ctx context.Context, id commonids.AppServiceId) (result CreateOneDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/onedeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdate.go b/resource-manager/web/2023-12-01/webapps/method_createorupdate.go new file mode 100644 index 00000000000..31581cafbd5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdate.go @@ -0,0 +1,76 @@ +package webapps + +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/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// CreateOrUpdate ... +func (c WebAppsClient) CreateOrUpdate(ctx context.Context, id commonids.AppServiceId, input Site) (result CreateOrUpdateOperationResponse, 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 +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c WebAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServiceId, input Site) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdateconfiguration.go b/resource-manager/web/2023-12-01/webapps/method_createorupdateconfiguration.go new file mode 100644 index 00000000000..0949625e755 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdateconfiguration.go @@ -0,0 +1,60 @@ +package webapps + +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 CreateOrUpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfiguration ... +func (c WebAppsClient) CreateOrUpdateConfiguration(ctx context.Context, id commonids.AppServiceId, input SiteConfigResource) (result CreateOrUpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdateconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdateconfigurationslot.go new file mode 100644 index 00000000000..6d8c147b26c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdateconfigurationslot.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfigurationSlot ... +func (c WebAppsClient) CreateOrUpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result CreateOrUpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifier.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifier.go new file mode 100644 index 00000000000..42d7d52d965 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifier.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifierslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..1147ef7573e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatedomainownershipidentifierslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecret.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecret.go new file mode 100644 index 00000000000..2ed0a2ab525 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecret.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecret ... +func (c WebAppsClient) CreateOrUpdateFunctionSecret(ctx context.Context, id KeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecretslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecretslot.go new file mode 100644 index 00000000000..16ba00bde18 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatefunctionsecretslot.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecretSlot ... +func (c WebAppsClient) CreateOrUpdateFunctionSecretSlot(ctx context.Context, id FunctionKeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebinding.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebinding.go new file mode 100644 index 00000000000..b239472ab87 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebinding.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBinding ... +func (c WebAppsClient) CreateOrUpdateHostNameBinding(ctx context.Context, id HostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebindingslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebindingslot.go new file mode 100644 index 00000000000..ad9378dfe37 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostnamebindingslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBindingSlot ... +func (c WebAppsClient) CreateOrUpdateHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecret.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecret.go new file mode 100644 index 00000000000..191c579b5d8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecret.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecret ... +func (c WebAppsClient) CreateOrUpdateHostSecret(ctx context.Context, id DefaultId, input KeyInfo) (result CreateOrUpdateHostSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecretslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecretslot.go new file mode 100644 index 00000000000..f3badff4dfe --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatehostsecretslot.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecretSlot ... +func (c WebAppsClient) CreateOrUpdateHostSecretSlot(ctx context.Context, id HostDefaultId, input KeyInfo) (result CreateOrUpdateHostSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnection.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnection.go new file mode 100644 index 00000000000..74629a106ec --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnection.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnection ... +func (c WebAppsClient) CreateOrUpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnectionslot.go new file mode 100644 index 00000000000..c08c5ecf83b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatehybridconnectionslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificate.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificate.go new file mode 100644 index 00000000000..b25986d572e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificate.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdatePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificate ... +func (c WebAppsClient) CreateOrUpdatePublicCertificate(ctx context.Context, id PublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificateslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificateslot.go new file mode 100644 index 00000000000..ec82a67e3a3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatepubliccertificateslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdatePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificateSlot ... +func (c WebAppsClient) CreateOrUpdatePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnection.go b/resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnection.go new file mode 100644 index 00000000000..0e475ea9495 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnection.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnection ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..df30da026a8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdaterelayserviceconnectionslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainer.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainer.go new file mode 100644 index 00000000000..5d5cf5440eb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainer.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// CreateOrUpdateSiteContainer ... +func (c WebAppsClient) CreateOrUpdateSiteContainer(ctx context.Context, id SitecontainerId, input SiteContainer) (result CreateOrUpdateSiteContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainerslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainerslot.go new file mode 100644 index 00000000000..2c906d04f91 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatesitecontainerslot.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// CreateOrUpdateSiteContainerSlot ... +func (c WebAppsClient) CreateOrUpdateSiteContainerSlot(ctx context.Context, id SlotSitecontainerId, input SiteContainer) (result CreateOrUpdateSiteContainerSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdateslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdateslot.go new file mode 100644 index 00000000000..3ab93dcea61 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdateslot.go @@ -0,0 +1,75 @@ +package webapps + +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 CreateOrUpdateSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// CreateOrUpdateSlot ... +func (c WebAppsClient) CreateOrUpdateSlot(ctx context.Context, id SlotId, input Site) (result CreateOrUpdateSlotOperationResponse, 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 +} + +// CreateOrUpdateSlotThenPoll performs CreateOrUpdateSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSlotThenPoll(ctx context.Context, id SlotId, input Site) error { + result, err := c.CreateOrUpdateSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrol.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrol.go new file mode 100644 index 00000000000..6c883f15851 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrol.go @@ -0,0 +1,77 @@ +package webapps + +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/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 CreateOrUpdateSourceControlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// CreateOrUpdateSourceControl ... +func (c WebAppsClient) CreateOrUpdateSourceControl(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) (result CreateOrUpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} + +// CreateOrUpdateSourceControlThenPoll performs CreateOrUpdateSourceControl then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlThenPoll(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControl(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControl: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControl: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrolslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrolslot.go new file mode 100644 index 00000000000..aa82d5d4811 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatesourcecontrolslot.go @@ -0,0 +1,76 @@ +package webapps + +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 CreateOrUpdateSourceControlSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// CreateOrUpdateSourceControlSlot ... +func (c WebAppsClient) CreateOrUpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result CreateOrUpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", 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 +} + +// CreateOrUpdateSourceControlSlotThenPoll performs CreateOrUpdateSourceControlSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlSlotThenPoll(ctx context.Context, id SlotId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControlSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControlSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControlSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..d2c9fca2d78 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,60 @@ +package webapps + +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 CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id commonids.AppServiceId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..7ababeb64de --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,59 @@ +package webapps + +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 CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnection.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnection.go new file mode 100644 index 00000000000..c98acf2757f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnection.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnection ... +func (c WebAppsClient) CreateOrUpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongateway.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongateway.go new file mode 100644 index 00000000000..f7c2605a07d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongateway.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGateway ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongatewayslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..a4040491cd6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectiongatewayslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectionslot.go new file mode 100644 index 00000000000..060b5673b5a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_createorupdatevnetconnectionslot.go @@ -0,0 +1,58 @@ +package webapps + +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 CreateOrUpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_delete.go b/resource-manager/web/2023-12-01/webapps/method_delete.go new file mode 100644 index 00000000000..e9d88eba269 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_delete.go @@ -0,0 +1,81 @@ +package webapps + +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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +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.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// Delete ... +func (c WebAppsClient) Delete(ctx context.Context, id commonids.AppServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletebackup.go b/resource-manager/web/2023-12-01/webapps/method_deletebackup.go new file mode 100644 index 00000000000..b2335e64953 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletebackup.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackup ... +func (c WebAppsClient) DeleteBackup(ctx context.Context, id BackupId) (result DeleteBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletebackupconfiguration.go b/resource-manager/web/2023-12-01/webapps/method_deletebackupconfiguration.go new file mode 100644 index 00000000000..fe9d53c8236 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletebackupconfiguration.go @@ -0,0 +1,48 @@ +package webapps + +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 DeleteBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfiguration ... +func (c WebAppsClient) DeleteBackupConfiguration(ctx context.Context, id commonids.AppServiceId) (result DeleteBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletebackupconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_deletebackupconfigurationslot.go new file mode 100644 index 00000000000..e417eec9042 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletebackupconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfigurationSlot ... +func (c WebAppsClient) DeleteBackupConfigurationSlot(ctx context.Context, id SlotId) (result DeleteBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletebackupslot.go b/resource-manager/web/2023-12-01/webapps/method_deletebackupslot.go new file mode 100644 index 00000000000..42f5d96f9bb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletebackupslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupSlot ... +func (c WebAppsClient) DeleteBackupSlot(ctx context.Context, id SlotBackupId) (result DeleteBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjob.go b/resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjob.go new file mode 100644 index 00000000000..291bdb8bdb2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJob ... +func (c WebAppsClient) DeleteContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result DeleteContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjobslot.go new file mode 100644 index 00000000000..08d6fbcf7ce --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletecontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJobSlot ... +func (c WebAppsClient) DeleteContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result DeleteContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletedeployment.go b/resource-manager/web/2023-12-01/webapps/method_deletedeployment.go new file mode 100644 index 00000000000..602496fecbe --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletedeployment.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeployment ... +func (c WebAppsClient) DeleteDeployment(ctx context.Context, id DeploymentId) (result DeleteDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletedeploymentslot.go b/resource-manager/web/2023-12-01/webapps/method_deletedeploymentslot.go new file mode 100644 index 00000000000..dcc3d21bbd1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletedeploymentslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeploymentSlot ... +func (c WebAppsClient) DeleteDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result DeleteDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifier.go b/resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifier.go new file mode 100644 index 00000000000..c170a9280d7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifier.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifier ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifierslot.go b/resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifierslot.go new file mode 100644 index 00000000000..28567f8ab9e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletedomainownershipidentifierslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletefunction.go b/resource-manager/web/2023-12-01/webapps/method_deletefunction.go new file mode 100644 index 00000000000..63c737693dd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletefunction.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunction ... +func (c WebAppsClient) DeleteFunction(ctx context.Context, id FunctionId) (result DeleteFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletefunctionsecret.go b/resource-manager/web/2023-12-01/webapps/method_deletefunctionsecret.go new file mode 100644 index 00000000000..279dac44b09 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletefunctionsecret.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecret ... +func (c WebAppsClient) DeleteFunctionSecret(ctx context.Context, id KeyId) (result DeleteFunctionSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletefunctionsecretslot.go b/resource-manager/web/2023-12-01/webapps/method_deletefunctionsecretslot.go new file mode 100644 index 00000000000..048a7322039 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletefunctionsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecretSlot ... +func (c WebAppsClient) DeleteFunctionSecretSlot(ctx context.Context, id FunctionKeyId) (result DeleteFunctionSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletehostnamebinding.go b/resource-manager/web/2023-12-01/webapps/method_deletehostnamebinding.go new file mode 100644 index 00000000000..f41070632fb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletehostnamebinding.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBinding ... +func (c WebAppsClient) DeleteHostNameBinding(ctx context.Context, id HostNameBindingId) (result DeleteHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletehostnamebindingslot.go b/resource-manager/web/2023-12-01/webapps/method_deletehostnamebindingslot.go new file mode 100644 index 00000000000..f780f65c797 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletehostnamebindingslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBindingSlot ... +func (c WebAppsClient) DeleteHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result DeleteHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletehostsecret.go b/resource-manager/web/2023-12-01/webapps/method_deletehostsecret.go new file mode 100644 index 00000000000..f7140877326 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletehostsecret.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecret ... +func (c WebAppsClient) DeleteHostSecret(ctx context.Context, id DefaultId) (result DeleteHostSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletehostsecretslot.go b/resource-manager/web/2023-12-01/webapps/method_deletehostsecretslot.go new file mode 100644 index 00000000000..7b2feaf96f1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletehostsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecretSlot ... +func (c WebAppsClient) DeleteHostSecretSlot(ctx context.Context, id HostDefaultId) (result DeleteHostSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletehybridconnection.go b/resource-manager/web/2023-12-01/webapps/method_deletehybridconnection.go new file mode 100644 index 00000000000..4c59c6746f2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletehybridconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c WebAppsClient) DeleteHybridConnection(ctx context.Context, id RelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletehybridconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_deletehybridconnectionslot.go new file mode 100644 index 00000000000..e5cd0c8f8ef --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletehybridconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnectionSlot ... +func (c WebAppsClient) DeleteHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result DeleteHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteinstancefunctionslot.go b/resource-manager/web/2023-12-01/webapps/method_deleteinstancefunctionslot.go new file mode 100644 index 00000000000..b69048fa682 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteinstancefunctionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceFunctionSlot ... +func (c WebAppsClient) DeleteInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result DeleteInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocess.go b/resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocess.go new file mode 100644 index 00000000000..1f48c5d2ee7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocess.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcess ... +func (c WebAppsClient) DeleteInstanceProcess(ctx context.Context, id InstanceProcessId) (result DeleteInstanceProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocessslot.go b/resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocessslot.go new file mode 100644 index 00000000000..4a86b938433 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteinstanceprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcessSlot ... +func (c WebAppsClient) DeleteInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result DeleteInstanceProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletepremieraddon.go b/resource-manager/web/2023-12-01/webapps/method_deletepremieraddon.go new file mode 100644 index 00000000000..add6d111d1d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletepremieraddon.go @@ -0,0 +1,46 @@ +package webapps + +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 DeletePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOn ... +func (c WebAppsClient) DeletePremierAddOn(ctx context.Context, id PremierAddonId) (result DeletePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletepremieraddonslot.go b/resource-manager/web/2023-12-01/webapps/method_deletepremieraddonslot.go new file mode 100644 index 00000000000..e2e6333e3c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletepremieraddonslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeletePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOnSlot ... +func (c WebAppsClient) DeletePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result DeletePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnection.go b/resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f5b956958aa --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package webapps + +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 DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c WebAppsClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnectionslot.go new file mode 100644 index 00000000000..61bbf74e21d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteprivateendpointconnectionslot.go @@ -0,0 +1,72 @@ +package webapps + +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 DeletePrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnectionSlot ... +func (c WebAppsClient) DeletePrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + 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 +} + +// DeletePrivateEndpointConnectionSlotThenPoll performs DeletePrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnectionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteprocess.go b/resource-manager/web/2023-12-01/webapps/method_deleteprocess.go new file mode 100644 index 00000000000..e925942300c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteprocess.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcess ... +func (c WebAppsClient) DeleteProcess(ctx context.Context, id ProcessId) (result DeleteProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteprocessslot.go b/resource-manager/web/2023-12-01/webapps/method_deleteprocessslot.go new file mode 100644 index 00000000000..da7cb778e03 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcessSlot ... +func (c WebAppsClient) DeleteProcessSlot(ctx context.Context, id SlotProcessId) (result DeleteProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletepubliccertificate.go b/resource-manager/web/2023-12-01/webapps/method_deletepubliccertificate.go new file mode 100644 index 00000000000..8b04d322801 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletepubliccertificate.go @@ -0,0 +1,47 @@ +package webapps + +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 DeletePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificate ... +func (c WebAppsClient) DeletePublicCertificate(ctx context.Context, id PublicCertificateId) (result DeletePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletepubliccertificateslot.go b/resource-manager/web/2023-12-01/webapps/method_deletepubliccertificateslot.go new file mode 100644 index 00000000000..98fca6889bf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletepubliccertificateslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeletePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificateSlot ... +func (c WebAppsClient) DeletePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result DeletePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnection.go b/resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnection.go new file mode 100644 index 00000000000..be9ded1355d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnection ... +func (c WebAppsClient) DeleteRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result DeleteRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnectionslot.go new file mode 100644 index 00000000000..42eccd7e9f5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleterelayserviceconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnectionSlot ... +func (c WebAppsClient) DeleteRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result DeleteRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletesitecontainer.go b/resource-manager/web/2023-12-01/webapps/method_deletesitecontainer.go new file mode 100644 index 00000000000..ea860f567ef --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletesitecontainer.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteContainer ... +func (c WebAppsClient) DeleteSiteContainer(ctx context.Context, id SitecontainerId) (result DeleteSiteContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletesitecontainerslot.go b/resource-manager/web/2023-12-01/webapps/method_deletesitecontainerslot.go new file mode 100644 index 00000000000..f3ad5aa1a72 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletesitecontainerslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteContainerSlot ... +func (c WebAppsClient) DeleteSiteContainerSlot(ctx context.Context, id SlotSitecontainerId) (result DeleteSiteContainerSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletesiteextension.go b/resource-manager/web/2023-12-01/webapps/method_deletesiteextension.go new file mode 100644 index 00000000000..525f7419d0d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletesiteextension.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtension ... +func (c WebAppsClient) DeleteSiteExtension(ctx context.Context, id SiteExtensionId) (result DeleteSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletesiteextensionslot.go b/resource-manager/web/2023-12-01/webapps/method_deletesiteextensionslot.go new file mode 100644 index 00000000000..cad4ab2271e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletesiteextensionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtensionSlot ... +func (c WebAppsClient) DeleteSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result DeleteSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteslot.go b/resource-manager/web/2023-12-01/webapps/method_deleteslot.go new file mode 100644 index 00000000000..b134af54533 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteslot.go @@ -0,0 +1,80 @@ +package webapps + +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 DeleteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSlotOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +func DefaultDeleteSlotOperationOptions() DeleteSlotOperationOptions { + return DeleteSlotOperationOptions{} +} + +func (o DeleteSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// DeleteSlot ... +func (c WebAppsClient) DeleteSlot(ctx context.Context, id SlotId, options DeleteSlotOperationOptions) (result DeleteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletesourcecontrol.go b/resource-manager/web/2023-12-01/webapps/method_deletesourcecontrol.go new file mode 100644 index 00000000000..1de5d801f35 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletesourcecontrol.go @@ -0,0 +1,77 @@ +package webapps + +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 DeleteSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlOperationOptions() DeleteSourceControlOperationOptions { + return DeleteSourceControlOperationOptions{} +} + +func (o DeleteSourceControlOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteSourceControlOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControl ... +func (c WebAppsClient) DeleteSourceControl(ctx context.Context, id commonids.AppServiceId, options DeleteSourceControlOperationOptions) (result DeleteSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletesourcecontrolslot.go b/resource-manager/web/2023-12-01/webapps/method_deletesourcecontrolslot.go new file mode 100644 index 00000000000..58843d09923 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletesourcecontrolslot.go @@ -0,0 +1,76 @@ +package webapps + +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 DeleteSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlSlotOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlSlotOperationOptions() DeleteSourceControlSlotOperationOptions { + return DeleteSourceControlSlotOperationOptions{} +} + +func (o DeleteSourceControlSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControlSlot ... +func (c WebAppsClient) DeleteSourceControlSlot(ctx context.Context, id SlotId, options DeleteSourceControlSlotOperationOptions) (result DeleteSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/sourceControls/web", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetwork.go b/resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetwork.go new file mode 100644 index 00000000000..5f7c911990a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetwork.go @@ -0,0 +1,48 @@ +package webapps + +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 DeleteSwiftVirtualNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetwork ... +func (c WebAppsClient) DeleteSwiftVirtualNetwork(ctx context.Context, id commonids.AppServiceId) (result DeleteSwiftVirtualNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetworkslot.go b/resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetworkslot.go new file mode 100644 index 00000000000..a63702c17c3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deleteswiftvirtualnetworkslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteSwiftVirtualNetworkSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetworkSlot ... +func (c WebAppsClient) DeleteSwiftVirtualNetworkSlot(ctx context.Context, id SlotId) (result DeleteSwiftVirtualNetworkSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjob.go b/resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjob.go new file mode 100644 index 00000000000..c09a8a7cdcf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJob ... +func (c WebAppsClient) DeleteTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result DeleteTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjobslot.go new file mode 100644 index 00000000000..c9aa75af711 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletetriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 DeleteTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJobSlot ... +func (c WebAppsClient) DeleteTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result DeleteTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletevnetconnection.go b/resource-manager/web/2023-12-01/webapps/method_deletevnetconnection.go new file mode 100644 index 00000000000..09e001b1b8a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletevnetconnection.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnection ... +func (c WebAppsClient) DeleteVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result DeleteVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deletevnetconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_deletevnetconnectionslot.go new file mode 100644 index 00000000000..eb208686b5d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deletevnetconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +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 DeleteVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnectionSlot ... +func (c WebAppsClient) DeleteVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result DeleteVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deployworkflowartifacts.go b/resource-manager/web/2023-12-01/webapps/method_deployworkflowartifacts.go new file mode 100644 index 00000000000..8b6316e6292 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deployworkflowartifacts.go @@ -0,0 +1,52 @@ +package webapps + +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 DeployWorkflowArtifactsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifacts ... +func (c WebAppsClient) DeployWorkflowArtifacts(ctx context.Context, id commonids.AppServiceId, input WorkflowArtifacts) (result DeployWorkflowArtifactsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_deployworkflowartifactsslot.go b/resource-manager/web/2023-12-01/webapps/method_deployworkflowartifactsslot.go new file mode 100644 index 00000000000..86a6bd816b5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_deployworkflowartifactsslot.go @@ -0,0 +1,51 @@ +package webapps + +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 DeployWorkflowArtifactsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifactsSlot ... +func (c WebAppsClient) DeployWorkflowArtifactsSlot(ctx context.Context, id SlotId, input WorkflowArtifacts) (result DeployWorkflowArtifactsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_discoverbackup.go b/resource-manager/web/2023-12-01/webapps/method_discoverbackup.go new file mode 100644 index 00000000000..a1d107c462f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_discoverbackup.go @@ -0,0 +1,60 @@ +package webapps + +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 DiscoverBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackup ... +func (c WebAppsClient) DiscoverBackup(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) (result DiscoverBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RestoreRequest + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_discoverbackupslot.go b/resource-manager/web/2023-12-01/webapps/method_discoverbackupslot.go new file mode 100644 index 00000000000..15773ae16b5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_discoverbackupslot.go @@ -0,0 +1,59 @@ +package webapps + +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 DiscoverBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackupSlot ... +func (c WebAppsClient) DiscoverBackupSlot(ctx context.Context, id SlotId, input RestoreRequest) (result DiscoverBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RestoreRequest + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpassword.go b/resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpassword.go new file mode 100644 index 00000000000..6e02a601437 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpassword.go @@ -0,0 +1,49 @@ +package webapps + +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 GenerateNewSitePublishingPasswordOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPassword ... +func (c WebAppsClient) GenerateNewSitePublishingPassword(ctx context.Context, id commonids.AppServiceId) (result GenerateNewSitePublishingPasswordOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpasswordslot.go b/resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpasswordslot.go new file mode 100644 index 00000000000..71e052a00e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_generatenewsitepublishingpasswordslot.go @@ -0,0 +1,48 @@ +package webapps + +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 GenerateNewSitePublishingPasswordSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPasswordSlot ... +func (c WebAppsClient) GenerateNewSitePublishingPasswordSlot(ctx context.Context, id SlotId) (result GenerateNewSitePublishingPasswordSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_get.go b/resource-manager/web/2023-12-01/webapps/method_get.go new file mode 100644 index 00000000000..23962fb39aa --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_get.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Get ... +func (c WebAppsClient) Get(ctx context.Context, id commonids.AppServiceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreference.go b/resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreference.go new file mode 100644 index 00000000000..29c9f5b97a8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreference.go @@ -0,0 +1,54 @@ +package webapps + +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 GetAppSettingKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReference ... +func (c WebAppsClient) GetAppSettingKeyVaultReference(ctx context.Context, id AppSettingId) (result GetAppSettingKeyVaultReferenceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreferenceslot.go b/resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreferenceslot.go new file mode 100644 index 00000000000..4dd14572ebb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getappsettingkeyvaultreferenceslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetAppSettingKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReferenceSlot ... +func (c WebAppsClient) GetAppSettingKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceAppSettingId) (result GetAppSettingKeyVaultReferenceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferences.go b/resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferences.go new file mode 100644 index 00000000000..4b64207c3f6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferences.go @@ -0,0 +1,92 @@ +package webapps + +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 GetAppSettingsKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +// GetAppSettingsKeyVaultReferences ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferences(ctx context.Context, id commonids.AppServiceId) (result GetAppSettingsKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesComplete(ctx context.Context, id commonids.AppServiceId) (GetAppSettingsKeyVaultReferencesCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferences(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 = GetAppSettingsKeyVaultReferencesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferencesslot.go b/resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferencesslot.go new file mode 100644 index 00000000000..eae1d2dc5f9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getappsettingskeyvaultreferencesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 GetAppSettingsKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +// GetAppSettingsKeyVaultReferencesSlot ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetAppSettingsKeyVaultReferencesSlotCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferencesSlot(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 = GetAppSettingsKeyVaultReferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getauthsettings.go b/resource-manager/web/2023-12-01/webapps/method_getauthsettings.go new file mode 100644 index 00000000000..dab06c29867 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getauthsettings.go @@ -0,0 +1,56 @@ +package webapps + +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 GetAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettings ... +func (c WebAppsClient) GetAuthSettings(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getauthsettingsslot.go b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsslot.go new file mode 100644 index 00000000000..1a60695f628 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettingsSlot ... +func (c WebAppsClient) GetAuthSettingsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2.go b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2.go new file mode 100644 index 00000000000..fb5709f7073 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2.go @@ -0,0 +1,56 @@ +package webapps + +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 GetAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2 ... +func (c WebAppsClient) GetAuthSettingsV2(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2slot.go b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2slot.go new file mode 100644 index 00000000000..aa047a0dfd3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2slot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2Slot ... +func (c WebAppsClient) GetAuthSettingsV2Slot(ctx context.Context, id SlotId) (result GetAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecrets.go b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecrets.go new file mode 100644 index 00000000000..01bf74554cf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecrets.go @@ -0,0 +1,56 @@ +package webapps + +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 GetAuthSettingsV2WithoutSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecrets ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecrets(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsV2WithoutSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecretsslot.go b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecretsslot.go new file mode 100644 index 00000000000..77753e1df7a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getauthsettingsv2withoutsecretsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetAuthSettingsV2WithoutSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecretsSlot ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecretsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsV2WithoutSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getbackupconfiguration.go b/resource-manager/web/2023-12-01/webapps/method_getbackupconfiguration.go new file mode 100644 index 00000000000..2f529b24e69 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getbackupconfiguration.go @@ -0,0 +1,56 @@ +package webapps + +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 GetBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfiguration ... +func (c WebAppsClient) GetBackupConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getbackupconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_getbackupconfigurationslot.go new file mode 100644 index 00000000000..865164a69ac --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getbackupconfigurationslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfigurationSlot ... +func (c WebAppsClient) GetBackupConfigurationSlot(ctx context.Context, id SlotId) (result GetBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getbackupstatus.go b/resource-manager/web/2023-12-01/webapps/method_getbackupstatus.go new file mode 100644 index 00000000000..24a6bb275d0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getbackupstatus.go @@ -0,0 +1,54 @@ +package webapps + +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 GetBackupStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatus ... +func (c WebAppsClient) GetBackupStatus(ctx context.Context, id BackupId) (result GetBackupStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getbackupstatusslot.go b/resource-manager/web/2023-12-01/webapps/method_getbackupstatusslot.go new file mode 100644 index 00000000000..a56211ca854 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getbackupstatusslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetBackupStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatusSlot ... +func (c WebAppsClient) GetBackupStatusSlot(ctx context.Context, id SlotBackupId) (result GetBackupStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getconfiguration.go b/resource-manager/web/2023-12-01/webapps/method_getconfiguration.go new file mode 100644 index 00000000000..7651c296acf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getconfiguration.go @@ -0,0 +1,56 @@ +package webapps + +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 GetConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfiguration ... +func (c WebAppsClient) GetConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_getconfigurationslot.go new file mode 100644 index 00000000000..9b190aed52b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getconfigurationslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSlot ... +func (c WebAppsClient) GetConfigurationSlot(ctx context.Context, id SlotId) (result GetConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshot.go b/resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshot.go new file mode 100644 index 00000000000..0b163fa0d01 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshot ... +func (c WebAppsClient) GetConfigurationSnapshot(ctx context.Context, id SnapshotId) (result GetConfigurationSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshotslot.go b/resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshotslot.go new file mode 100644 index 00000000000..0923d5bafca --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getconfigurationsnapshotslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshotSlot ... +func (c WebAppsClient) GetConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result GetConfigurationSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getcontainerlogszip.go b/resource-manager/web/2023-12-01/webapps/method_getcontainerlogszip.go new file mode 100644 index 00000000000..2f8ced54505 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getcontainerlogszip.go @@ -0,0 +1,57 @@ +package webapps + +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 GetContainerLogsZipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZip ... +func (c WebAppsClient) GetContainerLogsZip(ctx context.Context, id commonids.AppServiceId) (result GetContainerLogsZipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getcontainerlogszipslot.go b/resource-manager/web/2023-12-01/webapps/method_getcontainerlogszipslot.go new file mode 100644 index 00000000000..7fa0bf62727 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getcontainerlogszipslot.go @@ -0,0 +1,56 @@ +package webapps + +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 GetContainerLogsZipSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZipSlot ... +func (c WebAppsClient) GetContainerLogsZipSlot(ctx context.Context, id SlotId) (result GetContainerLogsZipSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjob.go b/resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjob.go new file mode 100644 index 00000000000..9070b5b9190 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjob.go @@ -0,0 +1,54 @@ +package webapps + +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 GetContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJob ... +func (c WebAppsClient) GetContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result GetContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContinuousWebJob + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjobslot.go new file mode 100644 index 00000000000..647b7a57557 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getcontinuouswebjobslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJobSlot ... +func (c WebAppsClient) GetContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result GetContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContinuousWebJob + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getdeployment.go b/resource-manager/web/2023-12-01/webapps/method_getdeployment.go new file mode 100644 index 00000000000..02efcfee65f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getdeployment.go @@ -0,0 +1,54 @@ +package webapps + +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 GetDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeployment ... +func (c WebAppsClient) GetDeployment(ctx context.Context, id DeploymentId) (result GetDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getdeploymentslot.go b/resource-manager/web/2023-12-01/webapps/method_getdeploymentslot.go new file mode 100644 index 00000000000..f382ca1b97a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getdeploymentslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeploymentSlot ... +func (c WebAppsClient) GetDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result GetDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfiguration.go b/resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfiguration.go new file mode 100644 index 00000000000..2995cd9178b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfiguration.go @@ -0,0 +1,56 @@ +package webapps + +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 GetDiagnosticLogsConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfiguration ... +func (c WebAppsClient) GetDiagnosticLogsConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetDiagnosticLogsConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfigurationslot.go new file mode 100644 index 00000000000..ea9587ae477 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getdiagnosticlogsconfigurationslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetDiagnosticLogsConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfigurationSlot ... +func (c WebAppsClient) GetDiagnosticLogsConfigurationSlot(ctx context.Context, id SlotId) (result GetDiagnosticLogsConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifier.go b/resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifier.go new file mode 100644 index 00000000000..6b9014ae5b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifier.go @@ -0,0 +1,54 @@ +package webapps + +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 GetDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifier ... +func (c WebAppsClient) GetDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifierslot.go b/resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifierslot.go new file mode 100644 index 00000000000..5b5d7404532 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getdomainownershipidentifierslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) GetDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getftpallowed.go b/resource-manager/web/2023-12-01/webapps/method_getftpallowed.go new file mode 100644 index 00000000000..cb3b41f0b65 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getftpallowed.go @@ -0,0 +1,56 @@ +package webapps + +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 GetFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowed ... +func (c WebAppsClient) GetFtpAllowed(ctx context.Context, id commonids.AppServiceId) (result GetFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getftpallowedslot.go b/resource-manager/web/2023-12-01/webapps/method_getftpallowedslot.go new file mode 100644 index 00000000000..67419725f8e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getftpallowedslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowedSlot ... +func (c WebAppsClient) GetFtpAllowedSlot(ctx context.Context, id SlotId) (result GetFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getfunction.go b/resource-manager/web/2023-12-01/webapps/method_getfunction.go new file mode 100644 index 00000000000..91ccc8cdb31 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getfunction.go @@ -0,0 +1,54 @@ +package webapps + +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 GetFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetFunction ... +func (c WebAppsClient) GetFunction(ctx context.Context, id FunctionId) (result GetFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionEnvelope + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintoken.go b/resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintoken.go new file mode 100644 index 00000000000..319970db3c1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintoken.go @@ -0,0 +1,56 @@ +package webapps + +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 GetFunctionsAdminTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminToken ... +func (c WebAppsClient) GetFunctionsAdminToken(ctx context.Context, id commonids.AppServiceId) (result GetFunctionsAdminTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintokenslot.go b/resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintokenslot.go new file mode 100644 index 00000000000..71cbb37de0d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getfunctionsadmintokenslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetFunctionsAdminTokenSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminTokenSlot ... +func (c WebAppsClient) GetFunctionsAdminTokenSlot(ctx context.Context, id SlotId) (result GetFunctionsAdminTokenSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gethostnamebinding.go b/resource-manager/web/2023-12-01/webapps/method_gethostnamebinding.go new file mode 100644 index 00000000000..1f8ada5414d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gethostnamebinding.go @@ -0,0 +1,54 @@ +package webapps + +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 GetHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBinding ... +func (c WebAppsClient) GetHostNameBinding(ctx context.Context, id HostNameBindingId) (result GetHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gethostnamebindingslot.go b/resource-manager/web/2023-12-01/webapps/method_gethostnamebindingslot.go new file mode 100644 index 00000000000..acd9260e326 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gethostnamebindingslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBindingSlot ... +func (c WebAppsClient) GetHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result GetHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gethybridconnection.go b/resource-manager/web/2023-12-01/webapps/method_gethybridconnection.go new file mode 100644 index 00000000000..6824a6a3881 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gethybridconnection.go @@ -0,0 +1,54 @@ +package webapps + +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 GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c WebAppsClient) GetHybridConnection(ctx context.Context, id RelayId) (result GetHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gethybridconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_gethybridconnectionslot.go new file mode 100644 index 00000000000..a73bc3e506e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gethybridconnectionslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnectionSlot ... +func (c WebAppsClient) GetHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result GetHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstancefunctionslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstancefunctionslot.go new file mode 100644 index 00000000000..ac388ddbe1e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstancefunctionslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetInstanceFunctionSlot ... +func (c WebAppsClient) GetInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result GetInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionEnvelope + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceinfo.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceinfo.go new file mode 100644 index 00000000000..ccab5c5b65b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceinfo.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfo ... +func (c WebAppsClient) GetInstanceInfo(ctx context.Context, id InstanceId) (result GetInstanceInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebSiteInstanceStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceinfoslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceinfoslot.go new file mode 100644 index 00000000000..eca65b26f1d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceinfoslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfoSlot ... +func (c WebAppsClient) GetInstanceInfoSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceInfoSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebSiteInstanceStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylog.go b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylog.go new file mode 100644 index 00000000000..54d4380e6c3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylog.go @@ -0,0 +1,55 @@ +package webapps + +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 GetInstanceMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLog ... +func (c WebAppsClient) GetInstanceMSDeployLog(ctx context.Context, id InstanceId) (result GetInstanceMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylogslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylogslot.go new file mode 100644 index 00000000000..3e41c70cf7e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploylogslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetInstanceMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLogSlot ... +func (c WebAppsClient) GetInstanceMSDeployLogSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatus.go b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatus.go new file mode 100644 index 00000000000..3516dc8c1f0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatus.go @@ -0,0 +1,55 @@ +package webapps + +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 GetInstanceMsDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatus ... +func (c WebAppsClient) GetInstanceMsDeployStatus(ctx context.Context, id InstanceId) (result GetInstanceMsDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatusslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatusslot.go new file mode 100644 index 00000000000..12bfe3d0fcf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstancemsdeploystatusslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetInstanceMsDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatusSlot ... +func (c WebAppsClient) GetInstanceMsDeployStatusSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMsDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceprocess.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocess.go new file mode 100644 index 00000000000..7d686bc51f8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocess.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcess ... +func (c WebAppsClient) GetInstanceProcess(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdump.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdump.go new file mode 100644 index 00000000000..97c4de7e3d5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdump.go @@ -0,0 +1,55 @@ +package webapps + +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 GetInstanceProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDump ... +func (c WebAppsClient) GetInstanceProcessDump(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdumpslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdumpslot.go new file mode 100644 index 00000000000..e32d3e6a2a8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessdumpslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetInstanceProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDumpSlot ... +func (c WebAppsClient) GetInstanceProcessDumpSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmodule.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmodule.go new file mode 100644 index 00000000000..b529a1ca714 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmodule.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModule ... +func (c WebAppsClient) GetInstanceProcessModule(ctx context.Context, id InstanceProcessModuleId) (result GetInstanceProcessModuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmoduleslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmoduleslot.go new file mode 100644 index 00000000000..0e1009c3dce --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessmoduleslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModuleSlot ... +func (c WebAppsClient) GetInstanceProcessModuleSlot(ctx context.Context, id SlotInstanceProcessModuleId) (result GetInstanceProcessModuleSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessslot.go new file mode 100644 index 00000000000..fc66e9a0fac --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceprocessslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcessSlot ... +func (c WebAppsClient) GetInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getinstanceworkflowslot.go b/resource-manager/web/2023-12-01/webapps/method_getinstanceworkflowslot.go new file mode 100644 index 00000000000..3edbdf23848 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getinstanceworkflowslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetInstanceWorkflowSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetInstanceWorkflowSlot ... +func (c WebAppsClient) GetInstanceWorkflowSlot(ctx context.Context, id SlotWorkflowId) (result GetInstanceWorkflowSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatus.go b/resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatus.go new file mode 100644 index 00000000000..9186da2ddf1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatus.go @@ -0,0 +1,56 @@ +package webapps + +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 GetMigrateMySqlStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatus ... +func (c WebAppsClient) GetMigrateMySqlStatus(ctx context.Context, id commonids.AppServiceId) (result GetMigrateMySqlStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MigrateMySqlStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatusslot.go b/resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatusslot.go new file mode 100644 index 00000000000..1916a1c2f04 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getmigratemysqlstatusslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetMigrateMySqlStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatusSlot ... +func (c WebAppsClient) GetMigrateMySqlStatusSlot(ctx context.Context, id SlotId) (result GetMigrateMySqlStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MigrateMySqlStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getmsdeploylog.go b/resource-manager/web/2023-12-01/webapps/method_getmsdeploylog.go new file mode 100644 index 00000000000..1fec3d2b551 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getmsdeploylog.go @@ -0,0 +1,56 @@ +package webapps + +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 GetMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLog ... +func (c WebAppsClient) GetMSDeployLog(ctx context.Context, id commonids.AppServiceId) (result GetMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getmsdeploylogslot.go b/resource-manager/web/2023-12-01/webapps/method_getmsdeploylogslot.go new file mode 100644 index 00000000000..a7148235787 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getmsdeploylogslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLogSlot ... +func (c WebAppsClient) GetMSDeployLogSlot(ctx context.Context, id SlotId) (result GetMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getmsdeploystatus.go b/resource-manager/web/2023-12-01/webapps/method_getmsdeploystatus.go new file mode 100644 index 00000000000..79957b82c58 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getmsdeploystatus.go @@ -0,0 +1,56 @@ +package webapps + +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 GetMSDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatus ... +func (c WebAppsClient) GetMSDeployStatus(ctx context.Context, id commonids.AppServiceId) (result GetMSDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getmsdeploystatusslot.go b/resource-manager/web/2023-12-01/webapps/method_getmsdeploystatusslot.go new file mode 100644 index 00000000000..33ee57e263f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getmsdeploystatusslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetMSDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatusSlot ... +func (c WebAppsClient) GetMSDeployStatusSlot(ctx context.Context, id SlotId) (result GetMSDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getnetworktraces.go b/resource-manager/web/2023-12-01/webapps/method_getnetworktraces.go new file mode 100644 index 00000000000..05a761a58cf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getnetworktraces.go @@ -0,0 +1,54 @@ +package webapps + +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 GetNetworkTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTraces ... +func (c WebAppsClient) GetNetworkTraces(ctx context.Context, id NetworkTraceId) (result GetNetworkTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getnetworktracesslot.go b/resource-manager/web/2023-12-01/webapps/method_getnetworktracesslot.go new file mode 100644 index 00000000000..fac98d3e21a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getnetworktracesslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetNetworkTracesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlot ... +func (c WebAppsClient) GetNetworkTracesSlot(ctx context.Context, id SlotNetworkTraceId) (result GetNetworkTracesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getnetworktracesslotv2.go b/resource-manager/web/2023-12-01/webapps/method_getnetworktracesslotv2.go new file mode 100644 index 00000000000..f4cfa7b0265 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getnetworktracesslotv2.go @@ -0,0 +1,54 @@ +package webapps + +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 GetNetworkTracesSlotV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlotV2 ... +func (c WebAppsClient) GetNetworkTracesSlotV2(ctx context.Context, id SiteSlotNetworkTraceId) (result GetNetworkTracesSlotV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getnetworktracesv2.go b/resource-manager/web/2023-12-01/webapps/method_getnetworktracesv2.go new file mode 100644 index 00000000000..075b0ec98e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getnetworktracesv2.go @@ -0,0 +1,54 @@ +package webapps + +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 GetNetworkTracesV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesV2 ... +func (c WebAppsClient) GetNetworkTracesV2(ctx context.Context, id SiteNetworkTraceId) (result GetNetworkTracesV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getonedeploystatus.go b/resource-manager/web/2023-12-01/webapps/method_getonedeploystatus.go new file mode 100644 index 00000000000..0192ff89661 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getonedeploystatus.go @@ -0,0 +1,56 @@ +package webapps + +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 GetOneDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetOneDeployStatus ... +func (c WebAppsClient) GetOneDeployStatus(ctx context.Context, id commonids.AppServiceId) (result GetOneDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/onedeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getpremieraddon.go b/resource-manager/web/2023-12-01/webapps/method_getpremieraddon.go new file mode 100644 index 00000000000..3a5194b7b4b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getpremieraddon.go @@ -0,0 +1,54 @@ +package webapps + +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 GetPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOn ... +func (c WebAppsClient) GetPremierAddOn(ctx context.Context, id PremierAddonId) (result GetPremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getpremieraddonslot.go b/resource-manager/web/2023-12-01/webapps/method_getpremieraddonslot.go new file mode 100644 index 00000000000..56055107545 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getpremieraddonslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOnSlot ... +func (c WebAppsClient) GetPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result GetPremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivateaccess.go b/resource-manager/web/2023-12-01/webapps/method_getprivateaccess.go new file mode 100644 index 00000000000..dce43e8e8df --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivateaccess.go @@ -0,0 +1,56 @@ +package webapps + +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 GetPrivateAccessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccess ... +func (c WebAppsClient) GetPrivateAccess(ctx context.Context, id commonids.AppServiceId) (result GetPrivateAccessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivateaccessslot.go b/resource-manager/web/2023-12-01/webapps/method_getprivateaccessslot.go new file mode 100644 index 00000000000..bfb25e1f581 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivateaccessslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetPrivateAccessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccessSlot ... +func (c WebAppsClient) GetPrivateAccessSlot(ctx context.Context, id SlotId) (result GetPrivateAccessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnection.go b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..26c7871fbbf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnection.go @@ -0,0 +1,54 @@ +package webapps + +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 GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c WebAppsClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlist.go b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..79964d41fe9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlist.go @@ -0,0 +1,92 @@ +package webapps + +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 GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionList ... +func (c WebAppsClient) GetPrivateEndpointConnectionList(ctx context.Context, id commonids.AppServiceId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id commonids.AppServiceId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(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 = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlistslot.go b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlistslot.go new file mode 100644 index 00000000000..18f7a9bf77e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionlistslot.go @@ -0,0 +1,91 @@ +package webapps + +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 GetPrivateEndpointConnectionListSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionListSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionListSlot(ctx context.Context, id SlotId) (result GetPrivateEndpointConnectionListSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", 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 *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotComplete(ctx context.Context, id SlotId) (GetPrivateEndpointConnectionListSlotCompleteResult, error) { + return c.GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListSlotCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionListSlot(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 = GetPrivateEndpointConnectionListSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionslot.go new file mode 100644 index 00000000000..9c25a41677f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivateendpointconnectionslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetPrivateEndpointConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivatelinkresources.go b/resource-manager/web/2023-12-01/webapps/method_getprivatelinkresources.go new file mode 100644 index 00000000000..667be0c0c72 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivatelinkresources.go @@ -0,0 +1,56 @@ +package webapps + +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 GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c WebAppsClient) GetPrivateLinkResources(ctx context.Context, id commonids.AppServiceId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprivatelinkresourcesslot.go b/resource-manager/web/2023-12-01/webapps/method_getprivatelinkresourcesslot.go new file mode 100644 index 00000000000..d2b79716d14 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprivatelinkresourcesslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetPrivateLinkResourcesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResourcesSlot ... +func (c WebAppsClient) GetPrivateLinkResourcesSlot(ctx context.Context, id SlotId) (result GetPrivateLinkResourcesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprocess.go b/resource-manager/web/2023-12-01/webapps/method_getprocess.go new file mode 100644 index 00000000000..42442c0b292 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprocess.go @@ -0,0 +1,54 @@ +package webapps + +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 GetProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcess ... +func (c WebAppsClient) GetProcess(ctx context.Context, id ProcessId) (result GetProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprocessdump.go b/resource-manager/web/2023-12-01/webapps/method_getprocessdump.go new file mode 100644 index 00000000000..e4ed77f79f6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprocessdump.go @@ -0,0 +1,55 @@ +package webapps + +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 GetProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDump ... +func (c WebAppsClient) GetProcessDump(ctx context.Context, id ProcessId) (result GetProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprocessdumpslot.go b/resource-manager/web/2023-12-01/webapps/method_getprocessdumpslot.go new file mode 100644 index 00000000000..c46e7a62c3d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprocessdumpslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDumpSlot ... +func (c WebAppsClient) GetProcessDumpSlot(ctx context.Context, id SlotProcessId) (result GetProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprocessmodule.go b/resource-manager/web/2023-12-01/webapps/method_getprocessmodule.go new file mode 100644 index 00000000000..b69821fe4ba --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprocessmodule.go @@ -0,0 +1,54 @@ +package webapps + +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 GetProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModule ... +func (c WebAppsClient) GetProcessModule(ctx context.Context, id ModuleId) (result GetProcessModuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprocessmoduleslot.go b/resource-manager/web/2023-12-01/webapps/method_getprocessmoduleslot.go new file mode 100644 index 00000000000..6e1e3d05fc7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprocessmoduleslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModuleSlot ... +func (c WebAppsClient) GetProcessModuleSlot(ctx context.Context, id ProcessModuleId) (result GetProcessModuleSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getprocessslot.go b/resource-manager/web/2023-12-01/webapps/method_getprocessslot.go new file mode 100644 index 00000000000..6d688c86119 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getprocessslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcessSlot ... +func (c WebAppsClient) GetProcessSlot(ctx context.Context, id SlotProcessId) (result GetProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getpubliccertificate.go b/resource-manager/web/2023-12-01/webapps/method_getpubliccertificate.go new file mode 100644 index 00000000000..294c7a1c1cd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getpubliccertificate.go @@ -0,0 +1,54 @@ +package webapps + +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 GetPublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificate ... +func (c WebAppsClient) GetPublicCertificate(ctx context.Context, id PublicCertificateId) (result GetPublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getpubliccertificateslot.go b/resource-manager/web/2023-12-01/webapps/method_getpubliccertificateslot.go new file mode 100644 index 00000000000..20a409afcce --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getpubliccertificateslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetPublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificateSlot ... +func (c WebAppsClient) GetPublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result GetPublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnection.go b/resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnection.go new file mode 100644 index 00000000000..e709d3033c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnection.go @@ -0,0 +1,54 @@ +package webapps + +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 GetRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnection ... +func (c WebAppsClient) GetRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result GetRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnectionslot.go new file mode 100644 index 00000000000..5cf0fc7ce2e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getrelayserviceconnectionslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnectionSlot ... +func (c WebAppsClient) GetRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result GetRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getscmallowed.go b/resource-manager/web/2023-12-01/webapps/method_getscmallowed.go new file mode 100644 index 00000000000..588b11ec267 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getscmallowed.go @@ -0,0 +1,56 @@ +package webapps + +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 GetScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowed ... +func (c WebAppsClient) GetScmAllowed(ctx context.Context, id commonids.AppServiceId) (result GetScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getscmallowedslot.go b/resource-manager/web/2023-12-01/webapps/method_getscmallowedslot.go new file mode 100644 index 00000000000..3dd063f8aca --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getscmallowedslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowedSlot ... +func (c WebAppsClient) GetScmAllowedSlot(ctx context.Context, id SlotId) (result GetScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreference.go b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreference.go new file mode 100644 index 00000000000..547724012d7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreference.go @@ -0,0 +1,54 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReference ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReference(ctx context.Context, id ConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go new file mode 100644 index 00000000000..6749fe2d8f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go @@ -0,0 +1,92 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferences ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferences(ctx context.Context, id commonids.AppServiceId) (result GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesComplete(ctx context.Context, id commonids.AppServiceId) (GetSiteConnectionStringKeyVaultReferencesCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferences(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 = GetSiteConnectionStringKeyVaultReferencesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go new file mode 100644 index 00000000000..ae2b9b61258 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferenceSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go new file mode 100644 index 00000000000..b7318545dd1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferencesSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", 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 *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferencesSlot(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 = GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsitecontainer.go b/resource-manager/web/2023-12-01/webapps/method_getsitecontainer.go new file mode 100644 index 00000000000..9c4d7d78224 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsitecontainer.go @@ -0,0 +1,54 @@ +package webapps + +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 GetSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// GetSiteContainer ... +func (c WebAppsClient) GetSiteContainer(ctx context.Context, id SitecontainerId) (result GetSiteContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsitecontainerslot.go b/resource-manager/web/2023-12-01/webapps/method_getsitecontainerslot.go new file mode 100644 index 00000000000..dc65c943da9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsitecontainerslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// GetSiteContainerSlot ... +func (c WebAppsClient) GetSiteContainerSlot(ctx context.Context, id SlotSitecontainerId) (result GetSiteContainerSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsiteextension.go b/resource-manager/web/2023-12-01/webapps/method_getsiteextension.go new file mode 100644 index 00000000000..e4a475e766d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsiteextension.go @@ -0,0 +1,54 @@ +package webapps + +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 GetSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtension ... +func (c WebAppsClient) GetSiteExtension(ctx context.Context, id SiteExtensionId) (result GetSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteExtensionInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsiteextensionslot.go b/resource-manager/web/2023-12-01/webapps/method_getsiteextensionslot.go new file mode 100644 index 00000000000..1bae54da3e3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsiteextensionslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtensionSlot ... +func (c WebAppsClient) GetSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result GetSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteExtensionInfo + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflag.go b/resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflag.go new file mode 100644 index 00000000000..7f2d3f3ddd0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflag.go @@ -0,0 +1,56 @@ +package webapps + +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 GetSitePhpErrorLogFlagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlag ... +func (c WebAppsClient) GetSitePhpErrorLogFlag(ctx context.Context, id commonids.AppServiceId) (result GetSitePhpErrorLogFlagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SitePhpErrorLogFlag + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflagslot.go b/resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflagslot.go new file mode 100644 index 00000000000..170b11be7bc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsitephperrorlogflagslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetSitePhpErrorLogFlagSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlagSlot ... +func (c WebAppsClient) GetSitePhpErrorLogFlagSlot(ctx context.Context, id SlotId) (result GetSitePhpErrorLogFlagSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SitePhpErrorLogFlag + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getslot.go b/resource-manager/web/2023-12-01/webapps/method_getslot.go new file mode 100644 index 00000000000..fd2c98b535c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// GetSlot ... +func (c WebAppsClient) GetSlot(ctx context.Context, id SlotId) (result GetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsourcecontrol.go b/resource-manager/web/2023-12-01/webapps/method_getsourcecontrol.go new file mode 100644 index 00000000000..7679f9feaf0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsourcecontrol.go @@ -0,0 +1,58 @@ +package webapps + +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 GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControl ... +func (c WebAppsClient) GetSourceControl(ctx context.Context, id commonids.AppServiceId) (result GetSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getsourcecontrolslot.go b/resource-manager/web/2023-12-01/webapps/method_getsourcecontrolslot.go new file mode 100644 index 00000000000..d06bb3ad906 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getsourcecontrolslot.go @@ -0,0 +1,57 @@ +package webapps + +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 GetSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControlSlot ... +func (c WebAppsClient) GetSourceControlSlot(ctx context.Context, id SlotId) (result GetSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnection.go b/resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnection.go new file mode 100644 index 00000000000..1914aa45261 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnection.go @@ -0,0 +1,56 @@ +package webapps + +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 GetSwiftVirtualNetworkConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnection ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnection(ctx context.Context, id commonids.AppServiceId) (result GetSwiftVirtualNetworkConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnectionslot.go new file mode 100644 index 00000000000..8f25ed183cf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getswiftvirtualnetworkconnectionslot.go @@ -0,0 +1,55 @@ +package webapps + +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 GetSwiftVirtualNetworkConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnectionSlot ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnectionSlot(ctx context.Context, id SlotId) (result GetSwiftVirtualNetworkConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjob.go b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjob.go new file mode 100644 index 00000000000..fa85150bc22 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjob.go @@ -0,0 +1,54 @@ +package webapps + +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 GetTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJob ... +func (c WebAppsClient) GetTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result GetTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredWebJob + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistory.go b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistory.go new file mode 100644 index 00000000000..25d867bd171 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistory.go @@ -0,0 +1,54 @@ +package webapps + +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 GetTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistory ... +func (c WebAppsClient) GetTriggeredWebJobHistory(ctx context.Context, id HistoryId) (result GetTriggeredWebJobHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredJobHistory + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistoryslot.go b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..da1075c7ef8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobhistoryslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistorySlot ... +func (c WebAppsClient) GetTriggeredWebJobHistorySlot(ctx context.Context, id TriggeredWebJobHistoryId) (result GetTriggeredWebJobHistorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredJobHistory + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobslot.go new file mode 100644 index 00000000000..df601d6b8e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_gettriggeredwebjobslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJobSlot ... +func (c WebAppsClient) GetTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result GetTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredWebJob + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getvnetconnection.go b/resource-manager/web/2023-12-01/webapps/method_getvnetconnection.go new file mode 100644 index 00000000000..8cbb17041d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getvnetconnection.go @@ -0,0 +1,54 @@ +package webapps + +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 GetVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnection ... +func (c WebAppsClient) GetVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result GetVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongateway.go b/resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongateway.go new file mode 100644 index 00000000000..d7147b08b2f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongateway.go @@ -0,0 +1,54 @@ +package webapps + +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 GetVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGateway ... +func (c WebAppsClient) GetVnetConnectionGateway(ctx context.Context, id GatewayId) (result GetVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongatewayslot.go b/resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongatewayslot.go new file mode 100644 index 00000000000..e3f7ab94a05 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getvnetconnectiongatewayslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGatewaySlot ... +func (c WebAppsClient) GetVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId) (result GetVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getvnetconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_getvnetconnectionslot.go new file mode 100644 index 00000000000..225b53b1c19 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getvnetconnectionslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnectionSlot ... +func (c WebAppsClient) GetVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result GetVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getwebjob.go b/resource-manager/web/2023-12-01/webapps/method_getwebjob.go new file mode 100644 index 00000000000..1544e50a120 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getwebjob.go @@ -0,0 +1,54 @@ +package webapps + +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 GetWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJob ... +func (c WebAppsClient) GetWebJob(ctx context.Context, id WebJobId) (result GetWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebJob + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getwebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_getwebjobslot.go new file mode 100644 index 00000000000..12438b92757 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getwebjobslot.go @@ -0,0 +1,54 @@ +package webapps + +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 GetWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJobSlot ... +func (c WebAppsClient) GetWebJobSlot(ctx context.Context, id SlotWebJobId) (result GetWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebJob + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogs.go b/resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogs.go new file mode 100644 index 00000000000..a78a69fc9be --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogs.go @@ -0,0 +1,57 @@ +package webapps + +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 GetWebSiteContainerLogsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogs ... +func (c WebAppsClient) GetWebSiteContainerLogs(ctx context.Context, id commonids.AppServiceId) (result GetWebSiteContainerLogsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogsslot.go b/resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogsslot.go new file mode 100644 index 00000000000..6ab570eb78f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getwebsitecontainerlogsslot.go @@ -0,0 +1,56 @@ +package webapps + +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 GetWebSiteContainerLogsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogsSlot ... +func (c WebAppsClient) GetWebSiteContainerLogsSlot(ctx context.Context, id SlotId) (result GetWebSiteContainerLogsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_getworkflow.go b/resource-manager/web/2023-12-01/webapps/method_getworkflow.go new file mode 100644 index 00000000000..6bc23af103f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_getworkflow.go @@ -0,0 +1,54 @@ +package webapps + +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 GetWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetWorkflow ... +func (c WebAppsClient) GetWorkflow(ctx context.Context, id WorkflowId) (result GetWorkflowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_installsiteextension.go b/resource-manager/web/2023-12-01/webapps/method_installsiteextension.go new file mode 100644 index 00000000000..7e485b9878f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_installsiteextension.go @@ -0,0 +1,71 @@ +package webapps + +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 InstallSiteExtensionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// InstallSiteExtension ... +func (c WebAppsClient) InstallSiteExtension(ctx context.Context, id SiteExtensionId) (result InstallSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + 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 +} + +// InstallSiteExtensionThenPoll performs InstallSiteExtension then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionThenPoll(ctx context.Context, id SiteExtensionId) error { + result, err := c.InstallSiteExtension(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtension: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtension: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_installsiteextensionslot.go b/resource-manager/web/2023-12-01/webapps/method_installsiteextensionslot.go new file mode 100644 index 00000000000..4bea72555e7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_installsiteextensionslot.go @@ -0,0 +1,71 @@ +package webapps + +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 InstallSiteExtensionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// InstallSiteExtensionSlot ... +func (c WebAppsClient) InstallSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result InstallSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + 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 +} + +// InstallSiteExtensionSlotThenPoll performs InstallSiteExtensionSlot then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionSlotThenPoll(ctx context.Context, id SlotSiteExtensionId) error { + result, err := c.InstallSiteExtensionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtensionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtensionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_iscloneable.go b/resource-manager/web/2023-12-01/webapps/method_iscloneable.go new file mode 100644 index 00000000000..1dc89371c3b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_iscloneable.go @@ -0,0 +1,56 @@ +package webapps + +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 IsCloneableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneable ... +func (c WebAppsClient) IsCloneable(ctx context.Context, id commonids.AppServiceId) (result IsCloneableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteCloneability + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_iscloneableslot.go b/resource-manager/web/2023-12-01/webapps/method_iscloneableslot.go new file mode 100644 index 00000000000..c28faba968a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_iscloneableslot.go @@ -0,0 +1,55 @@ +package webapps + +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 IsCloneableSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneableSlot ... +func (c WebAppsClient) IsCloneableSlot(ctx context.Context, id SlotId) (result IsCloneableSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteCloneability + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_list.go b/resource-manager/web/2023-12-01/webapps/method_list.go new file mode 100644 index 00000000000..32d0551e7ea --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_list.go @@ -0,0 +1,92 @@ +package webapps + +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 *[]Site +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +// List ... +func (c WebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (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.Web/sites", 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 *[]Site `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 WebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Site, 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/web/2023-12-01/webapps/method_listapplicationsettings.go b/resource-manager/web/2023-12-01/webapps/method_listapplicationsettings.go new file mode 100644 index 00000000000..2fe6d0b596f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listapplicationsettings.go @@ -0,0 +1,56 @@ +package webapps + +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 ListApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettings ... +func (c WebAppsClient) ListApplicationSettings(ctx context.Context, id commonids.AppServiceId) (result ListApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listapplicationsettingsslot.go b/resource-manager/web/2023-12-01/webapps/method_listapplicationsettingsslot.go new file mode 100644 index 00000000000..afbe704c229 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listapplicationsettingsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettingsSlot ... +func (c WebAppsClient) ListApplicationSettingsSlot(ctx context.Context, id SlotId) (result ListApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listazurestorageaccounts.go b/resource-manager/web/2023-12-01/webapps/method_listazurestorageaccounts.go new file mode 100644 index 00000000000..022ded5e7f4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listazurestorageaccounts.go @@ -0,0 +1,56 @@ +package webapps + +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 ListAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccounts ... +func (c WebAppsClient) ListAzureStorageAccounts(ctx context.Context, id commonids.AppServiceId) (result ListAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listazurestorageaccountsslot.go b/resource-manager/web/2023-12-01/webapps/method_listazurestorageaccountsslot.go new file mode 100644 index 00000000000..1ae48f64d6f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listazurestorageaccountsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccountsSlot ... +func (c WebAppsClient) ListAzureStorageAccountsSlot(ctx context.Context, id SlotId) (result ListAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listbackups.go b/resource-manager/web/2023-12-01/webapps/method_listbackups.go new file mode 100644 index 00000000000..4311aff5422 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listbackups.go @@ -0,0 +1,92 @@ +package webapps + +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 ListBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +// ListBackups ... +func (c WebAppsClient) ListBackups(ctx context.Context, id commonids.AppServiceId) (result ListBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsComplete(ctx context.Context, id commonids.AppServiceId) (ListBackupsCompleteResult, error) { + return c.ListBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate BackupItemOperationPredicate) (result ListBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackups(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 = ListBackupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listbackupsslot.go b/resource-manager/web/2023-12-01/webapps/method_listbackupsslot.go new file mode 100644 index 00000000000..f283c27eefa --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listbackupsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +// ListBackupsSlot ... +func (c WebAppsClient) ListBackupsSlot(ctx context.Context, id SlotId) (result ListBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/backups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsSlotComplete(ctx context.Context, id SlotId) (ListBackupsSlotCompleteResult, error) { + return c.ListBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackupsSlot(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 = ListBackupsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listbackupstatussecrets.go b/resource-manager/web/2023-12-01/webapps/method_listbackupstatussecrets.go new file mode 100644 index 00000000000..3334a5ea20b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listbackupstatussecrets.go @@ -0,0 +1,59 @@ +package webapps + +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 ListBackupStatusSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecrets ... +func (c WebAppsClient) ListBackupStatusSecrets(ctx context.Context, id BackupId, input BackupRequest) (result ListBackupStatusSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listbackupstatussecretsslot.go b/resource-manager/web/2023-12-01/webapps/method_listbackupstatussecretsslot.go new file mode 100644 index 00000000000..36a85d16ed5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listbackupstatussecretsslot.go @@ -0,0 +1,59 @@ +package webapps + +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 ListBackupStatusSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecretsSlot ... +func (c WebAppsClient) ListBackupStatusSecretsSlot(ctx context.Context, id SlotBackupId, input BackupRequest) (result ListBackupStatusSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspolicies.go b/resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspolicies.go new file mode 100644 index 00000000000..73e2e87a5b6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspolicies.go @@ -0,0 +1,92 @@ +package webapps + +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 ListBasicPublishingCredentialsPoliciesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmPublishingCredentialsPoliciesEntity +} + +// ListBasicPublishingCredentialsPolicies ... +func (c WebAppsClient) ListBasicPublishingCredentialsPolicies(ctx context.Context, id commonids.AppServiceId) (result ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", 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 *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesComplete(ctx context.Context, id commonids.AppServiceId) (ListBasicPublishingCredentialsPoliciesCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPolicies(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 = ListBasicPublishingCredentialsPoliciesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go b/resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go new file mode 100644 index 00000000000..9a34f49d17c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListBasicPublishingCredentialsPoliciesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmPublishingCredentialsPoliciesEntity +} + +// ListBasicPublishingCredentialsPoliciesSlot ... +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlot(ctx context.Context, id SlotId) (result ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", 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 *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotComplete(ctx context.Context, id SlotId) (ListBasicPublishingCredentialsPoliciesSlotCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesSlotCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPoliciesSlot(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 = ListBasicPublishingCredentialsPoliciesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listbyresourcegroup.go b/resource-manager/web/2023-12-01/webapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d5475954c3c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listbyresourcegroup.go @@ -0,0 +1,120 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListByResourceGroupOperationOptions struct { + IncludeSlots *bool +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeSlots != nil { + out.Append("includeSlots", fmt.Sprintf("%v", *o.IncludeSlots)) + } + return &out +} + +// ListByResourceGroup ... +func (c WebAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/sites", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c WebAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate SiteOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listconfigurations.go b/resource-manager/web/2023-12-01/webapps/method_listconfigurations.go new file mode 100644 index 00000000000..d4060b6f52c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listconfigurations.go @@ -0,0 +1,92 @@ +package webapps + +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 ListConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigResource +} + +// ListConfigurations ... +func (c WebAppsClient) ListConfigurations(ctx context.Context, id commonids.AppServiceId) (result ListConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config", 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 *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsComplete(ctx context.Context, id commonids.AppServiceId) (ListConfigurationsCompleteResult, error) { + return c.ListConfigurationsCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurations(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 = ListConfigurationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfo.go b/resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfo.go new file mode 100644 index 00000000000..950fb41c2b5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfo.go @@ -0,0 +1,92 @@ +package webapps + +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 ListConfigurationSnapshotInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigurationSnapshotInfo +} + +// ListConfigurationSnapshotInfo ... +func (c WebAppsClient) ListConfigurationSnapshotInfo(ctx context.Context, id commonids.AppServiceId) (result ListConfigurationSnapshotInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web/snapshots", 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 *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoComplete(ctx context.Context, id commonids.AppServiceId) (ListConfigurationSnapshotInfoCompleteResult, error) { + return c.ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfo(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 = ListConfigurationSnapshotInfoCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfoslot.go b/resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfoslot.go new file mode 100644 index 00000000000..1f9806f46a2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listconfigurationsnapshotinfoslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListConfigurationSnapshotInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigurationSnapshotInfo +} + +// ListConfigurationSnapshotInfoSlot ... +func (c WebAppsClient) ListConfigurationSnapshotInfoSlot(ctx context.Context, id SlotId) (result ListConfigurationSnapshotInfoSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web/snapshots", 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 *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotComplete(ctx context.Context, id SlotId) (ListConfigurationSnapshotInfoSlotCompleteResult, error) { + return c.ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoSlotCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfoSlot(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 = ListConfigurationSnapshotInfoSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listconfigurationsslot.go b/resource-manager/web/2023-12-01/webapps/method_listconfigurationsslot.go new file mode 100644 index 00000000000..37809ace4e9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listconfigurationsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListConfigurationsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigResource +} + +// ListConfigurationsSlot ... +func (c WebAppsClient) ListConfigurationsSlot(ctx context.Context, id SlotId) (result ListConfigurationsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config", 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 *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsSlotComplete(ctx context.Context, id SlotId) (ListConfigurationsSlotCompleteResult, error) { + return c.ListConfigurationsSlotCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsSlotCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurationsSlot(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 = ListConfigurationsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listconnectionstrings.go b/resource-manager/web/2023-12-01/webapps/method_listconnectionstrings.go new file mode 100644 index 00000000000..dedfccfc4dc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listconnectionstrings.go @@ -0,0 +1,56 @@ +package webapps + +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 ListConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStrings ... +func (c WebAppsClient) ListConnectionStrings(ctx context.Context, id commonids.AppServiceId) (result ListConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listconnectionstringsslot.go b/resource-manager/web/2023-12-01/webapps/method_listconnectionstringsslot.go new file mode 100644 index 00000000000..3498220d398 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listconnectionstringsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStringsSlot ... +func (c WebAppsClient) ListConnectionStringsSlot(ctx context.Context, id SlotId) (result ListConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobs.go b/resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobs.go new file mode 100644 index 00000000000..04cd482dc9f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobs.go @@ -0,0 +1,92 @@ +package webapps + +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 ListContinuousWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContinuousWebJob +} + +// ListContinuousWebJobs ... +func (c WebAppsClient) ListContinuousWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListContinuousWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/continuousWebJobs", 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 *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListContinuousWebJobsCompleteResult, error) { + return c.ListContinuousWebJobsCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobs(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 = ListContinuousWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobsslot.go b/resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobsslot.go new file mode 100644 index 00000000000..e0a7b01f5be --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listcontinuouswebjobsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListContinuousWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContinuousWebJob +} + +// ListContinuousWebJobsSlot ... +func (c WebAppsClient) ListContinuousWebJobsSlot(ctx context.Context, id SlotId) (result ListContinuousWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/continuousWebJobs", 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 *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsSlotComplete(ctx context.Context, id SlotId) (ListContinuousWebJobsSlotCompleteResult, error) { + return c.ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsSlotCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobsSlot(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 = ListContinuousWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listdeploymentlog.go b/resource-manager/web/2023-12-01/webapps/method_listdeploymentlog.go new file mode 100644 index 00000000000..35f887d50ed --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listdeploymentlog.go @@ -0,0 +1,55 @@ +package webapps + +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 ListDeploymentLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLog ... +func (c WebAppsClient) ListDeploymentLog(ctx context.Context, id DeploymentId) (result ListDeploymentLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listdeploymentlogslot.go b/resource-manager/web/2023-12-01/webapps/method_listdeploymentlogslot.go new file mode 100644 index 00000000000..570627468c5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listdeploymentlogslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListDeploymentLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLogSlot ... +func (c WebAppsClient) ListDeploymentLogSlot(ctx context.Context, id SlotDeploymentId) (result ListDeploymentLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listdeployments.go b/resource-manager/web/2023-12-01/webapps/method_listdeployments.go new file mode 100644 index 00000000000..cef230d61e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listdeployments.go @@ -0,0 +1,92 @@ +package webapps + +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 ListDeploymentsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Deployment +} + +// ListDeployments ... +func (c WebAppsClient) ListDeployments(ctx context.Context, id commonids.AppServiceId) (result ListDeploymentsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deployments", 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 *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsComplete(ctx context.Context, id commonids.AppServiceId) (ListDeploymentsCompleteResult, error) { + return c.ListDeploymentsCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DeploymentOperationPredicate) (result ListDeploymentsCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeployments(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 = ListDeploymentsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listdeploymentsslot.go b/resource-manager/web/2023-12-01/webapps/method_listdeploymentsslot.go new file mode 100644 index 00000000000..b93b6247fb7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listdeploymentsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListDeploymentsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Deployment +} + +// ListDeploymentsSlot ... +func (c WebAppsClient) ListDeploymentsSlot(ctx context.Context, id SlotId) (result ListDeploymentsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deployments", 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 *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsSlotComplete(ctx context.Context, id SlotId) (ListDeploymentsSlotCompleteResult, error) { + return c.ListDeploymentsSlotCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DeploymentOperationPredicate) (result ListDeploymentsSlotCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeploymentsSlot(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 = ListDeploymentsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiers.go b/resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiers.go new file mode 100644 index 00000000000..bffb8dea0d6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiers.go @@ -0,0 +1,92 @@ +package webapps + +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 ListDomainOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +// ListDomainOwnershipIdentifiers ... +func (c WebAppsClient) ListDomainOwnershipIdentifiers(ctx context.Context, id commonids.AppServiceId) (result ListDomainOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", 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 *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersComplete(ctx context.Context, id commonids.AppServiceId) (ListDomainOwnershipIdentifiersCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiers(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 = ListDomainOwnershipIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiersslot.go b/resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiersslot.go new file mode 100644 index 00000000000..9c7c86dd15c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listdomainownershipidentifiersslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListDomainOwnershipIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +// ListDomainOwnershipIdentifiersSlot ... +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlot(ctx context.Context, id SlotId) (result ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", 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 *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListDomainOwnershipIdentifiersSlotCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersSlotCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiersSlot(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 = ListDomainOwnershipIdentifiersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listfunctionkeys.go b/resource-manager/web/2023-12-01/webapps/method_listfunctionkeys.go new file mode 100644 index 00000000000..7bd6682f1cc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listfunctionkeys.go @@ -0,0 +1,55 @@ +package webapps + +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 ListFunctionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeys ... +func (c WebAppsClient) ListFunctionKeys(ctx context.Context, id FunctionId) (result ListFunctionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listfunctionkeysslot.go b/resource-manager/web/2023-12-01/webapps/method_listfunctionkeysslot.go new file mode 100644 index 00000000000..77aae0aaf70 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listfunctionkeysslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListFunctionKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeysSlot ... +func (c WebAppsClient) ListFunctionKeysSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listfunctions.go b/resource-manager/web/2023-12-01/webapps/method_listfunctions.go new file mode 100644 index 00000000000..df0f53303b2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listfunctions.go @@ -0,0 +1,92 @@ +package webapps + +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 ListFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionEnvelope +} + +// ListFunctions ... +func (c WebAppsClient) ListFunctions(ctx context.Context, id commonids.AppServiceId) (result ListFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", 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 *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListFunctionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListFunctionsComplete(ctx context.Context, id commonids.AppServiceId) (ListFunctionsCompleteResult, error) { + return c.ListFunctionsCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListFunctionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate FunctionEnvelopeOperationPredicate) (result ListFunctionsCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListFunctions(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 = ListFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listfunctionsecrets.go b/resource-manager/web/2023-12-01/webapps/method_listfunctionsecrets.go new file mode 100644 index 00000000000..3f26b8322db --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listfunctionsecrets.go @@ -0,0 +1,55 @@ +package webapps + +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 ListFunctionSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecrets ... +func (c WebAppsClient) ListFunctionSecrets(ctx context.Context, id FunctionId) (result ListFunctionSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listfunctionsecretsslot.go b/resource-manager/web/2023-12-01/webapps/method_listfunctionsecretsslot.go new file mode 100644 index 00000000000..a8354756f45 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listfunctionsecretsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListFunctionSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecretsSlot ... +func (c WebAppsClient) ListFunctionSecretsSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listhostkeys.go b/resource-manager/web/2023-12-01/webapps/method_listhostkeys.go new file mode 100644 index 00000000000..64dcbd8bfb6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listhostkeys.go @@ -0,0 +1,56 @@ +package webapps + +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 ListHostKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeys ... +func (c WebAppsClient) ListHostKeys(ctx context.Context, id commonids.AppServiceId) (result ListHostKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostKeys + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listhostkeysslot.go b/resource-manager/web/2023-12-01/webapps/method_listhostkeysslot.go new file mode 100644 index 00000000000..af23867eada --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listhostkeysslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListHostKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeysSlot ... +func (c WebAppsClient) ListHostKeysSlot(ctx context.Context, id SlotId) (result ListHostKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostKeys + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listhostnamebindings.go b/resource-manager/web/2023-12-01/webapps/method_listhostnamebindings.go new file mode 100644 index 00000000000..18b6abe4f77 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listhostnamebindings.go @@ -0,0 +1,92 @@ +package webapps + +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 ListHostNameBindingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostNameBinding +} + +// ListHostNameBindings ... +func (c WebAppsClient) ListHostNameBindings(ctx context.Context, id commonids.AppServiceId) (result ListHostNameBindingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hostNameBindings", 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 *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsComplete(ctx context.Context, id commonids.AppServiceId) (ListHostNameBindingsCompleteResult, error) { + return c.ListHostNameBindingsCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindings(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 = ListHostNameBindingsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listhostnamebindingsslot.go b/resource-manager/web/2023-12-01/webapps/method_listhostnamebindingsslot.go new file mode 100644 index 00000000000..8c393a663da --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listhostnamebindingsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListHostNameBindingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostNameBinding +} + +// ListHostNameBindingsSlot ... +func (c WebAppsClient) ListHostNameBindingsSlot(ctx context.Context, id SlotId) (result ListHostNameBindingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hostNameBindings", 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 *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsSlotComplete(ctx context.Context, id SlotId) (ListHostNameBindingsSlotCompleteResult, error) { + return c.ListHostNameBindingsSlotCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsSlotCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindingsSlot(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 = ListHostNameBindingsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listhybridconnections.go b/resource-manager/web/2023-12-01/webapps/method_listhybridconnections.go new file mode 100644 index 00000000000..08364fcb2af --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listhybridconnections.go @@ -0,0 +1,56 @@ +package webapps + +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 ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnections ... +func (c WebAppsClient) ListHybridConnections(ctx context.Context, id commonids.AppServiceId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listhybridconnectionsslot.go b/resource-manager/web/2023-12-01/webapps/method_listhybridconnectionsslot.go new file mode 100644 index 00000000000..7508c1275e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listhybridconnectionsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListHybridConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnectionsSlot ... +func (c WebAppsClient) ListHybridConnectionsSlot(ctx context.Context, id SlotId) (result ListHybridConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstancefunctionsslot.go b/resource-manager/web/2023-12-01/webapps/method_listinstancefunctionsslot.go new file mode 100644 index 00000000000..7bdd102425e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstancefunctionsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListInstanceFunctionsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionEnvelope +} + +// ListInstanceFunctionsSlot ... +func (c WebAppsClient) ListInstanceFunctionsSlot(ctx context.Context, id SlotId) (result ListInstanceFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions", 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 *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceFunctionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceFunctionsSlotComplete(ctx context.Context, id SlotId) (ListInstanceFunctionsSlotCompleteResult, error) { + return c.ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListInstanceFunctionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate FunctionEnvelopeOperationPredicate) (result ListInstanceFunctionsSlotCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListInstanceFunctionsSlot(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 = ListInstanceFunctionsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiers.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiers.go new file mode 100644 index 00000000000..cb40226a729 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiers.go @@ -0,0 +1,92 @@ +package webapps + +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 ListInstanceIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebSiteInstanceStatus +} + +// ListInstanceIdentifiers ... +func (c WebAppsClient) ListInstanceIdentifiers(ctx context.Context, id commonids.AppServiceId) (result ListInstanceIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/instances", 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 *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersComplete(ctx context.Context, id commonids.AppServiceId) (ListInstanceIdentifiersCompleteResult, error) { + return c.ListInstanceIdentifiersCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiers(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 = ListInstanceIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiersslot.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiersslot.go new file mode 100644 index 00000000000..e79fe985e93 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceidentifiersslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebSiteInstanceStatus +} + +// ListInstanceIdentifiersSlot ... +func (c WebAppsClient) ListInstanceIdentifiersSlot(ctx context.Context, id SlotId) (result ListInstanceIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/instances", 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 *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListInstanceIdentifiersSlotCompleteResult, error) { + return c.ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersSlotCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiersSlot(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 = ListInstanceIdentifiersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceprocesses.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocesses.go new file mode 100644 index 00000000000..488612ce5de --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocesses.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +// ListInstanceProcesses ... +func (c WebAppsClient) ListInstanceProcesses(ctx context.Context, id InstanceId) (result ListInstanceProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesComplete(ctx context.Context, id InstanceId) (ListInstanceProcessesCompleteResult, error) { + return c.ListInstanceProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesCompleteMatchingPredicate(ctx context.Context, id InstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcesses(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 = ListInstanceProcessesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessesslot.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessesslot.go new file mode 100644 index 00000000000..8ba7d56c16c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +// ListInstanceProcessesSlot ... +func (c WebAppsClient) ListInstanceProcessesSlot(ctx context.Context, id SlotInstanceId) (result ListInstanceProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesSlotComplete(ctx context.Context, id SlotInstanceId) (ListInstanceProcessesSlotCompleteResult, error) { + return c.ListInstanceProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcessesSlot(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 = ListInstanceProcessesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodules.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodules.go new file mode 100644 index 00000000000..ee7c4cea711 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodules.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +// ListInstanceProcessModules ... +func (c WebAppsClient) ListInstanceProcessModules(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessModulesCompleteResult, error) { + return c.ListInstanceProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModules(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 = ListInstanceProcessModulesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodulesslot.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodulesslot.go new file mode 100644 index 00000000000..e28a3890647 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessmodulesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +// ListInstanceProcessModulesSlot ... +func (c WebAppsClient) ListInstanceProcessModulesSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessModulesSlotCompleteResult, error) { + return c.ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModulesSlot(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 = ListInstanceProcessModulesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreads.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreads.go new file mode 100644 index 00000000000..7d79055b161 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreads.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +// ListInstanceProcessThreads ... +func (c WebAppsClient) ListInstanceProcessThreads(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessThreadsCompleteResult, error) { + return c.ListInstanceProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreads(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 = ListInstanceProcessThreadsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreadsslot.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreadsslot.go new file mode 100644 index 00000000000..78f08c60753 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceprocessthreadsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +// ListInstanceProcessThreadsSlot ... +func (c WebAppsClient) ListInstanceProcessThreadsSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessThreadsSlotCompleteResult, error) { + return c.ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreadsSlot(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 = ListInstanceProcessThreadsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listinstanceworkflowsslot.go b/resource-manager/web/2023-12-01/webapps/method_listinstanceworkflowsslot.go new file mode 100644 index 00000000000..aed499e2894 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listinstanceworkflowsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListInstanceWorkflowsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListInstanceWorkflowsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowEnvelope +} + +// ListInstanceWorkflowsSlot ... +func (c WebAppsClient) ListInstanceWorkflowsSlot(ctx context.Context, id SlotId) (result ListInstanceWorkflowsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/workflows", 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 *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceWorkflowsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceWorkflowsSlotComplete(ctx context.Context, id SlotId) (ListInstanceWorkflowsSlotCompleteResult, error) { + return c.ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListInstanceWorkflowsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WorkflowEnvelopeOperationPredicate) (result ListInstanceWorkflowsSlotCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListInstanceWorkflowsSlot(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 = ListInstanceWorkflowsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listmetadata.go b/resource-manager/web/2023-12-01/webapps/method_listmetadata.go new file mode 100644 index 00000000000..ecb2e7ae7da --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listmetadata.go @@ -0,0 +1,56 @@ +package webapps + +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 ListMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadata ... +func (c WebAppsClient) ListMetadata(ctx context.Context, id commonids.AppServiceId) (result ListMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listmetadataslot.go b/resource-manager/web/2023-12-01/webapps/method_listmetadataslot.go new file mode 100644 index 00000000000..f392f8f6086 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listmetadataslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadataSlot ... +func (c WebAppsClient) ListMetadataSlot(ctx context.Context, id SlotId) (result ListMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listnetworkfeatures.go b/resource-manager/web/2023-12-01/webapps/method_listnetworkfeatures.go new file mode 100644 index 00000000000..5cd439a53af --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listnetworkfeatures.go @@ -0,0 +1,54 @@ +package webapps + +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 ListNetworkFeaturesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeatures ... +func (c WebAppsClient) ListNetworkFeatures(ctx context.Context, id NetworkFeatureId) (result ListNetworkFeaturesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkFeatures + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listnetworkfeaturesslot.go b/resource-manager/web/2023-12-01/webapps/method_listnetworkfeaturesslot.go new file mode 100644 index 00000000000..41badd13da9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listnetworkfeaturesslot.go @@ -0,0 +1,54 @@ +package webapps + +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 ListNetworkFeaturesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeaturesSlot ... +func (c WebAppsClient) ListNetworkFeaturesSlot(ctx context.Context, id SlotNetworkFeatureId) (result ListNetworkFeaturesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkFeatures + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listperfmoncounters.go b/resource-manager/web/2023-12-01/webapps/method_listperfmoncounters.go new file mode 100644 index 00000000000..01f2d02a5ac --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listperfmoncounters.go @@ -0,0 +1,120 @@ +package webapps + +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 ListPerfMonCountersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersCompleteResult struct { + LatestHttpResponse *http.Response + Items []PerfMonResponse +} + +type ListPerfMonCountersOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersOperationOptions() ListPerfMonCountersOperationOptions { + return ListPerfMonCountersOperationOptions{} +} + +func (o ListPerfMonCountersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListPerfMonCounters ... +func (c WebAppsClient) ListPerfMonCounters(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions) (result ListPerfMonCountersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/perfcounters", 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 *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersComplete(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions) (ListPerfMonCountersCompleteResult, error) { + return c.ListPerfMonCountersCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCounters(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 = ListPerfMonCountersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listperfmoncountersslot.go b/resource-manager/web/2023-12-01/webapps/method_listperfmoncountersslot.go new file mode 100644 index 00000000000..8b94fe570dc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listperfmoncountersslot.go @@ -0,0 +1,119 @@ +package webapps + +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 ListPerfMonCountersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []PerfMonResponse +} + +type ListPerfMonCountersSlotOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersSlotOperationOptions() ListPerfMonCountersSlotOperationOptions { + return ListPerfMonCountersSlotOperationOptions{} +} + +func (o ListPerfMonCountersSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListPerfMonCountersSlot ... +func (c WebAppsClient) ListPerfMonCountersSlot(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (result ListPerfMonCountersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/perfcounters", 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 *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersSlotComplete(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (ListPerfMonCountersSlotCompleteResult, error) { + return c.ListPerfMonCountersSlotCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersSlotCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCountersSlot(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 = ListPerfMonCountersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpremieraddons.go b/resource-manager/web/2023-12-01/webapps/method_listpremieraddons.go new file mode 100644 index 00000000000..0215cabcf57 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpremieraddons.go @@ -0,0 +1,56 @@ +package webapps + +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 ListPremierAddOnsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOns ... +func (c WebAppsClient) ListPremierAddOns(ctx context.Context, id commonids.AppServiceId) (result ListPremierAddOnsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpremieraddonsslot.go b/resource-manager/web/2023-12-01/webapps/method_listpremieraddonsslot.go new file mode 100644 index 00000000000..044b2912f5a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpremieraddonsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListPremierAddOnsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOnsSlot ... +func (c WebAppsClient) ListPremierAddOnsSlot(ctx context.Context, id SlotId) (result ListPremierAddOnsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listprocesses.go b/resource-manager/web/2023-12-01/webapps/method_listprocesses.go new file mode 100644 index 00000000000..5a604a00141 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listprocesses.go @@ -0,0 +1,92 @@ +package webapps + +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 ListProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +// ListProcesses ... +func (c WebAppsClient) ListProcesses(ctx context.Context, id commonids.AppServiceId) (result ListProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesComplete(ctx context.Context, id commonids.AppServiceId) (ListProcessesCompleteResult, error) { + return c.ListProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ProcessInfoOperationPredicate) (result ListProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcesses(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 = ListProcessesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listprocessesslot.go b/resource-manager/web/2023-12-01/webapps/method_listprocessesslot.go new file mode 100644 index 00000000000..ffe7b9d8156 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listprocessesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +// ListProcessesSlot ... +func (c WebAppsClient) ListProcessesSlot(ctx context.Context, id SlotId) (result ListProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/processes", 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 *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesSlotComplete(ctx context.Context, id SlotId) (ListProcessesSlotCompleteResult, error) { + return c.ListProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ProcessInfoOperationPredicate) (result ListProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcessesSlot(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 = ListProcessesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listprocessmodules.go b/resource-manager/web/2023-12-01/webapps/method_listprocessmodules.go new file mode 100644 index 00000000000..15443ad9399 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listprocessmodules.go @@ -0,0 +1,91 @@ +package webapps + +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 ListProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +// ListProcessModules ... +func (c WebAppsClient) ListProcessModules(ctx context.Context, id ProcessId) (result ListProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesComplete(ctx context.Context, id ProcessId) (ListProcessModulesCompleteResult, error) { + return c.ListProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModules(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 = ListProcessModulesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listprocessmodulesslot.go b/resource-manager/web/2023-12-01/webapps/method_listprocessmodulesslot.go new file mode 100644 index 00000000000..b0481bc8602 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listprocessmodulesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +// ListProcessModulesSlot ... +func (c WebAppsClient) ListProcessModulesSlot(ctx context.Context, id SlotProcessId) (result ListProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/modules", 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 *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessModulesSlotCompleteResult, error) { + return c.ListProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModulesSlot(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 = ListProcessModulesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listprocessthreads.go b/resource-manager/web/2023-12-01/webapps/method_listprocessthreads.go new file mode 100644 index 00000000000..26147f0eae6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listprocessthreads.go @@ -0,0 +1,91 @@ +package webapps + +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 ListProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +// ListProcessThreads ... +func (c WebAppsClient) ListProcessThreads(ctx context.Context, id ProcessId) (result ListProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsComplete(ctx context.Context, id ProcessId) (ListProcessThreadsCompleteResult, error) { + return c.ListProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreads(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 = ListProcessThreadsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listprocessthreadsslot.go b/resource-manager/web/2023-12-01/webapps/method_listprocessthreadsslot.go new file mode 100644 index 00000000000..b6fc1232146 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listprocessthreadsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +// ListProcessThreadsSlot ... +func (c WebAppsClient) ListProcessThreadsSlot(ctx context.Context, id SlotProcessId) (result ListProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/threads", 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 *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessThreadsSlotCompleteResult, error) { + return c.ListProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreadsSlot(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 = ListProcessThreadsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listproductionsitedeploymentstatuses.go b/resource-manager/web/2023-12-01/webapps/method_listproductionsitedeploymentstatuses.go new file mode 100644 index 00000000000..9492755e012 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listproductionsitedeploymentstatuses.go @@ -0,0 +1,92 @@ +package webapps + +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 ListProductionSiteDeploymentStatusesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListProductionSiteDeploymentStatusesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmDeploymentStatus +} + +// ListProductionSiteDeploymentStatuses ... +func (c WebAppsClient) ListProductionSiteDeploymentStatuses(ctx context.Context, id commonids.AppServiceId) (result ListProductionSiteDeploymentStatusesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deploymentStatus", 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 *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProductionSiteDeploymentStatusesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProductionSiteDeploymentStatusesComplete(ctx context.Context, id commonids.AppServiceId) (ListProductionSiteDeploymentStatusesCompleteResult, error) { + return c.ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListProductionSiteDeploymentStatusesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate CsmDeploymentStatusOperationPredicate) (result ListProductionSiteDeploymentStatusesCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListProductionSiteDeploymentStatuses(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 = ListProductionSiteDeploymentStatusesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpubliccertificates.go b/resource-manager/web/2023-12-01/webapps/method_listpubliccertificates.go new file mode 100644 index 00000000000..bd48a7353dd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpubliccertificates.go @@ -0,0 +1,92 @@ +package webapps + +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 ListPublicCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicCertificate +} + +// ListPublicCertificates ... +func (c WebAppsClient) ListPublicCertificates(ctx context.Context, id commonids.AppServiceId) (result ListPublicCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/publicCertificates", 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 *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesComplete(ctx context.Context, id commonids.AppServiceId) (ListPublicCertificatesCompleteResult, error) { + return c.ListPublicCertificatesCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificates(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 = ListPublicCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpubliccertificatesslot.go b/resource-manager/web/2023-12-01/webapps/method_listpubliccertificatesslot.go new file mode 100644 index 00000000000..a6c132885ac --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpubliccertificatesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListPublicCertificatesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicCertificate +} + +// ListPublicCertificatesSlot ... +func (c WebAppsClient) ListPublicCertificatesSlot(ctx context.Context, id SlotId) (result ListPublicCertificatesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/publicCertificates", 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 *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesSlotComplete(ctx context.Context, id SlotId) (ListPublicCertificatesSlotCompleteResult, error) { + return c.ListPublicCertificatesSlotCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesSlotCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificatesSlot(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 = ListPublicCertificatesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpublishingcredentials.go b/resource-manager/web/2023-12-01/webapps/method_listpublishingcredentials.go new file mode 100644 index 00000000000..3c3e5a7d373 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpublishingcredentials.go @@ -0,0 +1,71 @@ +package webapps + +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/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 ListPublishingCredentialsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// ListPublishingCredentials ... +func (c WebAppsClient) ListPublishingCredentials(ctx context.Context, id commonids.AppServiceId) (result ListPublishingCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", 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 +} + +// ListPublishingCredentialsThenPoll performs ListPublishingCredentials then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsThenPoll(ctx context.Context, id commonids.AppServiceId) error { + result, err := c.ListPublishingCredentials(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentials: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentials: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpublishingcredentialsslot.go b/resource-manager/web/2023-12-01/webapps/method_listpublishingcredentialsslot.go new file mode 100644 index 00000000000..6c38961b04a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpublishingcredentialsslot.go @@ -0,0 +1,70 @@ +package webapps + +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 ListPublishingCredentialsSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// ListPublishingCredentialsSlot ... +func (c WebAppsClient) ListPublishingCredentialsSlot(ctx context.Context, id SlotId) (result ListPublishingCredentialsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", 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 +} + +// ListPublishingCredentialsSlotThenPoll performs ListPublishingCredentialsSlot then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsSlotThenPoll(ctx context.Context, id SlotId) error { + result, err := c.ListPublishingCredentialsSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentialsSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentialsSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecrets.go b/resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecrets.go new file mode 100644 index 00000000000..7da7da0b23c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecrets.go @@ -0,0 +1,60 @@ +package webapps + +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 ListPublishingProfileXmlWithSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecrets ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecrets(ctx context.Context, id commonids.AppServiceId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go b/resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go new file mode 100644 index 00000000000..2a4701423fd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go @@ -0,0 +1,59 @@ +package webapps + +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 ListPublishingProfileXmlWithSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecretsSlot ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecretsSlot(ctx context.Context, id SlotId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnections.go b/resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnections.go new file mode 100644 index 00000000000..d7e18cd89e8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnections.go @@ -0,0 +1,56 @@ +package webapps + +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 ListRelayServiceConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnections ... +func (c WebAppsClient) ListRelayServiceConnections(ctx context.Context, id commonids.AppServiceId) (result ListRelayServiceConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnectionsslot.go b/resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnectionsslot.go new file mode 100644 index 00000000000..1f4ad19a8c9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listrelayserviceconnectionsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListRelayServiceConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnectionsSlot ... +func (c WebAppsClient) ListRelayServiceConnectionsSlot(ctx context.Context, id SlotId) (result ListRelayServiceConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsitebackups.go b/resource-manager/web/2023-12-01/webapps/method_listsitebackups.go new file mode 100644 index 00000000000..2a0dfa9922d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsitebackups.go @@ -0,0 +1,92 @@ +package webapps + +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 ListSiteBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +// ListSiteBackups ... +func (c WebAppsClient) ListSiteBackups(ctx context.Context, id commonids.AppServiceId) (result ListSiteBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listbackups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteBackupsCompleteResult, error) { + return c.ListSiteBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate BackupItemOperationPredicate) (result ListSiteBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackups(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 = ListSiteBackupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsitebackupsslot.go b/resource-manager/web/2023-12-01/webapps/method_listsitebackupsslot.go new file mode 100644 index 00000000000..2d8dd37dbad --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsitebackupsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListSiteBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +// ListSiteBackupsSlot ... +func (c WebAppsClient) ListSiteBackupsSlot(ctx context.Context, id SlotId) (result ListSiteBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listbackups", 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 *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsSlotComplete(ctx context.Context, id SlotId) (ListSiteBackupsSlotCompleteResult, error) { + return c.ListSiteBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListSiteBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackupsSlot(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 = ListSiteBackupsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsitecontainers.go b/resource-manager/web/2023-12-01/webapps/method_listsitecontainers.go new file mode 100644 index 00000000000..4deb2204c7f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsitecontainers.go @@ -0,0 +1,92 @@ +package webapps + +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 ListSiteContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteContainer +} + +type ListSiteContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteContainer +} + +// ListSiteContainers ... +func (c WebAppsClient) ListSiteContainers(ctx context.Context, id commonids.AppServiceId) (result ListSiteContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sitecontainers", 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 *[]SiteContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteContainersComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteContainersComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteContainersCompleteResult, error) { + return c.ListSiteContainersCompleteMatchingPredicate(ctx, id, SiteContainerOperationPredicate{}) +} + +// ListSiteContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteContainersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteContainerOperationPredicate) (result ListSiteContainersCompleteResult, err error) { + items := make([]SiteContainer, 0) + + resp, err := c.ListSiteContainers(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 = ListSiteContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsitecontainersslot.go b/resource-manager/web/2023-12-01/webapps/method_listsitecontainersslot.go new file mode 100644 index 00000000000..16bff34fa4e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsitecontainersslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListSiteContainersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteContainer +} + +type ListSiteContainersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteContainer +} + +// ListSiteContainersSlot ... +func (c WebAppsClient) ListSiteContainersSlot(ctx context.Context, id SlotId) (result ListSiteContainersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sitecontainers", 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 *[]SiteContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteContainersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteContainersSlotComplete(ctx context.Context, id SlotId) (ListSiteContainersSlotCompleteResult, error) { + return c.ListSiteContainersSlotCompleteMatchingPredicate(ctx, id, SiteContainerOperationPredicate{}) +} + +// ListSiteContainersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteContainersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteContainerOperationPredicate) (result ListSiteContainersSlotCompleteResult, err error) { + items := make([]SiteContainer, 0) + + resp, err := c.ListSiteContainersSlot(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 = ListSiteContainersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsiteextensions.go b/resource-manager/web/2023-12-01/webapps/method_listsiteextensions.go new file mode 100644 index 00000000000..4ee8caa1c52 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsiteextensions.go @@ -0,0 +1,92 @@ +package webapps + +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 ListSiteExtensionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteExtensionInfo +} + +// ListSiteExtensions ... +func (c WebAppsClient) ListSiteExtensions(ctx context.Context, id commonids.AppServiceId) (result ListSiteExtensionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/siteExtensions", 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 *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteExtensionsCompleteResult, error) { + return c.ListSiteExtensionsCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensions(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 = ListSiteExtensionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsiteextensionsslot.go b/resource-manager/web/2023-12-01/webapps/method_listsiteextensionsslot.go new file mode 100644 index 00000000000..19d6888db1e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsiteextensionsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListSiteExtensionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteExtensionInfo +} + +// ListSiteExtensionsSlot ... +func (c WebAppsClient) ListSiteExtensionsSlot(ctx context.Context, id SlotId) (result ListSiteExtensionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/siteExtensions", 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 *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsSlotComplete(ctx context.Context, id SlotId) (ListSiteExtensionsSlotCompleteResult, error) { + return c.ListSiteExtensionsSlotCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsSlotCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensionsSlot(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 = ListSiteExtensionsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsitepushsettings.go b/resource-manager/web/2023-12-01/webapps/method_listsitepushsettings.go new file mode 100644 index 00000000000..c62e23599bc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsitepushsettings.go @@ -0,0 +1,56 @@ +package webapps + +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 ListSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettings ... +func (c WebAppsClient) ListSitePushSettings(ctx context.Context, id commonids.AppServiceId) (result ListSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsitepushsettingsslot.go b/resource-manager/web/2023-12-01/webapps/method_listsitepushsettingsslot.go new file mode 100644 index 00000000000..c68fba350a3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsitepushsettingsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettingsSlot ... +func (c WebAppsClient) ListSitePushSettingsSlot(ctx context.Context, id SlotId) (result ListSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listslotconfigurationnames.go b/resource-manager/web/2023-12-01/webapps/method_listslotconfigurationnames.go new file mode 100644 index 00000000000..06953e01e3f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listslotconfigurationnames.go @@ -0,0 +1,56 @@ +package webapps + +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 ListSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// ListSlotConfigurationNames ... +func (c WebAppsClient) ListSlotConfigurationNames(ctx context.Context, id commonids.AppServiceId) (result ListSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/slotConfigNames", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SlotConfigNamesResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listslotdifferencesfromproduction.go b/resource-manager/web/2023-12-01/webapps/method_listslotdifferencesfromproduction.go new file mode 100644 index 00000000000..9f18e2a998c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listslotdifferencesfromproduction.go @@ -0,0 +1,92 @@ +package webapps + +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 ListSlotDifferencesFromProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesFromProductionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SlotDifference +} + +// ListSlotDifferencesFromProduction ... +func (c WebAppsClient) ListSlotDifferencesFromProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result ListSlotDifferencesFromProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsdiffs", 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 *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesFromProductionComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesFromProductionComplete(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (ListSlotDifferencesFromProductionCompleteResult, error) { + return c.ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesFromProductionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesFromProductionCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesFromProduction(ctx, id, input) + 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 = ListSlotDifferencesFromProductionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listslotdifferencesslot.go b/resource-manager/web/2023-12-01/webapps/method_listslotdifferencesslot.go new file mode 100644 index 00000000000..c0c33b32a4a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listslotdifferencesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListSlotDifferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SlotDifference +} + +// ListSlotDifferencesSlot ... +func (c WebAppsClient) ListSlotDifferencesSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ListSlotDifferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsdiffs", 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 *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesSlotComplete(ctx context.Context, id SlotId, input CsmSlotEntity) (ListSlotDifferencesSlotCompleteResult, error) { + return c.ListSlotDifferencesSlotCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesSlotCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesSlot(ctx, id, input) + 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 = ListSlotDifferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listslots.go b/resource-manager/web/2023-12-01/webapps/method_listslots.go new file mode 100644 index 00000000000..3d92fdd3fa7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listslots.go @@ -0,0 +1,92 @@ +package webapps + +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 ListSlotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListSlotsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +// ListSlots ... +func (c WebAppsClient) ListSlots(ctx context.Context, id commonids.AppServiceId) (result ListSlotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/slots", 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 *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotsComplete(ctx context.Context, id commonids.AppServiceId) (ListSlotsCompleteResult, error) { + return c.ListSlotsCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListSlotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteOperationPredicate) (result ListSlotsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListSlots(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 = ListSlotsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listslotsitedeploymentstatusesslot.go b/resource-manager/web/2023-12-01/webapps/method_listslotsitedeploymentstatusesslot.go new file mode 100644 index 00000000000..90a8856f16e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listslotsitedeploymentstatusesslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListSlotSiteDeploymentStatusesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListSlotSiteDeploymentStatusesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmDeploymentStatus +} + +// ListSlotSiteDeploymentStatusesSlot ... +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlot(ctx context.Context, id SlotId) (result ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/deploymentStatus", 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 *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotSiteDeploymentStatusesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotComplete(ctx context.Context, id SlotId) (ListSlotSiteDeploymentStatusesSlotCompleteResult, error) { + return c.ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmDeploymentStatusOperationPredicate) (result ListSlotSiteDeploymentStatusesSlotCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListSlotSiteDeploymentStatusesSlot(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 = ListSlotSiteDeploymentStatusesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsnapshots.go b/resource-manager/web/2023-12-01/webapps/method_listsnapshots.go new file mode 100644 index 00000000000..afe7c5aee43 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsnapshots.go @@ -0,0 +1,92 @@ +package webapps + +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 ListSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +// ListSnapshots ... +func (c WebAppsClient) ListSnapshots(ctx context.Context, id commonids.AppServiceId) (result ListSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsComplete(ctx context.Context, id commonids.AppServiceId) (ListSnapshotsCompleteResult, error) { + return c.ListSnapshotsCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SnapshotOperationPredicate) (result ListSnapshotsCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshots(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 = ListSnapshotsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondary.go b/resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondary.go new file mode 100644 index 00000000000..805bc701d57 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondary.go @@ -0,0 +1,92 @@ +package webapps + +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 ListSnapshotsFromDRSecondaryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondaryCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +// ListSnapshotsFromDRSecondary ... +func (c WebAppsClient) ListSnapshotsFromDRSecondary(ctx context.Context, id commonids.AppServiceId) (result ListSnapshotsFromDRSecondaryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshotsdr", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondaryComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondaryComplete(ctx context.Context, id commonids.AppServiceId) (ListSnapshotsFromDRSecondaryCompleteResult, error) { + return c.ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondaryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondaryCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondary(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 = ListSnapshotsFromDRSecondaryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondaryslot.go b/resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondaryslot.go new file mode 100644 index 00000000000..838ac506bce --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsnapshotsfromdrsecondaryslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListSnapshotsFromDRSecondarySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondarySlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +// ListSnapshotsFromDRSecondarySlot ... +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlot(ctx context.Context, id SlotId) (result ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshotsdr", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondarySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotComplete(ctx context.Context, id SlotId) (ListSnapshotsFromDRSecondarySlotCompleteResult, error) { + return c.ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondarySlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondarySlot(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 = ListSnapshotsFromDRSecondarySlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsnapshotsslot.go b/resource-manager/web/2023-12-01/webapps/method_listsnapshotsslot.go new file mode 100644 index 00000000000..a39d25566dc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsnapshotsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListSnapshotsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +// ListSnapshotsSlot ... +func (c WebAppsClient) ListSnapshotsSlot(ctx context.Context, id SlotId) (result ListSnapshotsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", 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 *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsSlotComplete(ctx context.Context, id SlotId) (ListSnapshotsSlotCompleteResult, error) { + return c.ListSnapshotsSlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsSlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsSlot(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 = ListSnapshotsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggers.go b/resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggers.go new file mode 100644 index 00000000000..e92a5874991 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggers.go @@ -0,0 +1,56 @@ +package webapps + +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 ListSyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggers ... +func (c WebAppsClient) ListSyncFunctionTriggers(ctx context.Context, id commonids.AppServiceId) (result ListSyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggersslot.go b/resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggersslot.go new file mode 100644 index 00000000000..e00d4fd2f39 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsyncfunctiontriggersslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListSyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggersSlot ... +func (c WebAppsClient) ListSyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result ListSyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsyncstatus.go b/resource-manager/web/2023-12-01/webapps/method_listsyncstatus.go new file mode 100644 index 00000000000..bc0ee3e79f0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsyncstatus.go @@ -0,0 +1,48 @@ +package webapps + +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 ListSyncStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatus ... +func (c WebAppsClient) ListSyncStatus(ctx context.Context, id commonids.AppServiceId) (result ListSyncStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listsyncstatusslot.go b/resource-manager/web/2023-12-01/webapps/method_listsyncstatusslot.go new file mode 100644 index 00000000000..bf199ced94d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listsyncstatusslot.go @@ -0,0 +1,47 @@ +package webapps + +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 ListSyncStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatusSlot ... +func (c WebAppsClient) ListSyncStatusSlot(ctx context.Context, id SlotId) (result ListSyncStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistory.go b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistory.go new file mode 100644 index 00000000000..a1975b11987 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistory.go @@ -0,0 +1,91 @@ +package webapps + +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 ListTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistoryCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredJobHistory +} + +// ListTriggeredWebJobHistory ... +func (c WebAppsClient) ListTriggeredWebJobHistory(ctx context.Context, id TriggeredWebJobId) (result ListTriggeredWebJobHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/history", 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 *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistoryComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistoryComplete(ctx context.Context, id TriggeredWebJobId) (ListTriggeredWebJobHistoryCompleteResult, error) { + return c.ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistoryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx context.Context, id TriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistoryCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistory(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 = ListTriggeredWebJobHistoryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistoryslot.go b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..bd3b6529802 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobhistoryslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistorySlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredJobHistory +} + +// ListTriggeredWebJobHistorySlot ... +func (c WebAppsClient) ListTriggeredWebJobHistorySlot(ctx context.Context, id SlotTriggeredWebJobId) (result ListTriggeredWebJobHistorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/history", 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 *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistorySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistorySlotComplete(ctx context.Context, id SlotTriggeredWebJobId) (ListTriggeredWebJobHistorySlotCompleteResult, error) { + return c.ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistorySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx context.Context, id SlotTriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistorySlotCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistorySlot(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 = ListTriggeredWebJobHistorySlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobs.go b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobs.go new file mode 100644 index 00000000000..f8cf40a9962 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobs.go @@ -0,0 +1,92 @@ +package webapps + +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 ListTriggeredWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredWebJob +} + +// ListTriggeredWebJobs ... +func (c WebAppsClient) ListTriggeredWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListTriggeredWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/triggeredWebJobs", 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 *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListTriggeredWebJobsCompleteResult, error) { + return c.ListTriggeredWebJobsCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobs(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 = ListTriggeredWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobsslot.go b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobsslot.go new file mode 100644 index 00000000000..9c05bd4be00 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listtriggeredwebjobsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListTriggeredWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredWebJob +} + +// ListTriggeredWebJobsSlot ... +func (c WebAppsClient) ListTriggeredWebJobsSlot(ctx context.Context, id SlotId) (result ListTriggeredWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/triggeredWebJobs", 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 *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsSlotComplete(ctx context.Context, id SlotId) (ListTriggeredWebJobsSlotCompleteResult, error) { + return c.ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsSlotCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobsSlot(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 = ListTriggeredWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listusages.go b/resource-manager/web/2023-12-01/webapps/method_listusages.go new file mode 100644 index 00000000000..4cadba06224 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listusages.go @@ -0,0 +1,120 @@ +package webapps + +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 ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsages ... +func (c WebAppsClient) ListUsages(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesComplete(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(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 = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listusagesslot.go b/resource-manager/web/2023-12-01/webapps/method_listusagesslot.go new file mode 100644 index 00000000000..dd87f87508f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listusagesslot.go @@ -0,0 +1,119 @@ +package webapps + +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 ListUsagesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesSlotOperationOptions struct { + Filter *string +} + +func DefaultListUsagesSlotOperationOptions() ListUsagesSlotOperationOptions { + return ListUsagesSlotOperationOptions{} +} + +func (o ListUsagesSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListUsagesSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +// ListUsagesSlot ... +func (c WebAppsClient) ListUsagesSlot(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (result ListUsagesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/usages", id.ID()), + 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 *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesSlotComplete(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (ListUsagesSlotCompleteResult, error) { + return c.ListUsagesSlotCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesSlotCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsagesSlot(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 = ListUsagesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listvnetconnections.go b/resource-manager/web/2023-12-01/webapps/method_listvnetconnections.go new file mode 100644 index 00000000000..72289ddc25f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listvnetconnections.go @@ -0,0 +1,56 @@ +package webapps + +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 ListVnetConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnections ... +func (c WebAppsClient) ListVnetConnections(ctx context.Context, id commonids.AppServiceId) (result ListVnetConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listvnetconnectionsslot.go b/resource-manager/web/2023-12-01/webapps/method_listvnetconnectionsslot.go new file mode 100644 index 00000000000..8018d954faf --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listvnetconnectionsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListVnetConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnectionsSlot ... +func (c WebAppsClient) ListVnetConnectionsSlot(ctx context.Context, id SlotId) (result ListVnetConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listwebjobs.go b/resource-manager/web/2023-12-01/webapps/method_listwebjobs.go new file mode 100644 index 00000000000..581f0c2f492 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listwebjobs.go @@ -0,0 +1,92 @@ +package webapps + +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 ListWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebJob +} + +// ListWebJobs ... +func (c WebAppsClient) ListWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/webJobs", 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 *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListWebJobsCompleteResult, error) { + return c.ListWebJobsCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WebJobOperationPredicate) (result ListWebJobsCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobs(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 = ListWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listwebjobsslot.go b/resource-manager/web/2023-12-01/webapps/method_listwebjobsslot.go new file mode 100644 index 00000000000..1cca95411e3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listwebjobsslot.go @@ -0,0 +1,91 @@ +package webapps + +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 ListWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebJob +} + +// ListWebJobsSlot ... +func (c WebAppsClient) ListWebJobsSlot(ctx context.Context, id SlotId) (result ListWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/webJobs", 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 *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsSlotComplete(ctx context.Context, id SlotId) (ListWebJobsSlotCompleteResult, error) { + return c.ListWebJobsSlotCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebJobOperationPredicate) (result ListWebJobsSlotCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobsSlot(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 = ListWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listworkflows.go b/resource-manager/web/2023-12-01/webapps/method_listworkflows.go new file mode 100644 index 00000000000..705087f7204 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listworkflows.go @@ -0,0 +1,92 @@ +package webapps + +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 ListWorkflowsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListWorkflowsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowEnvelope +} + +// ListWorkflows ... +func (c WebAppsClient) ListWorkflows(ctx context.Context, id commonids.AppServiceId) (result ListWorkflowsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/workflows", 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 *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkflowsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWorkflowsComplete(ctx context.Context, id commonids.AppServiceId) (ListWorkflowsCompleteResult, error) { + return c.ListWorkflowsCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListWorkflowsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWorkflowsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WorkflowEnvelopeOperationPredicate) (result ListWorkflowsCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListWorkflows(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 = ListWorkflowsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listworkflowsconnections.go b/resource-manager/web/2023-12-01/webapps/method_listworkflowsconnections.go new file mode 100644 index 00000000000..05c1769e6c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listworkflowsconnections.go @@ -0,0 +1,56 @@ +package webapps + +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 ListWorkflowsConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnections ... +func (c WebAppsClient) ListWorkflowsConnections(ctx context.Context, id commonids.AppServiceId) (result ListWorkflowsConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_listworkflowsconnectionsslot.go b/resource-manager/web/2023-12-01/webapps/method_listworkflowsconnectionsslot.go new file mode 100644 index 00000000000..b1319800e9b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_listworkflowsconnectionsslot.go @@ -0,0 +1,55 @@ +package webapps + +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 ListWorkflowsConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnectionsSlot ... +func (c WebAppsClient) ListWorkflowsConnectionsSlot(ctx context.Context, id SlotId) (result ListWorkflowsConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_migratemysql.go b/resource-manager/web/2023-12-01/webapps/method_migratemysql.go new file mode 100644 index 00000000000..ce8f8a7c00c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_migratemysql.go @@ -0,0 +1,75 @@ +package webapps + +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/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 MigrateMySqlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Operation +} + +// MigrateMySql ... +func (c WebAppsClient) MigrateMySql(ctx context.Context, id commonids.AppServiceId, input MigrateMySqlRequest) (result MigrateMySqlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateMySql", 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 +} + +// MigrateMySqlThenPoll performs MigrateMySql then polls until it's completed +func (c WebAppsClient) MigrateMySqlThenPoll(ctx context.Context, id commonids.AppServiceId, input MigrateMySqlRequest) error { + result, err := c.MigrateMySql(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MigrateMySql: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateMySql: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_migratestorage.go b/resource-manager/web/2023-12-01/webapps/method_migratestorage.go new file mode 100644 index 00000000000..5f0c28ff47d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_migratestorage.go @@ -0,0 +1,103 @@ +package webapps + +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/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 MigrateStorageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageMigrationResponse +} + +type MigrateStorageOperationOptions struct { + SubscriptionName *string +} + +func DefaultMigrateStorageOperationOptions() MigrateStorageOperationOptions { + return MigrateStorageOperationOptions{} +} + +func (o MigrateStorageOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o MigrateStorageOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o MigrateStorageOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SubscriptionName != nil { + out.Append("subscriptionName", fmt.Sprintf("%v", *o.SubscriptionName)) + } + return &out +} + +// MigrateStorage ... +func (c WebAppsClient) MigrateStorage(ctx context.Context, id commonids.AppServiceId, input StorageMigrationOptions, options MigrateStorageOperationOptions) (result MigrateStorageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/migrate", id.ID()), + OptionsObject: options, + } + + 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 +} + +// MigrateStorageThenPoll performs MigrateStorage then polls until it's completed +func (c WebAppsClient) MigrateStorageThenPoll(ctx context.Context, id commonids.AppServiceId, input StorageMigrationOptions, options MigrateStorageOperationOptions) error { + result, err := c.MigrateStorage(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing MigrateStorage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateStorage: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnet.go b/resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnet.go new file mode 100644 index 00000000000..63ec49104fc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnet.go @@ -0,0 +1,60 @@ +package webapps + +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 PutPrivateAccessVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnet ... +func (c WebAppsClient) PutPrivateAccessVnet(ctx context.Context, id commonids.AppServiceId, input PrivateAccess) (result PutPrivateAccessVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnetslot.go b/resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnetslot.go new file mode 100644 index 00000000000..465f0eb8449 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_putprivateaccessvnetslot.go @@ -0,0 +1,59 @@ +package webapps + +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 PutPrivateAccessVnetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnetSlot ... +func (c WebAppsClient) PutPrivateAccessVnetSlot(ctx context.Context, id SlotId, input PrivateAccess) (result PutPrivateAccessVnetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshot.go b/resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshot.go new file mode 100644 index 00000000000..9bd00ef6a3f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshot.go @@ -0,0 +1,47 @@ +package webapps + +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 RecoverSiteConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshot(ctx context.Context, id SnapshotId) (result RecoverSiteConfigurationSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshotslot.go b/resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshotslot.go new file mode 100644 index 00000000000..c2218167e74 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_recoversiteconfigurationsnapshotslot.go @@ -0,0 +1,47 @@ +package webapps + +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 RecoverSiteConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshotSlot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result RecoverSiteConfigurationSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_resetproductionslotconfig.go b/resource-manager/web/2023-12-01/webapps/method_resetproductionslotconfig.go new file mode 100644 index 00000000000..d3e1980493a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_resetproductionslotconfig.go @@ -0,0 +1,48 @@ +package webapps + +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 ResetProductionSlotConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetProductionSlotConfig ... +func (c WebAppsClient) ResetProductionSlotConfig(ctx context.Context, id commonids.AppServiceId) (result ResetProductionSlotConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_resetslotconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_resetslotconfigurationslot.go new file mode 100644 index 00000000000..15aae400653 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_resetslotconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +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 ResetSlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetSlotConfigurationSlot ... +func (c WebAppsClient) ResetSlotConfigurationSlot(ctx context.Context, id SlotId) (result ResetSlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restart.go b/resource-manager/web/2023-12-01/webapps/method_restart.go new file mode 100644 index 00000000000..fbc0d6837cb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restart.go @@ -0,0 +1,80 @@ +package webapps + +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 RestartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartOperationOptions() RestartOperationOptions { + return RestartOperationOptions{} +} + +func (o RestartOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RestartOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// Restart ... +func (c WebAppsClient) Restart(ctx context.Context, id commonids.AppServiceId, options RestartOperationOptions) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restartslot.go b/resource-manager/web/2023-12-01/webapps/method_restartslot.go new file mode 100644 index 00000000000..2ed5d2e9efa --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restartslot.go @@ -0,0 +1,79 @@ +package webapps + +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 RestartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartSlotOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartSlotOperationOptions() RestartSlotOperationOptions { + return RestartSlotOperationOptions{} +} + +func (o RestartSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o RestartSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// RestartSlot ... +func (c WebAppsClient) RestartSlot(ctx context.Context, id SlotId, options RestartSlotOperationOptions) (result RestartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restore.go b/resource-manager/web/2023-12-01/webapps/method_restore.go new file mode 100644 index 00000000000..021d7f79a35 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restore.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restore ... +func (c WebAppsClient) Restore(ctx context.Context, id BackupId, input RestoreRequest) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c WebAppsClient) RestoreThenPoll(ctx context.Context, id BackupId, input RestoreRequest) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restorefrombackupblob.go b/resource-manager/web/2023-12-01/webapps/method_restorefrombackupblob.go new file mode 100644 index 00000000000..0483caf9f9c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restorefrombackupblob.go @@ -0,0 +1,75 @@ +package webapps + +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/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 RestoreFromBackupBlobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlob ... +func (c WebAppsClient) RestoreFromBackupBlob(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) (result RestoreFromBackupBlobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", 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 +} + +// RestoreFromBackupBlobThenPoll performs RestoreFromBackupBlob then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobThenPoll(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlob: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restorefrombackupblobslot.go b/resource-manager/web/2023-12-01/webapps/method_restorefrombackupblobslot.go new file mode 100644 index 00000000000..27fd565b8af --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restorefrombackupblobslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromBackupBlobSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlobSlot ... +func (c WebAppsClient) RestoreFromBackupBlobSlot(ctx context.Context, id SlotId, input RestoreRequest) (result RestoreFromBackupBlobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", 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 +} + +// RestoreFromBackupBlobSlotThenPoll performs RestoreFromBackupBlobSlot then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobSlotThenPoll(ctx context.Context, id SlotId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlobSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlobSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlobSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restorefromdeletedapp.go b/resource-manager/web/2023-12-01/webapps/method_restorefromdeletedapp.go new file mode 100644 index 00000000000..1b8a16b10b5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restorefromdeletedapp.go @@ -0,0 +1,75 @@ +package webapps + +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/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 RestoreFromDeletedAppOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedApp ... +func (c WebAppsClient) RestoreFromDeletedApp(ctx context.Context, id commonids.AppServiceId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", 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 +} + +// RestoreFromDeletedAppThenPoll performs RestoreFromDeletedApp then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppThenPoll(ctx context.Context, id commonids.AppServiceId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedApp(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedApp: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedApp: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restorefromdeletedappslot.go b/resource-manager/web/2023-12-01/webapps/method_restorefromdeletedappslot.go new file mode 100644 index 00000000000..6fd61e73c37 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restorefromdeletedappslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreFromDeletedAppSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedAppSlot ... +func (c WebAppsClient) RestoreFromDeletedAppSlot(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", 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 +} + +// RestoreFromDeletedAppSlotThenPoll performs RestoreFromDeletedAppSlot then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppSlotThenPoll(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedAppSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedAppSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedAppSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restoreslot.go b/resource-manager/web/2023-12-01/webapps/method_restoreslot.go new file mode 100644 index 00000000000..0e401f516af --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restoreslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSlot ... +func (c WebAppsClient) RestoreSlot(ctx context.Context, id SlotBackupId, input RestoreRequest) (result RestoreSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", 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 +} + +// RestoreSlotThenPoll performs RestoreSlot then polls until it's completed +func (c WebAppsClient) RestoreSlotThenPoll(ctx context.Context, id SlotBackupId, input RestoreRequest) error { + result, err := c.RestoreSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restoresnapshot.go b/resource-manager/web/2023-12-01/webapps/method_restoresnapshot.go new file mode 100644 index 00000000000..191a16d685d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restoresnapshot.go @@ -0,0 +1,75 @@ +package webapps + +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/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 RestoreSnapshotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshot ... +func (c WebAppsClient) RestoreSnapshot(ctx context.Context, id commonids.AppServiceId, input SnapshotRestoreRequest) (result RestoreSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", 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 +} + +// RestoreSnapshotThenPoll performs RestoreSnapshot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotThenPoll(ctx context.Context, id commonids.AppServiceId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_restoresnapshotslot.go b/resource-manager/web/2023-12-01/webapps/method_restoresnapshotslot.go new file mode 100644 index 00000000000..95c72292ac1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_restoresnapshotslot.go @@ -0,0 +1,74 @@ +package webapps + +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 RestoreSnapshotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshotSlot ... +func (c WebAppsClient) RestoreSnapshotSlot(ctx context.Context, id SlotId, input SnapshotRestoreRequest) (result RestoreSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", 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 +} + +// RestoreSnapshotSlotThenPoll performs RestoreSnapshotSlot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotSlotThenPoll(ctx context.Context, id SlotId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjob.go b/resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjob.go new file mode 100644 index 00000000000..368004f11bb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 RunTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJob ... +func (c WebAppsClient) RunTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result RunTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjobslot.go new file mode 100644 index 00000000000..20589d753fc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_runtriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 RunTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJobSlot ... +func (c WebAppsClient) RunTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result RunTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_start.go b/resource-manager/web/2023-12-01/webapps/method_start.go new file mode 100644 index 00000000000..6eeb4574e82 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_start.go @@ -0,0 +1,48 @@ +package webapps + +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 StartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c WebAppsClient) Start(ctx context.Context, id commonids.AppServiceId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjob.go b/resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjob.go new file mode 100644 index 00000000000..e3a68b92d35 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 StartContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJob ... +func (c WebAppsClient) StartContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StartContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjobslot.go new file mode 100644 index 00000000000..25b7624a51e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 StartContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJobSlot ... +func (c WebAppsClient) StartContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StartContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startnetworktrace.go b/resource-manager/web/2023-12-01/webapps/method_startnetworktrace.go new file mode 100644 index 00000000000..92ce80e4291 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startnetworktrace.go @@ -0,0 +1,108 @@ +package webapps + +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/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 StartNetworkTraceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartNetworkTraceOperationOptions() StartNetworkTraceOperationOptions { + return StartNetworkTraceOperationOptions{} +} + +func (o StartNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartNetworkTrace ... +func (c WebAppsClient) StartNetworkTrace(ctx context.Context, id commonids.AppServiceId, options StartNetworkTraceOperationOptions) (result StartNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startNetworkTrace", 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 +} + +// StartNetworkTraceThenPoll performs StartNetworkTrace then polls until it's completed +func (c WebAppsClient) StartNetworkTraceThenPoll(ctx context.Context, id commonids.AppServiceId, options StartNetworkTraceOperationOptions) error { + result, err := c.StartNetworkTrace(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTrace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTrace: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startnetworktraceslot.go b/resource-manager/web/2023-12-01/webapps/method_startnetworktraceslot.go new file mode 100644 index 00000000000..50d223940d5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startnetworktraceslot.go @@ -0,0 +1,107 @@ +package webapps + +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 StartNetworkTraceSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartNetworkTraceSlotOperationOptions() StartNetworkTraceSlotOperationOptions { + return StartNetworkTraceSlotOperationOptions{} +} + +func (o StartNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartNetworkTraceSlot ... +func (c WebAppsClient) StartNetworkTraceSlot(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) (result StartNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startNetworkTrace", 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 +} + +// StartNetworkTraceSlotThenPoll performs StartNetworkTraceSlot then polls until it's completed +func (c WebAppsClient) StartNetworkTraceSlotThenPoll(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) error { + result, err := c.StartNetworkTraceSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTraceSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTraceSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startslot.go b/resource-manager/web/2023-12-01/webapps/method_startslot.go new file mode 100644 index 00000000000..e1ef6c58413 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startslot.go @@ -0,0 +1,47 @@ +package webapps + +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 StartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartSlot ... +func (c WebAppsClient) StartSlot(ctx context.Context, id SlotId) (result StartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktrace.go b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktrace.go new file mode 100644 index 00000000000..65c5c68ef51 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktrace.go @@ -0,0 +1,92 @@ +package webapps + +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 StartWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceOperationOptions() StartWebSiteNetworkTraceOperationOptions { + return StartWebSiteNetworkTraceOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTrace ... +func (c WebAppsClient) StartWebSiteNetworkTrace(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOptions) (result StartWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/start", 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 + } + + var model string + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperation.go b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperation.go new file mode 100644 index 00000000000..21703009ddc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperation.go @@ -0,0 +1,108 @@ +package webapps + +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/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 StartWebSiteNetworkTraceOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartWebSiteNetworkTraceOperationOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceOperationOperationOptions() StartWebSiteNetworkTraceOperationOperationOptions { + return StartWebSiteNetworkTraceOperationOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTraceOperation ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperation(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOperationOptions) (result StartWebSiteNetworkTraceOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/startOperation", 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 +} + +// StartWebSiteNetworkTraceOperationThenPoll performs StartWebSiteNetworkTraceOperation then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationThenPoll(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperation(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperationslot.go b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperationslot.go new file mode 100644 index 00000000000..2d71a255ba4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceoperationslot.go @@ -0,0 +1,107 @@ +package webapps + +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 StartWebSiteNetworkTraceOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartWebSiteNetworkTraceOperationSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions() StartWebSiteNetworkTraceOperationSlotOperationOptions { + return StartWebSiteNetworkTraceOperationSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTraceOperationSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) (result StartWebSiteNetworkTraceOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/startOperation", 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 +} + +// StartWebSiteNetworkTraceOperationSlotThenPoll performs StartWebSiteNetworkTraceOperationSlot then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlotThenPoll(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperationSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceslot.go b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceslot.go new file mode 100644 index 00000000000..b52ac41f1a2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_startwebsitenetworktraceslot.go @@ -0,0 +1,91 @@ +package webapps + +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 StartWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasUrl *string +} + +func DefaultStartWebSiteNetworkTraceSlotOperationOptions() StartWebSiteNetworkTraceSlotOperationOptions { + return StartWebSiteNetworkTraceSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasUrl != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasUrl)) + } + return &out +} + +// StartWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceSlotOperationOptions) (result StartWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/start", 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 + } + + var model string + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stop.go b/resource-manager/web/2023-12-01/webapps/method_stop.go new file mode 100644 index 00000000000..7f3caf53d9d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stop.go @@ -0,0 +1,48 @@ +package webapps + +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 StopOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c WebAppsClient) Stop(ctx context.Context, id commonids.AppServiceId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjob.go b/resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjob.go new file mode 100644 index 00000000000..66fcde1e73b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +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 StopContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJob ... +func (c WebAppsClient) StopContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StopContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjobslot.go b/resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjobslot.go new file mode 100644 index 00000000000..6195a3125e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stopcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +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 StopContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJobSlot ... +func (c WebAppsClient) StopContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StopContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stopnetworktrace.go b/resource-manager/web/2023-12-01/webapps/method_stopnetworktrace.go new file mode 100644 index 00000000000..098cdf97671 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stopnetworktrace.go @@ -0,0 +1,49 @@ +package webapps + +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 StopNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTrace ... +func (c WebAppsClient) StopNetworkTrace(ctx context.Context, id commonids.AppServiceId) (result StopNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stopnetworktraceslot.go b/resource-manager/web/2023-12-01/webapps/method_stopnetworktraceslot.go new file mode 100644 index 00000000000..08644e40fc9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stopnetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +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 StopNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTraceSlot ... +func (c WebAppsClient) StopNetworkTraceSlot(ctx context.Context, id SlotId) (result StopNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stopslot.go b/resource-manager/web/2023-12-01/webapps/method_stopslot.go new file mode 100644 index 00000000000..cd89d662a26 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stopslot.go @@ -0,0 +1,47 @@ +package webapps + +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 StopSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopSlot ... +func (c WebAppsClient) StopSlot(ctx context.Context, id SlotId) (result StopSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktrace.go b/resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktrace.go new file mode 100644 index 00000000000..7c3fcd820e8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktrace.go @@ -0,0 +1,49 @@ +package webapps + +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 StopWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTrace ... +func (c WebAppsClient) StopWebSiteNetworkTrace(ctx context.Context, id commonids.AppServiceId) (result StopWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktraceslot.go b/resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktraceslot.go new file mode 100644 index 00000000000..4ac3a77814a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_stopwebsitenetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +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 StopWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StopWebSiteNetworkTraceSlot(ctx context.Context, id SlotId) (result StopWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_swapslotslot.go b/resource-manager/web/2023-12-01/webapps/method_swapslotslot.go new file mode 100644 index 00000000000..4adb4148b94 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_swapslotslot.go @@ -0,0 +1,74 @@ +package webapps + +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 SwapSlotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotSlot ... +func (c WebAppsClient) SwapSlotSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result SwapSlotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", 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 +} + +// SwapSlotSlotThenPoll performs SwapSlotSlot then polls until it's completed +func (c WebAppsClient) SwapSlotSlotThenPoll(ctx context.Context, id SlotId, input CsmSlotEntity) error { + result, err := c.SwapSlotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_swapslotwithproduction.go b/resource-manager/web/2023-12-01/webapps/method_swapslotwithproduction.go new file mode 100644 index 00000000000..924b47593e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_swapslotwithproduction.go @@ -0,0 +1,75 @@ +package webapps + +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/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 SwapSlotWithProductionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotWithProduction ... +func (c WebAppsClient) SwapSlotWithProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result SwapSlotWithProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", 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 +} + +// SwapSlotWithProductionThenPoll performs SwapSlotWithProduction then polls until it's completed +func (c WebAppsClient) SwapSlotWithProductionThenPoll(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) error { + result, err := c.SwapSlotWithProduction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotWithProduction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotWithProduction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/webapps/method_syncfunctions.go b/resource-manager/web/2023-12-01/webapps/method_syncfunctions.go new file mode 100644 index 00000000000..f9e53a89d27 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_syncfunctions.go @@ -0,0 +1,48 @@ +package webapps + +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 SyncFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctions ... +func (c WebAppsClient) SyncFunctions(ctx context.Context, id commonids.AppServiceId) (result SyncFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_syncfunctionsslot.go b/resource-manager/web/2023-12-01/webapps/method_syncfunctionsslot.go new file mode 100644 index 00000000000..37773597814 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_syncfunctionsslot.go @@ -0,0 +1,47 @@ +package webapps + +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 SyncFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionsSlot ... +func (c WebAppsClient) SyncFunctionsSlot(ctx context.Context, id SlotId) (result SyncFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggers.go b/resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggers.go new file mode 100644 index 00000000000..1370fe7c5d3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggers.go @@ -0,0 +1,48 @@ +package webapps + +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 SyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggers ... +func (c WebAppsClient) SyncFunctionTriggers(ctx context.Context, id commonids.AppServiceId) (result SyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggersslot.go b/resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggersslot.go new file mode 100644 index 00000000000..f3cef3f11df --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_syncfunctiontriggersslot.go @@ -0,0 +1,47 @@ +package webapps + +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 SyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggersSlot ... +func (c WebAppsClient) SyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result SyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_syncrepository.go b/resource-manager/web/2023-12-01/webapps/method_syncrepository.go new file mode 100644 index 00000000000..d798d4f5793 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_syncrepository.go @@ -0,0 +1,48 @@ +package webapps + +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 SyncRepositoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepository ... +func (c WebAppsClient) SyncRepository(ctx context.Context, id commonids.AppServiceId) (result SyncRepositoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_syncrepositoryslot.go b/resource-manager/web/2023-12-01/webapps/method_syncrepositoryslot.go new file mode 100644 index 00000000000..81b7009d872 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_syncrepositoryslot.go @@ -0,0 +1,47 @@ +package webapps + +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 SyncRepositorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepositorySlot ... +func (c WebAppsClient) SyncRepositorySlot(ctx context.Context, id SlotId) (result SyncRepositorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_update.go b/resource-manager/web/2023-12-01/webapps/method_update.go new file mode 100644 index 00000000000..ed1ba13fa40 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_update.go @@ -0,0 +1,60 @@ +package webapps + +import ( + "context" + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Update ... +func (c WebAppsClient) Update(ctx context.Context, id commonids.AppServiceId, input SitePatchResource) (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 + } + + var model Site + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateapplicationsettings.go b/resource-manager/web/2023-12-01/webapps/method_updateapplicationsettings.go new file mode 100644 index 00000000000..f60ab8838c9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateapplicationsettings.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettings ... +func (c WebAppsClient) UpdateApplicationSettings(ctx context.Context, id commonids.AppServiceId, input StringDictionary) (result UpdateApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateapplicationsettingsslot.go b/resource-manager/web/2023-12-01/webapps/method_updateapplicationsettingsslot.go new file mode 100644 index 00000000000..b0382487cf8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateapplicationsettingsslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettingsSlot ... +func (c WebAppsClient) UpdateApplicationSettingsSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateauthsettings.go b/resource-manager/web/2023-12-01/webapps/method_updateauthsettings.go new file mode 100644 index 00000000000..ff363074bef --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateauthsettings.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettings ... +func (c WebAppsClient) UpdateAuthSettings(ctx context.Context, id commonids.AppServiceId, input SiteAuthSettings) (result UpdateAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsslot.go b/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsslot.go new file mode 100644 index 00000000000..434d233bfd4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettingsSlot ... +func (c WebAppsClient) UpdateAuthSettingsSlot(ctx context.Context, id SlotId, input SiteAuthSettings) (result UpdateAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2.go b/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2.go new file mode 100644 index 00000000000..d4fce76e8de --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2 ... +func (c WebAppsClient) UpdateAuthSettingsV2(ctx context.Context, id commonids.AppServiceId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2slot.go b/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2slot.go new file mode 100644 index 00000000000..e6ea9a8b1ee --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateauthsettingsv2slot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2Slot ... +func (c WebAppsClient) UpdateAuthSettingsV2Slot(ctx context.Context, id SlotId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccounts.go b/resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccounts.go new file mode 100644 index 00000000000..a3ae2d6b3c9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccounts.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccounts ... +func (c WebAppsClient) UpdateAzureStorageAccounts(ctx context.Context, id commonids.AppServiceId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccountsslot.go b/resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccountsslot.go new file mode 100644 index 00000000000..16e730b1e99 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateazurestorageaccountsslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccountsSlot ... +func (c WebAppsClient) UpdateAzureStorageAccountsSlot(ctx context.Context, id SlotId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatebackupconfiguration.go b/resource-manager/web/2023-12-01/webapps/method_updatebackupconfiguration.go new file mode 100644 index 00000000000..b8bf6ec24e8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatebackupconfiguration.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfiguration ... +func (c WebAppsClient) UpdateBackupConfiguration(ctx context.Context, id commonids.AppServiceId, input BackupRequest) (result UpdateBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatebackupconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_updatebackupconfigurationslot.go new file mode 100644 index 00000000000..74c8ef4b5e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatebackupconfigurationslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfigurationSlot ... +func (c WebAppsClient) UpdateBackupConfigurationSlot(ctx context.Context, id SlotId, input BackupRequest) (result UpdateBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateconfiguration.go b/resource-manager/web/2023-12-01/webapps/method_updateconfiguration.go new file mode 100644 index 00000000000..ace56a0e15a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateconfiguration.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfiguration ... +func (c WebAppsClient) UpdateConfiguration(ctx context.Context, id commonids.AppServiceId, input SiteConfigResource) (result UpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateconfigurationslot.go b/resource-manager/web/2023-12-01/webapps/method_updateconfigurationslot.go new file mode 100644 index 00000000000..6909e91308f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateconfigurationslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfigurationSlot ... +func (c WebAppsClient) UpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result UpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateconnectionstrings.go b/resource-manager/web/2023-12-01/webapps/method_updateconnectionstrings.go new file mode 100644 index 00000000000..7d97ab27e33 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateconnectionstrings.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStrings ... +func (c WebAppsClient) UpdateConnectionStrings(ctx context.Context, id commonids.AppServiceId, input ConnectionStringDictionary) (result UpdateConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateconnectionstringsslot.go b/resource-manager/web/2023-12-01/webapps/method_updateconnectionstringsslot.go new file mode 100644 index 00000000000..197d01fa963 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateconnectionstringsslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStringsSlot ... +func (c WebAppsClient) UpdateConnectionStringsSlot(ctx context.Context, id SlotId, input ConnectionStringDictionary) (result UpdateConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfig.go b/resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfig.go new file mode 100644 index 00000000000..8885b9ada96 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfig.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateDiagnosticLogsConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfig ... +func (c WebAppsClient) UpdateDiagnosticLogsConfig(ctx context.Context, id commonids.AppServiceId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfigslot.go b/resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfigslot.go new file mode 100644 index 00000000000..7e46415c0a9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatediagnosticlogsconfigslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateDiagnosticLogsConfigSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfigSlot ... +func (c WebAppsClient) UpdateDiagnosticLogsConfigSlot(ctx context.Context, id SlotId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifier.go b/resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifier.go new file mode 100644 index 00000000000..e2f684a8ec6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifier.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Identifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifierslot.go b/resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..118cec095ff --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatedomainownershipidentifierslot.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model Identifier + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateftpallowed.go b/resource-manager/web/2023-12-01/webapps/method_updateftpallowed.go new file mode 100644 index 00000000000..d8b2976c309 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateftpallowed.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowed ... +func (c WebAppsClient) UpdateFtpAllowed(ctx context.Context, id commonids.AppServiceId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateftpallowedslot.go b/resource-manager/web/2023-12-01/webapps/method_updateftpallowedslot.go new file mode 100644 index 00000000000..5e3125acabb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateftpallowedslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowedSlot ... +func (c WebAppsClient) UpdateFtpAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatehybridconnection.go b/resource-manager/web/2023-12-01/webapps/method_updatehybridconnection.go new file mode 100644 index 00000000000..3641ff27936 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatehybridconnection.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnection ... +func (c WebAppsClient) UpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result UpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatehybridconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_updatehybridconnectionslot.go new file mode 100644 index 00000000000..51cc1d0206d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatehybridconnectionslot.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnectionSlot ... +func (c WebAppsClient) UpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result UpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model HybridConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatemetadata.go b/resource-manager/web/2023-12-01/webapps/method_updatemetadata.go new file mode 100644 index 00000000000..e5e463a2656 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatemetadata.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadata ... +func (c WebAppsClient) UpdateMetadata(ctx context.Context, id commonids.AppServiceId, input StringDictionary) (result UpdateMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatemetadataslot.go b/resource-manager/web/2023-12-01/webapps/method_updatemetadataslot.go new file mode 100644 index 00000000000..7f24c677cda --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatemetadataslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadataSlot ... +func (c WebAppsClient) UpdateMetadataSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatepremieraddon.go b/resource-manager/web/2023-12-01/webapps/method_updatepremieraddon.go new file mode 100644 index 00000000000..283da43f6b9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatepremieraddon.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdatePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOn ... +func (c WebAppsClient) UpdatePremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatepremieraddonslot.go b/resource-manager/web/2023-12-01/webapps/method_updatepremieraddonslot.go new file mode 100644 index 00000000000..a37e30d7c27 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatepremieraddonslot.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdatePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOnSlot ... +func (c WebAppsClient) UpdatePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model PremierAddOn + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnection.go b/resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnection.go new file mode 100644 index 00000000000..3c8dfb4108d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnection.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnection ... +func (c WebAppsClient) UpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..fca0b74fb39 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updaterelayserviceconnectionslot.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) UpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model RelayServiceConnectionEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatescmallowed.go b/resource-manager/web/2023-12-01/webapps/method_updatescmallowed.go new file mode 100644 index 00000000000..0be20463210 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatescmallowed.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowed ... +func (c WebAppsClient) UpdateScmAllowed(ctx context.Context, id commonids.AppServiceId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatescmallowedslot.go b/resource-manager/web/2023-12-01/webapps/method_updatescmallowedslot.go new file mode 100644 index 00000000000..f124b6f3526 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatescmallowedslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowedSlot ... +func (c WebAppsClient) UpdateScmAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatesitepushsettings.go b/resource-manager/web/2023-12-01/webapps/method_updatesitepushsettings.go new file mode 100644 index 00000000000..20b493aae8c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatesitepushsettings.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettings ... +func (c WebAppsClient) UpdateSitePushSettings(ctx context.Context, id commonids.AppServiceId, input PushSettings) (result UpdateSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatesitepushsettingsslot.go b/resource-manager/web/2023-12-01/webapps/method_updatesitepushsettingsslot.go new file mode 100644 index 00000000000..774c0e26cbd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatesitepushsettingsslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettingsSlot ... +func (c WebAppsClient) UpdateSitePushSettingsSlot(ctx context.Context, id SlotId, input PushSettings) (result UpdateSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateslot.go b/resource-manager/web/2023-12-01/webapps/method_updateslot.go new file mode 100644 index 00000000000..d7a0e90cd61 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// UpdateSlot ... +func (c WebAppsClient) UpdateSlot(ctx context.Context, id SlotId, input SitePatchResource) (result UpdateSlotOperationResponse, 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 + } + + var model Site + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateslotconfigurationnames.go b/resource-manager/web/2023-12-01/webapps/method_updateslotconfigurationnames.go new file mode 100644 index 00000000000..f4f5b05b966 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateslotconfigurationnames.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// UpdateSlotConfigurationNames ... +func (c WebAppsClient) UpdateSlotConfigurationNames(ctx context.Context, id commonids.AppServiceId, input SlotConfigNamesResource) (result UpdateSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/slotConfigNames", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SlotConfigNamesResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatesourcecontrol.go b/resource-manager/web/2023-12-01/webapps/method_updatesourcecontrol.go new file mode 100644 index 00000000000..792bf5a462b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatesourcecontrol.go @@ -0,0 +1,62 @@ +package webapps + +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 UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControl ... +func (c WebAppsClient) UpdateSourceControl(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatesourcecontrolslot.go b/resource-manager/web/2023-12-01/webapps/method_updatesourcecontrolslot.go new file mode 100644 index 00000000000..5d25563b5d0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatesourcecontrolslot.go @@ -0,0 +1,61 @@ +package webapps + +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 UpdateSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControlSlot ... +func (c WebAppsClient) UpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result UpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..b54e54b619e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,60 @@ +package webapps + +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 UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id commonids.AppServiceId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..48bbaa559c8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,59 @@ +package webapps + +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 UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatevnetconnection.go b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnection.go new file mode 100644 index 00000000000..987cb8fbff7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnection.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnection ... +func (c WebAppsClient) UpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongateway.go b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongateway.go new file mode 100644 index 00000000000..dd57888f81e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongateway.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGateway ... +func (c WebAppsClient) UpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result UpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongatewayslot.go b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..1be5209f364 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectiongatewayslot.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) UpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetGateway + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectionslot.go b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectionslot.go new file mode 100644 index 00000000000..c076ea62f81 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/method_updatevnetconnectionslot.go @@ -0,0 +1,58 @@ +package webapps + +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 UpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnectionSlot ... +func (c WebAppsClient) UpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + var model VnetInfoResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/webapps/model_allowedaudiencesvalidation.go b/resource-manager/web/2023-12-01/webapps/model_allowedaudiencesvalidation.go new file mode 100644 index 00000000000..da259d9fd38 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_allowedaudiencesvalidation.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedAudiencesValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_allowedprincipals.go b/resource-manager/web/2023-12-01/webapps/model_allowedprincipals.go new file mode 100644 index 00000000000..b17b5652dd2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_allowedprincipals.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedPrincipals struct { + Groups *[]string `json:"groups,omitempty"` + Identities *[]string `json:"identities,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_apidefinitioninfo.go b/resource-manager/web/2023-12-01/webapps/model_apidefinitioninfo.go new file mode 100644 index 00000000000..152027e15e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_apikvreference.go b/resource-manager/web/2023-12-01/webapps/model_apikvreference.go new file mode 100644 index 00000000000..62f12266d3b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_apikvreference.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReference struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApiKVReferenceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_apikvreferenceproperties.go b/resource-manager/web/2023-12-01/webapps/model_apikvreferenceproperties.go new file mode 100644 index 00000000000..58a0f5398cc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_apikvreferenceproperties.go @@ -0,0 +1,20 @@ +package webapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReferenceProperties struct { + ActiveVersion *string `json:"activeVersion,omitempty"` + Details *string `json:"details,omitempty"` + IdentityType *identity.SystemAndUserAssignedMap `json:"identityType,omitempty"` + Reference *string `json:"reference,omitempty"` + SecretName *string `json:"secretName,omitempty"` + SecretVersion *string `json:"secretVersion,omitempty"` + Source *ConfigReferenceSource `json:"source,omitempty"` + Status *ResolveStatus `json:"status,omitempty"` + VaultName *string `json:"vaultName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_apimanagementconfig.go b/resource-manager/web/2023-12-01/webapps/model_apimanagementconfig.go new file mode 100644 index 00000000000..9acd3c84278 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_apple.go b/resource-manager/web/2023-12-01/webapps/model_apple.go new file mode 100644 index 00000000000..69e9769061b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_apple.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Apple struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppleRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_appleregistration.go b/resource-manager/web/2023-12-01/webapps/model_appleregistration.go new file mode 100644 index 00000000000..304a6b2b50f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_appleregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppleRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_applicationlogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_applicationlogsconfig.go new file mode 100644 index 00000000000..9734bceb194 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_applicationlogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationLogsConfig struct { + AzureBlobStorage *AzureBlobStorageApplicationLogsConfig `json:"azureBlobStorage,omitempty"` + AzureTableStorage *AzureTableStorageApplicationLogsConfig `json:"azureTableStorage,omitempty"` + FileSystem *FileSystemApplicationLogsConfig `json:"fileSystem,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_appregistration.go b/resource-manager/web/2023-12-01/webapps/model_appregistration.go new file mode 100644 index 00000000000..658b68d4c6e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_appregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppRegistration struct { + AppId *string `json:"appId,omitempty"` + AppSecretSettingName *string `json:"appSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_armidwrapper.go b/resource-manager/web/2023-12-01/webapps/model_armidwrapper.go new file mode 100644 index 00000000000..f73fbd64bb2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_armidwrapper.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_authplatform.go b/resource-manager/web/2023-12-01/webapps/model_authplatform.go new file mode 100644 index 00000000000..c1222a45d4e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_authplatform.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthPlatform struct { + ConfigFilePath *string `json:"configFilePath,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_autohealactions.go b/resource-manager/web/2023-12-01/webapps/model_autohealactions.go new file mode 100644 index 00000000000..c33d955c76e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_autohealactions.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_autohealcustomaction.go b/resource-manager/web/2023-12-01/webapps/model_autohealcustomaction.go new file mode 100644 index 00000000000..49bfb9eb35b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_autohealrules.go b/resource-manager/web/2023-12-01/webapps/model_autohealrules.go new file mode 100644 index 00000000000..b96bc1ad965 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_autohealrules.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_autohealtriggers.go b/resource-manager/web/2023-12-01/webapps/model_autohealtriggers.go new file mode 100644 index 00000000000..932862aab96 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azureactivedirectory.go b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectory.go new file mode 100644 index 00000000000..cda4c5114d2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectory.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectory struct { + Enabled *bool `json:"enabled,omitempty"` + IsAutoProvisioned *bool `json:"isAutoProvisioned,omitempty"` + Login *AzureActiveDirectoryLogin `json:"login,omitempty"` + Registration *AzureActiveDirectoryRegistration `json:"registration,omitempty"` + Validation *AzureActiveDirectoryValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azureactivedirectorylogin.go b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectorylogin.go new file mode 100644 index 00000000000..590062cd0e1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectorylogin.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryLogin struct { + DisableWWWAuthenticate *bool `json:"disableWWWAuthenticate,omitempty"` + LoginParameters *[]string `json:"loginParameters,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryregistration.go b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryregistration.go new file mode 100644 index 00000000000..8cb7ab16efb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryregistration.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretCertificateIssuer *string `json:"clientSecretCertificateIssuer,omitempty"` + ClientSecretCertificateSubjectAlternativeName *string `json:"clientSecretCertificateSubjectAlternativeName,omitempty"` + ClientSecretCertificateThumbprint *string `json:"clientSecretCertificateThumbprint,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + OpenIdIssuer *string `json:"openIdIssuer,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryvalidation.go b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryvalidation.go new file mode 100644 index 00000000000..bd699d34a12 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azureactivedirectoryvalidation.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` + DefaultAuthorizationPolicy *DefaultAuthorizationPolicy `json:"defaultAuthorizationPolicy,omitempty"` + JwtClaimChecks *JwtClaimChecks `json:"jwtClaimChecks,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azureblobstorageapplicationlogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_azureblobstorageapplicationlogsconfig.go new file mode 100644 index 00000000000..d17b5f8ddb1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azureblobstorageapplicationlogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBlobStorageApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + SasUrl *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azureblobstoragehttplogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_azureblobstoragehttplogsconfig.go new file mode 100644 index 00000000000..4bafbbd06e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azureblobstoragehttplogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBlobStorageHTTPLogsConfig struct { + Enabled *bool `json:"enabled,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + SasUrl *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azurestaticwebapps.go b/resource-manager/web/2023-12-01/webapps/model_azurestaticwebapps.go new file mode 100644 index 00000000000..16d67230d5f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azurestaticwebapps.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebApps struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *AzureStaticWebAppsRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azurestaticwebappsregistration.go b/resource-manager/web/2023-12-01/webapps/model_azurestaticwebappsregistration.go new file mode 100644 index 00000000000..bd78e405cfe --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azurestaticwebappsregistration.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebAppsRegistration struct { + ClientId *string `json:"clientId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azurestorageinfovalue.go b/resource-manager/web/2023-12-01/webapps/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..e92f9c01952 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azurestoragepropertydictionaryresource.go b/resource-manager/web/2023-12-01/webapps/model_azurestoragepropertydictionaryresource.go new file mode 100644 index 00000000000..6c7675fec3f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azurestoragepropertydictionaryresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStoragePropertyDictionaryResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]AzureStorageInfoValue `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_azuretablestorageapplicationlogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_azuretablestorageapplicationlogsconfig.go new file mode 100644 index 00000000000..6a87bfc0dc9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_azuretablestorageapplicationlogsconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureTableStorageApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` + SasUrl string `json:"sasUrl"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_backupitem.go b/resource-manager/web/2023-12-01/webapps/model_backupitem.go new file mode 100644 index 00000000000..7bf578be3a9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_backupitem.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupItem struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_backupitemproperties.go b/resource-manager/web/2023-12-01/webapps/model_backupitemproperties.go new file mode 100644 index 00000000000..577e4eb1a23 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_backupitemproperties.go @@ -0,0 +1,63 @@ +package webapps + +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 BackupItemProperties struct { + BlobName *string `json:"blobName,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + Created *string `json:"created,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + FinishedTimeStamp *string `json:"finishedTimeStamp,omitempty"` + Id *int64 `json:"id,omitempty"` + LastRestoreTimeStamp *string `json:"lastRestoreTimeStamp,omitempty"` + Log *string `json:"log,omitempty"` + Name *string `json:"name,omitempty"` + Scheduled *bool `json:"scheduled,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + Status *BackupItemStatus `json:"status,omitempty"` + StorageAccountUrl *string `json:"storageAccountUrl,omitempty"` + WebsiteSizeInBytes *int64 `json:"websiteSizeInBytes,omitempty"` +} + +func (o *BackupItemProperties) GetCreatedAsTime() (*time.Time, error) { + if o.Created == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Created, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Created = &formatted +} + +func (o *BackupItemProperties) GetFinishedTimeStampAsTime() (*time.Time, error) { + if o.FinishedTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FinishedTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetFinishedTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FinishedTimeStamp = &formatted +} + +func (o *BackupItemProperties) GetLastRestoreTimeStampAsTime() (*time.Time, error) { + if o.LastRestoreTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRestoreTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetLastRestoreTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRestoreTimeStamp = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_backuprequest.go b/resource-manager/web/2023-12-01/webapps/model_backuprequest.go new file mode 100644 index 00000000000..5247f8695cc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_backuprequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_backuprequestproperties.go b/resource-manager/web/2023-12-01/webapps/model_backuprequestproperties.go new file mode 100644 index 00000000000..8a3f52e475f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_backuprequestproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequestProperties struct { + BackupName *string `json:"backupName,omitempty"` + BackupSchedule *BackupSchedule `json:"backupSchedule,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + StorageAccountUrl string `json:"storageAccountUrl"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_backupschedule.go b/resource-manager/web/2023-12-01/webapps/model_backupschedule.go new file mode 100644 index 00000000000..8fb777f2e01 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_backupschedule.go @@ -0,0 +1,43 @@ +package webapps + +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 BackupSchedule struct { + FrequencyInterval int64 `json:"frequencyInterval"` + FrequencyUnit FrequencyUnit `json:"frequencyUnit"` + KeepAtLeastOneBackup bool `json:"keepAtLeastOneBackup"` + LastExecutionTime *string `json:"lastExecutionTime,omitempty"` + RetentionPeriodInDays int64 `json:"retentionPeriodInDays"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *BackupSchedule) GetLastExecutionTimeAsTime() (*time.Time, error) { + if o.LastExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupSchedule) SetLastExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastExecutionTime = &formatted +} + +func (o *BackupSchedule) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupSchedule) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_blobstoragetokenstore.go b/resource-manager/web/2023-12-01/webapps/model_blobstoragetokenstore.go new file mode 100644 index 00000000000..002a55f2dad --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_blobstoragetokenstore.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BlobStorageTokenStore struct { + SasUrlSettingName *string `json:"sasUrlSettingName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_clientregistration.go b/resource-manager/web/2023-12-01/webapps/model_clientregistration.go new file mode 100644 index 00000000000..a0983671ae0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_clientregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_cloninginfo.go b/resource-manager/web/2023-12-01/webapps/model_cloninginfo.go new file mode 100644 index 00000000000..0934bb9fecc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_cloninginfo.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_connectionstringdictionary.go b/resource-manager/web/2023-12-01/webapps/model_connectionstringdictionary.go new file mode 100644 index 00000000000..ce8d8b95927 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_connectionstringdictionary.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionStringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]ConnStringValueTypePair `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_connstringinfo.go b/resource-manager/web/2023-12-01/webapps/model_connstringinfo.go new file mode 100644 index 00000000000..a41ade2e9db --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_connstringinfo.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_connstringvaluetypepair.go b/resource-manager/web/2023-12-01/webapps/model_connstringvaluetypepair.go new file mode 100644 index 00000000000..a80c0c6b95e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_connstringvaluetypepair.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringValueTypePair struct { + Type ConnectionStringType `json:"type"` + Value string `json:"value"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_containercpustatistics.go b/resource-manager/web/2023-12-01/webapps/model_containercpustatistics.go new file mode 100644 index 00000000000..dd2b3964567 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_containercpustatistics.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerCPUStatistics struct { + CpuUsage *ContainerCPUUsage `json:"cpuUsage,omitempty"` + OnlineCPUCount *int64 `json:"onlineCpuCount,omitempty"` + SystemCPUUsage *int64 `json:"systemCpuUsage,omitempty"` + ThrottlingData *ContainerThrottlingData `json:"throttlingData,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_containercpuusage.go b/resource-manager/web/2023-12-01/webapps/model_containercpuusage.go new file mode 100644 index 00000000000..c7c0de7ff15 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_containercpuusage.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerCPUUsage struct { + KernelModeUsage *int64 `json:"kernelModeUsage,omitempty"` + PerCPUUsage *[]int64 `json:"perCpuUsage,omitempty"` + TotalUsage *int64 `json:"totalUsage,omitempty"` + UserModeUsage *int64 `json:"userModeUsage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_containerinfo.go b/resource-manager/web/2023-12-01/webapps/model_containerinfo.go new file mode 100644 index 00000000000..e69d7c9d60a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_containerinfo.go @@ -0,0 +1,45 @@ +package webapps + +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 ContainerInfo struct { + CurrentCPUStats *ContainerCPUStatistics `json:"currentCpuStats,omitempty"` + CurrentTimeStamp *string `json:"currentTimeStamp,omitempty"` + Eth0 *ContainerNetworkInterfaceStatistics `json:"eth0,omitempty"` + Id *string `json:"id,omitempty"` + MemoryStats *ContainerMemoryStatistics `json:"memoryStats,omitempty"` + Name *string `json:"name,omitempty"` + PreviousCPUStats *ContainerCPUStatistics `json:"previousCpuStats,omitempty"` + PreviousTimeStamp *string `json:"previousTimeStamp,omitempty"` +} + +func (o *ContainerInfo) GetCurrentTimeStampAsTime() (*time.Time, error) { + if o.CurrentTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CurrentTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerInfo) SetCurrentTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CurrentTimeStamp = &formatted +} + +func (o *ContainerInfo) GetPreviousTimeStampAsTime() (*time.Time, error) { + if o.PreviousTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PreviousTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerInfo) SetPreviousTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PreviousTimeStamp = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_containermemorystatistics.go b/resource-manager/web/2023-12-01/webapps/model_containermemorystatistics.go new file mode 100644 index 00000000000..766817d234f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_containermemorystatistics.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerMemoryStatistics struct { + Limit *int64 `json:"limit,omitempty"` + MaxUsage *int64 `json:"maxUsage,omitempty"` + Usage *int64 `json:"usage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_containernetworkinterfacestatistics.go b/resource-manager/web/2023-12-01/webapps/model_containernetworkinterfacestatistics.go new file mode 100644 index 00000000000..70eed77205c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_containernetworkinterfacestatistics.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfaceStatistics struct { + RxBytes *int64 `json:"rxBytes,omitempty"` + RxDropped *int64 `json:"rxDropped,omitempty"` + RxErrors *int64 `json:"rxErrors,omitempty"` + RxPackets *int64 `json:"rxPackets,omitempty"` + TxBytes *int64 `json:"txBytes,omitempty"` + TxDropped *int64 `json:"txDropped,omitempty"` + TxErrors *int64 `json:"txErrors,omitempty"` + TxPackets *int64 `json:"txPackets,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_containerthrottlingdata.go b/resource-manager/web/2023-12-01/webapps/model_containerthrottlingdata.go new file mode 100644 index 00000000000..9a8399671cb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_containerthrottlingdata.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerThrottlingData struct { + Periods *int64 `json:"periods,omitempty"` + ThrottledPeriods *int64 `json:"throttledPeriods,omitempty"` + ThrottledTime *int64 `json:"throttledTime,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_continuouswebjob.go b/resource-manager/web/2023-12-01/webapps/model_continuouswebjob.go new file mode 100644 index 00000000000..960c0b21c35 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_continuouswebjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousWebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContinuousWebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_continuouswebjobproperties.go b/resource-manager/web/2023-12-01/webapps/model_continuouswebjobproperties.go new file mode 100644 index 00000000000..ae1f697a892 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_continuouswebjobproperties.go @@ -0,0 +1,17 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousWebJobProperties struct { + DetailedStatus *string `json:"detailed_status,omitempty"` + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + LogUrl *string `json:"log_url,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + Status *ContinuousWebJobStatus `json:"status,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_cookieexpiration.go b/resource-manager/web/2023-12-01/webapps/model_cookieexpiration.go new file mode 100644 index 00000000000..1acd40bff42 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_cookieexpiration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CookieExpiration struct { + Convention *CookieExpirationConvention `json:"convention,omitempty"` + TimeToExpiration *string `json:"timeToExpiration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_corssettings.go b/resource-manager/web/2023-12-01/webapps/model_corssettings.go new file mode 100644 index 00000000000..58894d63e23 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_corssettings.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatus.go b/resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatus.go new file mode 100644 index 00000000000..011d7f38b97 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmDeploymentStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CsmDeploymentStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatusproperties.go b/resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatusproperties.go new file mode 100644 index 00000000000..08a6ae20c11 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_csmdeploymentstatusproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmDeploymentStatusProperties struct { + DeploymentId *string `json:"deploymentId,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + FailedInstancesLogs *[]string `json:"failedInstancesLogs,omitempty"` + NumberOfInstancesFailed *int64 `json:"numberOfInstancesFailed,omitempty"` + NumberOfInstancesInProgress *int64 `json:"numberOfInstancesInProgress,omitempty"` + NumberOfInstancesSuccessful *int64 `json:"numberOfInstancesSuccessful,omitempty"` + Status *DeploymentBuildStatus `json:"status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentity.go b/resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentity.go new file mode 100644 index 00000000000..dcdf32e913e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentity.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingCredentialsPoliciesEntity struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CsmPublishingCredentialsPoliciesEntityProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go b/resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go new file mode 100644 index 00000000000..bc91e5c0882 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingCredentialsPoliciesEntityProperties struct { + Allow bool `json:"allow"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_csmpublishingprofileoptions.go b/resource-manager/web/2023-12-01/webapps/model_csmpublishingprofileoptions.go new file mode 100644 index 00000000000..acf65055371 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_csmpublishingprofileoptions.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingProfileOptions struct { + Format *PublishingProfileFormat `json:"format,omitempty"` + IncludeDisasterRecoveryEndpoints *bool `json:"includeDisasterRecoveryEndpoints,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_csmslotentity.go b/resource-manager/web/2023-12-01/webapps/model_csmslotentity.go new file mode 100644 index 00000000000..086fe3ab931 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_csmslotentity.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmSlotEntity struct { + PreserveVnet bool `json:"preserveVnet"` + TargetSlot string `json:"targetSlot"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_csmusagequota.go b/resource-manager/web/2023-12-01/webapps/model_csmusagequota.go new file mode 100644 index 00000000000..7fad4d7865d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_csmusagequota.go @@ -0,0 +1,30 @@ +package webapps + +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 CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresult.go b/resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresult.go new file mode 100644 index 00000000000..965958b5906 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresult.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResult struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomHostnameAnalysisResultProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresultproperties.go b/resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresultproperties.go new file mode 100644 index 00000000000..e8641765248 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_customhostnameanalysisresultproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResultProperties struct { + ARecords *[]string `json:"aRecords,omitempty"` + AlternateCNameRecords *[]string `json:"alternateCNameRecords,omitempty"` + AlternateTxtRecords *[]string `json:"alternateTxtRecords,omitempty"` + CNameRecords *[]string `json:"cNameRecords,omitempty"` + ConflictingAppResourceId *string `json:"conflictingAppResourceId,omitempty"` + CustomDomainVerificationFailureInfo *ErrorEntity `json:"customDomainVerificationFailureInfo,omitempty"` + CustomDomainVerificationTest *DnsVerificationTestResult `json:"customDomainVerificationTest,omitempty"` + HasConflictAcrossSubscription *bool `json:"hasConflictAcrossSubscription,omitempty"` + HasConflictOnScaleUnit *bool `json:"hasConflictOnScaleUnit,omitempty"` + IsHostnameAlreadyVerified *bool `json:"isHostnameAlreadyVerified,omitempty"` + TxtRecords *[]string `json:"txtRecords,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_customopenidconnectprovider.go b/resource-manager/web/2023-12-01/webapps/model_customopenidconnectprovider.go new file mode 100644 index 00000000000..6131cc54b0f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_customopenidconnectprovider.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomOpenIdConnectProvider struct { + Enabled *bool `json:"enabled,omitempty"` + Login *OpenIdConnectLogin `json:"login,omitempty"` + Registration *OpenIdConnectRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_daprconfig.go b/resource-manager/web/2023-12-01/webapps/model_daprconfig.go new file mode 100644 index 00000000000..4405627b643 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_daprconfig.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_databasebackupsetting.go b/resource-manager/web/2023-12-01/webapps/model_databasebackupsetting.go new file mode 100644 index 00000000000..57baff31aa0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_databasebackupsetting.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseBackupSetting struct { + ConnectionString *string `json:"connectionString,omitempty"` + ConnectionStringName *string `json:"connectionStringName,omitempty"` + DatabaseType DatabaseType `json:"databaseType"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_defaultauthorizationpolicy.go b/resource-manager/web/2023-12-01/webapps/model_defaultauthorizationpolicy.go new file mode 100644 index 00000000000..7cc4f0cf723 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_defaultauthorizationpolicy.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAuthorizationPolicy struct { + AllowedApplications *[]string `json:"allowedApplications,omitempty"` + AllowedPrincipals *AllowedPrincipals `json:"allowedPrincipals,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequest.go b/resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequest.go new file mode 100644 index 00000000000..9ef81650415 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedAppRestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedAppRestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequestproperties.go b/resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequestproperties.go new file mode 100644 index 00000000000..48010e62a87 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_deletedapprestorerequestproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedAppRestoreRequestProperties struct { + DeletedSiteId *string `json:"deletedSiteId,omitempty"` + RecoverConfiguration *bool `json:"recoverConfiguration,omitempty"` + SnapshotTime *string `json:"snapshotTime,omitempty"` + UseDRSecondary *bool `json:"useDRSecondary,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_deployment.go b/resource-manager/web/2023-12-01/webapps/model_deployment.go new file mode 100644 index 00000000000..764e2891dd4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_deployment.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Deployment struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeploymentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_deploymentproperties.go b/resource-manager/web/2023-12-01/webapps/model_deploymentproperties.go new file mode 100644 index 00000000000..62df75e6494 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_deploymentproperties.go @@ -0,0 +1,46 @@ +package webapps + +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 DeploymentProperties struct { + Active *bool `json:"active,omitempty"` + Author *string `json:"author,omitempty"` + AuthorEmail *string `json:"author_email,omitempty"` + Deployer *string `json:"deployer,omitempty"` + Details *string `json:"details,omitempty"` + EndTime *string `json:"end_time,omitempty"` + Message *string `json:"message,omitempty"` + StartTime *string `json:"start_time,omitempty"` + Status *int64 `json:"status,omitempty"` +} + +func (o *DeploymentProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DeploymentProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DeploymentProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DeploymentProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_enabledconfig.go b/resource-manager/web/2023-12-01/webapps/model_enabledconfig.go new file mode 100644 index 00000000000..740c6a6f750 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_enabledconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnabledConfig struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_environmentvariable.go b/resource-manager/web/2023-12-01/webapps/model_environmentvariable.go new file mode 100644 index 00000000000..44c25f7e4c1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_environmentvariable.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVariable struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_errorentity.go b/resource-manager/web/2023-12-01/webapps/model_errorentity.go new file mode 100644 index 00000000000..3d84f5ece58 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_errorentity.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_experiments.go b/resource-manager/web/2023-12-01/webapps/model_experiments.go new file mode 100644 index 00000000000..9e8a3418c84 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_experiments.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_extendedlocation.go b/resource-manager/web/2023-12-01/webapps/model_extendedlocation.go new file mode 100644 index 00000000000..3f619b04f38 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_extendedlocation.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_facebook.go b/resource-manager/web/2023-12-01/webapps/model_facebook.go new file mode 100644 index 00000000000..834ae971243 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_facebook.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Facebook struct { + Enabled *bool `json:"enabled,omitempty"` + GraphApiVersion *string `json:"graphApiVersion,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_filesystemapplicationlogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_filesystemapplicationlogsconfig.go new file mode 100644 index 00000000000..89cb89d942b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_filesystemapplicationlogsconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_filesystemhttplogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_filesystemhttplogsconfig.go new file mode 100644 index 00000000000..f69fa8fecca --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_filesystemhttplogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemHTTPLogsConfig struct { + Enabled *bool `json:"enabled,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + RetentionInMb *int64 `json:"retentionInMb,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_filesystemtokenstore.go b/resource-manager/web/2023-12-01/webapps/model_filesystemtokenstore.go new file mode 100644 index 00000000000..123a111d50b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_filesystemtokenstore.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemTokenStore struct { + Directory *string `json:"directory,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_forwardproxy.go b/resource-manager/web/2023-12-01/webapps/model_forwardproxy.go new file mode 100644 index 00000000000..897a226b706 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_forwardproxy.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ForwardProxy struct { + Convention *ForwardProxyConvention `json:"convention,omitempty"` + CustomHostHeaderName *string `json:"customHostHeaderName,omitempty"` + CustomProtoHeaderName *string `json:"customProtoHeaderName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionappconfig.go b/resource-manager/web/2023-12-01/webapps/model_functionappconfig.go new file mode 100644 index 00000000000..598987c0273 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionappconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionenvelope.go b/resource-manager/web/2023-12-01/webapps/model_functionenvelope.go new file mode 100644 index 00000000000..d690c668b8a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionenvelope.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionEnvelope struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FunctionEnvelopeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionenvelopeproperties.go b/resource-manager/web/2023-12-01/webapps/model_functionenvelopeproperties.go new file mode 100644 index 00000000000..b32434f7616 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionenvelopeproperties.go @@ -0,0 +1,20 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionEnvelopeProperties struct { + Config *interface{} `json:"config,omitempty"` + ConfigHref *string `json:"config_href,omitempty"` + Files *map[string]string `json:"files,omitempty"` + FunctionAppId *string `json:"function_app_id,omitempty"` + Href *string `json:"href,omitempty"` + InvokeUrlTemplate *string `json:"invoke_url_template,omitempty"` + IsDisabled *bool `json:"isDisabled,omitempty"` + Language *string `json:"language,omitempty"` + ScriptHref *string `json:"script_href,omitempty"` + ScriptRootPathHref *string `json:"script_root_path_href,omitempty"` + SecretsFileHref *string `json:"secrets_file_href,omitempty"` + TestData *string `json:"test_data,omitempty"` + TestDataHref *string `json:"test_data_href,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsalwaysreadyconfig.go b/resource-manager/web/2023-12-01/webapps/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..11dd43125f8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *float64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsdeployment.go b/resource-manager/web/2023-12-01/webapps/model_functionsdeployment.go new file mode 100644 index 00000000000..fa7c6e12a33 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorage.go b/resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..7a81b1b5af2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *StorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..087a9f1559f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsecrets.go b/resource-manager/web/2023-12-01/webapps/model_functionsecrets.go new file mode 100644 index 00000000000..daa46718fb3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsecrets.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionSecrets struct { + Key *string `json:"key,omitempty"` + TriggerUrl *string `json:"trigger_url,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsruntime.go b/resource-manager/web/2023-12-01/webapps/model_functionsruntime.go new file mode 100644 index 00000000000..025981cf91c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsruntime.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrency.go b/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..f99d51751c0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *float64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *float64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..070def9b6d2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..905bddaa70e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *float64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_github.go b/resource-manager/web/2023-12-01/webapps/model_github.go new file mode 100644 index 00000000000..0baa912b7f4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_github.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHub struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_githubactioncodeconfiguration.go b/resource-manager/web/2023-12-01/webapps/model_githubactioncodeconfiguration.go new file mode 100644 index 00000000000..96e13fda517 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_githubactioncodeconfiguration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionCodeConfiguration struct { + RuntimeStack *string `json:"runtimeStack,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_githubactionconfiguration.go b/resource-manager/web/2023-12-01/webapps/model_githubactionconfiguration.go new file mode 100644 index 00000000000..3e0089953d8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_githubactionconfiguration.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionConfiguration struct { + CodeConfiguration *GitHubActionCodeConfiguration `json:"codeConfiguration,omitempty"` + ContainerConfiguration *GitHubActionContainerConfiguration `json:"containerConfiguration,omitempty"` + GenerateWorkflowFile *bool `json:"generateWorkflowFile,omitempty"` + IsLinux *bool `json:"isLinux,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_githubactioncontainerconfiguration.go b/resource-manager/web/2023-12-01/webapps/model_githubactioncontainerconfiguration.go new file mode 100644 index 00000000000..0eb95a29ffb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_githubactioncontainerconfiguration.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionContainerConfiguration struct { + ImageName *string `json:"imageName,omitempty"` + Password *string `json:"password,omitempty"` + ServerUrl *string `json:"serverUrl,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_globalvalidation.go b/resource-manager/web/2023-12-01/webapps/model_globalvalidation.go new file mode 100644 index 00000000000..e3f6446954e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_globalvalidation.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalValidation struct { + ExcludedPaths *[]string `json:"excludedPaths,omitempty"` + RedirectToProvider *string `json:"redirectToProvider,omitempty"` + RequireAuthentication *bool `json:"requireAuthentication,omitempty"` + UnauthenticatedClientAction *UnauthenticatedClientActionV2 `json:"unauthenticatedClientAction,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_google.go b/resource-manager/web/2023-12-01/webapps/model_google.go new file mode 100644 index 00000000000..739f5aba70b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_google.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Google struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` + Validation *AllowedAudiencesValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_handlermapping.go b/resource-manager/web/2023-12-01/webapps/model_handlermapping.go new file mode 100644 index 00000000000..b5593f88002 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_handlermapping.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_hostingenvironmentprofile.go b/resource-manager/web/2023-12-01/webapps/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..e75ca71ee32 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_hostkeys.go b/resource-manager/web/2023-12-01/webapps/model_hostkeys.go new file mode 100644 index 00000000000..af8cb685979 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_hostkeys.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostKeys struct { + FunctionKeys *map[string]string `json:"functionKeys,omitempty"` + MasterKey *string `json:"masterKey,omitempty"` + SystemKeys *map[string]string `json:"systemKeys,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_hostnamebinding.go b/resource-manager/web/2023-12-01/webapps/model_hostnamebinding.go new file mode 100644 index 00000000000..4759b208afa --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_hostnamebinding.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameBinding struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HostNameBindingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_hostnamebindingproperties.go b/resource-manager/web/2023-12-01/webapps/model_hostnamebindingproperties.go new file mode 100644 index 00000000000..89d397ba5fa --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_hostnamebindingproperties.go @@ -0,0 +1,16 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameBindingProperties struct { + AzureResourceName *string `json:"azureResourceName,omitempty"` + AzureResourceType *AzureResourceType `json:"azureResourceType,omitempty"` + CustomHostNameDnsRecordType *CustomHostNameDnsRecordType `json:"customHostNameDnsRecordType,omitempty"` + DomainId *string `json:"domainId,omitempty"` + HostNameType *HostNameType `json:"hostNameType,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_hostnamesslstate.go b/resource-manager/web/2023-12-01/webapps/model_hostnamesslstate.go new file mode 100644 index 00000000000..a330c5447ea --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_httplogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_httplogsconfig.go new file mode 100644 index 00000000000..006cccdc08f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_httplogsconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPLogsConfig struct { + AzureBlobStorage *AzureBlobStorageHTTPLogsConfig `json:"azureBlobStorage,omitempty"` + FileSystem *FileSystemHTTPLogsConfig `json:"fileSystem,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_httpsettings.go b/resource-manager/web/2023-12-01/webapps/model_httpsettings.go new file mode 100644 index 00000000000..50a72c92e61 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_httpsettings.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettings struct { + ForwardProxy *ForwardProxy `json:"forwardProxy,omitempty"` + RequireHTTPS *bool `json:"requireHttps,omitempty"` + Routes *HTTPSettingsRoutes `json:"routes,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_httpsettingsroutes.go b/resource-manager/web/2023-12-01/webapps/model_httpsettingsroutes.go new file mode 100644 index 00000000000..deb06f51434 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_httpsettingsroutes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettingsRoutes struct { + ApiPrefix *string `json:"apiPrefix,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_hybridconnection.go b/resource-manager/web/2023-12-01/webapps/model_hybridconnection.go new file mode 100644 index 00000000000..57e4841bb22 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_hybridconnection.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_hybridconnectionproperties.go b/resource-manager/web/2023-12-01/webapps/model_hybridconnectionproperties.go new file mode 100644 index 00000000000..82c9d19bbb9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_hybridconnectionproperties.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionProperties struct { + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + RelayArmUri *string `json:"relayArmUri,omitempty"` + RelayName *string `json:"relayName,omitempty"` + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + ServiceBusSuffix *string `json:"serviceBusSuffix,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_identifier.go b/resource-manager/web/2023-12-01/webapps/model_identifier.go new file mode 100644 index 00000000000..134faaa6890 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_identifier.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Identifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_identifierproperties.go b/resource-manager/web/2023-12-01/webapps/model_identifierproperties.go new file mode 100644 index 00000000000..3826ff38a2e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_identifierproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentifierProperties struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_identityproviders.go b/resource-manager/web/2023-12-01/webapps/model_identityproviders.go new file mode 100644 index 00000000000..383fb8243f3 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_identityproviders.go @@ -0,0 +1,16 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviders struct { + Apple *Apple `json:"apple,omitempty"` + AzureActiveDirectory *AzureActiveDirectory `json:"azureActiveDirectory,omitempty"` + AzureStaticWebApps *AzureStaticWebApps `json:"azureStaticWebApps,omitempty"` + CustomOpenIdConnectProviders *map[string]CustomOpenIdConnectProvider `json:"customOpenIdConnectProviders,omitempty"` + Facebook *Facebook `json:"facebook,omitempty"` + GitHub *GitHub `json:"gitHub,omitempty"` + Google *Google `json:"google,omitempty"` + LegacyMicrosoftAccount *LegacyMicrosoftAccount `json:"legacyMicrosoftAccount,omitempty"` + Twitter *Twitter `json:"twitter,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_ipsecurityrestriction.go b/resource-manager/web/2023-12-01/webapps/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..2d96d9b6520 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_jwtclaimchecks.go b/resource-manager/web/2023-12-01/webapps/model_jwtclaimchecks.go new file mode 100644 index 00000000000..be04286a8e9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_jwtclaimchecks.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JwtClaimChecks struct { + AllowedClientApplications *[]string `json:"allowedClientApplications,omitempty"` + AllowedGroups *[]string `json:"allowedGroups,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_keyinfo.go b/resource-manager/web/2023-12-01/webapps/model_keyinfo.go new file mode 100644 index 00000000000..5463d9e53ce --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_keyinfo.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyInfo struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_legacymicrosoftaccount.go b/resource-manager/web/2023-12-01/webapps/model_legacymicrosoftaccount.go new file mode 100644 index 00000000000..77b7761115c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_legacymicrosoftaccount.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LegacyMicrosoftAccount struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` + Validation *AllowedAudiencesValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_localizablestring.go b/resource-manager/web/2023-12-01/webapps/model_localizablestring.go new file mode 100644 index 00000000000..1fac79f7d9f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_localizablestring.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_login.go b/resource-manager/web/2023-12-01/webapps/model_login.go new file mode 100644 index 00000000000..a8fee3b25d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_login.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Login struct { + AllowedExternalRedirectUrls *[]string `json:"allowedExternalRedirectUrls,omitempty"` + CookieExpiration *CookieExpiration `json:"cookieExpiration,omitempty"` + Nonce *Nonce `json:"nonce,omitempty"` + PreserveUrlFragmentsForLogins *bool `json:"preserveUrlFragmentsForLogins,omitempty"` + Routes *LoginRoutes `json:"routes,omitempty"` + TokenStore *TokenStore `json:"tokenStore,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_loginroutes.go b/resource-manager/web/2023-12-01/webapps/model_loginroutes.go new file mode 100644 index 00000000000..8009af99b43 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_loginroutes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginRoutes struct { + LogoutEndpoint *string `json:"logoutEndpoint,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_loginscopes.go b/resource-manager/web/2023-12-01/webapps/model_loginscopes.go new file mode 100644 index 00000000000..4b1160d5562 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_loginscopes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginScopes struct { + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_migratemysqlrequest.go b/resource-manager/web/2023-12-01/webapps/model_migratemysqlrequest.go new file mode 100644 index 00000000000..7661e8391ae --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_migratemysqlrequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrateMySqlRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_migratemysqlrequestproperties.go b/resource-manager/web/2023-12-01/webapps/model_migratemysqlrequestproperties.go new file mode 100644 index 00000000000..0a9492d11bb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_migratemysqlrequestproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlRequestProperties struct { + ConnectionString string `json:"connectionString"` + MigrationType MySqlMigrationType `json:"migrationType"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_migratemysqlstatus.go b/resource-manager/web/2023-12-01/webapps/model_migratemysqlstatus.go new file mode 100644 index 00000000000..93e2c1806cd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_migratemysqlstatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrateMySqlStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_migratemysqlstatusproperties.go b/resource-manager/web/2023-12-01/webapps/model_migratemysqlstatusproperties.go new file mode 100644 index 00000000000..bb707fc1768 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_migratemysqlstatusproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlStatusProperties struct { + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + MigrationOperationStatus *OperationStatus `json:"migrationOperationStatus,omitempty"` + OperationId *string `json:"operationId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeploy.go b/resource-manager/web/2023-12-01/webapps/model_msdeploy.go new file mode 100644 index 00000000000..27ad333e0e5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeploy.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeploy struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeploycore.go b/resource-manager/web/2023-12-01/webapps/model_msdeploycore.go new file mode 100644 index 00000000000..e87d9f960ad --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeploycore.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployCore struct { + AppOffline *bool `json:"appOffline,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + DbType *string `json:"dbType,omitempty"` + PackageUri *string `json:"packageUri,omitempty"` + SetParameters *map[string]string `json:"setParameters,omitempty"` + SetParametersXmlFileUri *string `json:"setParametersXmlFileUri,omitempty"` + SkipAppData *bool `json:"skipAppData,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeploylog.go b/resource-manager/web/2023-12-01/webapps/model_msdeploylog.go new file mode 100644 index 00000000000..344db502e39 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeploylog.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployLog struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployLogProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeploylogentry.go b/resource-manager/web/2023-12-01/webapps/model_msdeploylogentry.go new file mode 100644 index 00000000000..b300f240305 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeploylogentry.go @@ -0,0 +1,28 @@ +package webapps + +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 MSDeployLogEntry struct { + Message *string `json:"message,omitempty"` + Time *string `json:"time,omitempty"` + Type *MSDeployLogEntryType `json:"type,omitempty"` +} + +func (o *MSDeployLogEntry) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployLogEntry) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeploylogproperties.go b/resource-manager/web/2023-12-01/webapps/model_msdeploylogproperties.go new file mode 100644 index 00000000000..4d30fd74a57 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeploylogproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployLogProperties struct { + Entries *[]MSDeployLogEntry `json:"entries,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeployproperties.go b/resource-manager/web/2023-12-01/webapps/model_msdeployproperties.go new file mode 100644 index 00000000000..2fdb5e36d60 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeployproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployProperties struct { + AddOnPackages *[]MSDeployCore `json:"addOnPackages,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeploystatus.go b/resource-manager/web/2023-12-01/webapps/model_msdeploystatus.go new file mode 100644 index 00000000000..9f782217369 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeploystatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_msdeploystatusproperties.go b/resource-manager/web/2023-12-01/webapps/model_msdeploystatusproperties.go new file mode 100644 index 00000000000..739caae3f32 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_msdeploystatusproperties.go @@ -0,0 +1,42 @@ +package webapps + +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 MSDeployStatusProperties struct { + Complete *bool `json:"complete,omitempty"` + Deployer *string `json:"deployer,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ProvisioningState *MSDeployProvisioningState `json:"provisioningState,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *MSDeployStatusProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployStatusProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MSDeployStatusProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployStatusProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_namevaluepair.go b/resource-manager/web/2023-12-01/webapps/model_namevaluepair.go new file mode 100644 index 00000000000..db12fa3a313 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_namevaluepair.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_networkfeatures.go b/resource-manager/web/2023-12-01/webapps/model_networkfeatures.go new file mode 100644 index 00000000000..34cbbf7f121 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_networkfeatures.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkFeatures struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkFeaturesProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_networkfeaturesproperties.go b/resource-manager/web/2023-12-01/webapps/model_networkfeaturesproperties.go new file mode 100644 index 00000000000..a51a0260488 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_networkfeaturesproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkFeaturesProperties struct { + HybridConnections *[]RelayServiceConnectionEntity `json:"hybridConnections,omitempty"` + HybridConnectionsV2 *[]HybridConnection `json:"hybridConnectionsV2,omitempty"` + VirtualNetworkConnection *VnetInfo `json:"virtualNetworkConnection,omitempty"` + VirtualNetworkName *string `json:"virtualNetworkName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_networktrace.go b/resource-manager/web/2023-12-01/webapps/model_networktrace.go new file mode 100644 index 00000000000..4c22aec67e9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_networktrace.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkTrace struct { + Message *string `json:"message,omitempty"` + Path *string `json:"path,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_nonce.go b/resource-manager/web/2023-12-01/webapps/model_nonce.go new file mode 100644 index 00000000000..ae90e0008f5 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_nonce.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Nonce struct { + NonceExpirationInterval *string `json:"nonceExpirationInterval,omitempty"` + ValidateNonce *bool `json:"validateNonce,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_openidconnectclientcredential.go b/resource-manager/web/2023-12-01/webapps/model_openidconnectclientcredential.go new file mode 100644 index 00000000000..11d3fe51886 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_openidconnectclientcredential.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectClientCredential struct { + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + Method *ClientCredentialMethod `json:"method,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_openidconnectconfig.go b/resource-manager/web/2023-12-01/webapps/model_openidconnectconfig.go new file mode 100644 index 00000000000..c76119be643 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_openidconnectconfig.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectConfig struct { + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + CertificationUri *string `json:"certificationUri,omitempty"` + Issuer *string `json:"issuer,omitempty"` + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` + WellKnownOpenIdConfiguration *string `json:"wellKnownOpenIdConfiguration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_openidconnectlogin.go b/resource-manager/web/2023-12-01/webapps/model_openidconnectlogin.go new file mode 100644 index 00000000000..e8a1c2ae8ed --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_openidconnectlogin.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectLogin struct { + NameClaimType *string `json:"nameClaimType,omitempty"` + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_openidconnectregistration.go b/resource-manager/web/2023-12-01/webapps/model_openidconnectregistration.go new file mode 100644 index 00000000000..faf47478e0c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_openidconnectregistration.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectRegistration struct { + ClientCredential *OpenIdConnectClientCredential `json:"clientCredential,omitempty"` + ClientId *string `json:"clientId,omitempty"` + OpenIdConnectConfiguration *OpenIdConnectConfig `json:"openIdConnectConfiguration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_operation.go b/resource-manager/web/2023-12-01/webapps/model_operation.go new file mode 100644 index 00000000000..19973cf1953 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_operation.go @@ -0,0 +1,57 @@ +package webapps + +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 Operation struct { + CreatedTime *string `json:"createdTime,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + GeoMasterOperationId *string `json:"geoMasterOperationId,omitempty"` + Id *string `json:"id,omitempty"` + ModifiedTime *string `json:"modifiedTime,omitempty"` + Name *string `json:"name,omitempty"` + Status *OperationStatus `json:"status,omitempty"` +} + +func (o *Operation) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *Operation) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *Operation) GetModifiedTimeAsTime() (*time.Time, error) { + if o.ModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_perfmonresponse.go b/resource-manager/web/2023-12-01/webapps/model_perfmonresponse.go new file mode 100644 index 00000000000..9b5ecb7207b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_perfmonresponse.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerfMonResponse struct { + Code *string `json:"code,omitempty"` + Data *PerfMonSet `json:"data,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_perfmonsample.go b/resource-manager/web/2023-12-01/webapps/model_perfmonsample.go new file mode 100644 index 00000000000..d431429707b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_perfmonsample.go @@ -0,0 +1,28 @@ +package webapps + +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 PerfMonSample struct { + InstanceName *string `json:"instanceName,omitempty"` + Time *string `json:"time,omitempty"` + Value *float64 `json:"value,omitempty"` +} + +func (o *PerfMonSample) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSample) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_perfmonset.go b/resource-manager/web/2023-12-01/webapps/model_perfmonset.go new file mode 100644 index 00000000000..3c4b44ec647 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_perfmonset.go @@ -0,0 +1,42 @@ +package webapps + +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 PerfMonSet struct { + EndTime *string `json:"endTime,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Values *[]PerfMonSample `json:"values,omitempty"` +} + +func (o *PerfMonSet) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSet) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PerfMonSet) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSet) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_premieraddon.go b/resource-manager/web/2023-12-01/webapps/model_premieraddon.go new file mode 100644 index 00000000000..7d64dfe405d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_premieraddon.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOn struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresource.go b/resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresource.go new file mode 100644 index 00000000000..6d715b148db --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresourceproperties.go b/resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresourceproperties.go new file mode 100644 index 00000000000..6a330db952e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_premieraddonpatchresourceproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnPatchResourceProperties struct { + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + Product *string `json:"product,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_premieraddonproperties.go b/resource-manager/web/2023-12-01/webapps/model_premieraddonproperties.go new file mode 100644 index 00000000000..1a0c2eeb3eb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_premieraddonproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnProperties struct { + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + Product *string `json:"product,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privateaccess.go b/resource-manager/web/2023-12-01/webapps/model_privateaccess.go new file mode 100644 index 00000000000..57bb75c3f6a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privateaccess.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccess struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateAccessProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privateaccessproperties.go b/resource-manager/web/2023-12-01/webapps/model_privateaccessproperties.go new file mode 100644 index 00000000000..654c66fb229 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privateaccessproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessProperties struct { + Enabled *bool `json:"enabled,omitempty"` + VirtualNetworks *[]PrivateAccessVirtualNetwork `json:"virtualNetworks,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privateaccesssubnet.go b/resource-manager/web/2023-12-01/webapps/model_privateaccesssubnet.go new file mode 100644 index 00000000000..c0308f0a6b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privateaccesssubnet.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessSubnet struct { + Key *int64 `json:"key,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privateaccessvirtualnetwork.go b/resource-manager/web/2023-12-01/webapps/model_privateaccessvirtualnetwork.go new file mode 100644 index 00000000000..1aa31d5386c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privateaccessvirtualnetwork.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessVirtualNetwork struct { + Key *int64 `json:"key,omitempty"` + Name *string `json:"name,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + Subnets *[]PrivateAccessSubnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privatelinkconnectionstate.go b/resource-manager/web/2023-12-01/webapps/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..0cb41b46def --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privatelinkresource.go b/resource-manager/web/2023-12-01/webapps/model_privatelinkresource.go new file mode 100644 index 00000000000..8ad526f8d22 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privatelinkresourceproperties.go b/resource-manager/web/2023-12-01/webapps/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..681e7763d0b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_privatelinkresourceswrapper.go b/resource-manager/web/2023-12-01/webapps/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..44ee0fa08c8 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_processinfo.go b/resource-manager/web/2023-12-01/webapps/model_processinfo.go new file mode 100644 index 00000000000..fc0db143ae2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_processinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_processinfoproperties.go b/resource-manager/web/2023-12-01/webapps/model_processinfoproperties.go new file mode 100644 index 00000000000..705da9f398d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_processinfoproperties.go @@ -0,0 +1,73 @@ +package webapps + +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 ProcessInfoProperties struct { + Children *[]string `json:"children,omitempty"` + CommandLine *string `json:"command_line,omitempty"` + DeploymentName *string `json:"deployment_name,omitempty"` + Description *string `json:"description,omitempty"` + EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` + FileName *string `json:"file_name,omitempty"` + HandleCount *int64 `json:"handle_count,omitempty"` + Href *string `json:"href,omitempty"` + Identifier *int64 `json:"identifier,omitempty"` + IisProfileTimeoutInSeconds *float64 `json:"iis_profile_timeout_in_seconds,omitempty"` + IsIisProfileRunning *bool `json:"is_iis_profile_running,omitempty"` + IsProfileRunning *bool `json:"is_profile_running,omitempty"` + IsScmSite *bool `json:"is_scm_site,omitempty"` + IsWebjob *bool `json:"is_webjob,omitempty"` + Minidump *string `json:"minidump,omitempty"` + ModuleCount *int64 `json:"module_count,omitempty"` + Modules *[]ProcessModuleInfo `json:"modules,omitempty"` + NonPagedSystemMemory *int64 `json:"non_paged_system_memory,omitempty"` + OpenFileHandles *[]string `json:"open_file_handles,omitempty"` + PagedMemory *int64 `json:"paged_memory,omitempty"` + PagedSystemMemory *int64 `json:"paged_system_memory,omitempty"` + Parent *string `json:"parent,omitempty"` + PeakPagedMemory *int64 `json:"peak_paged_memory,omitempty"` + PeakVirtualMemory *int64 `json:"peak_virtual_memory,omitempty"` + PeakWorkingSet *int64 `json:"peak_working_set,omitempty"` + PrivateMemory *int64 `json:"private_memory,omitempty"` + PrivilegedCpuTime *string `json:"privileged_cpu_time,omitempty"` + StartTime *string `json:"start_time,omitempty"` + ThreadCount *int64 `json:"thread_count,omitempty"` + Threads *[]ProcessThreadInfo `json:"threads,omitempty"` + TimeStamp *string `json:"time_stamp,omitempty"` + TotalCpuTime *string `json:"total_cpu_time,omitempty"` + UserCpuTime *string `json:"user_cpu_time,omitempty"` + UserName *string `json:"user_name,omitempty"` + VirtualMemory *int64 `json:"virtual_memory,omitempty"` + WorkingSet *int64 `json:"working_set,omitempty"` +} + +func (o *ProcessInfoProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessInfoProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +func (o *ProcessInfoProperties) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessInfoProperties) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_processmoduleinfo.go b/resource-manager/web/2023-12-01/webapps/model_processmoduleinfo.go new file mode 100644 index 00000000000..9f12d6c8bab --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_processmoduleinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessModuleInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessModuleInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_processmoduleinfoproperties.go b/resource-manager/web/2023-12-01/webapps/model_processmoduleinfoproperties.go new file mode 100644 index 00000000000..170aa09c221 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_processmoduleinfoproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessModuleInfoProperties struct { + BaseAddress *string `json:"base_address,omitempty"` + FileDescription *string `json:"file_description,omitempty"` + FileName *string `json:"file_name,omitempty"` + FilePath *string `json:"file_path,omitempty"` + FileVersion *string `json:"file_version,omitempty"` + Href *string `json:"href,omitempty"` + IsDebug *bool `json:"is_debug,omitempty"` + Language *string `json:"language,omitempty"` + ModuleMemorySize *int64 `json:"module_memory_size,omitempty"` + Product *string `json:"product,omitempty"` + ProductVersion *string `json:"product_version,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_processthreadinfo.go b/resource-manager/web/2023-12-01/webapps/model_processthreadinfo.go new file mode 100644 index 00000000000..f11e4d7370c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_processthreadinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessThreadInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessThreadInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_processthreadinfoproperties.go b/resource-manager/web/2023-12-01/webapps/model_processthreadinfoproperties.go new file mode 100644 index 00000000000..e115c1477b6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_processthreadinfoproperties.go @@ -0,0 +1,37 @@ +package webapps + +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 ProcessThreadInfoProperties struct { + BasePriority *int64 `json:"base_priority,omitempty"` + CurrentPriority *int64 `json:"current_priority,omitempty"` + Href *string `json:"href,omitempty"` + Identifier *int64 `json:"identifier,omitempty"` + PriorityLevel *string `json:"priority_level,omitempty"` + Process *string `json:"process,omitempty"` + StartAddress *string `json:"start_address,omitempty"` + StartTime *string `json:"start_time,omitempty"` + State *string `json:"state,omitempty"` + TotalProcessorTime *string `json:"total_processor_time,omitempty"` + UserProcessorTime *string `json:"user_processor_time,omitempty"` + WaitReason *string `json:"wait_reason,omitempty"` +} + +func (o *ProcessThreadInfoProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessThreadInfoProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_publiccertificate.go b/resource-manager/web/2023-12-01/webapps/model_publiccertificate.go new file mode 100644 index 00000000000..41d2238cf35 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_publiccertificate.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicCertificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicCertificateProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_publiccertificateproperties.go b/resource-manager/web/2023-12-01/webapps/model_publiccertificateproperties.go new file mode 100644 index 00000000000..291d9a59a0f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_publiccertificateproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicCertificateProperties struct { + Blob *string `json:"blob,omitempty"` + PublicCertificateLocation *PublicCertificateLocation `json:"publicCertificateLocation,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_pushsettings.go b/resource-manager/web/2023-12-01/webapps/model_pushsettings.go new file mode 100644 index 00000000000..c233a60ea49 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_pushsettings.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_pushsettingsproperties.go b/resource-manager/web/2023-12-01/webapps/model_pushsettingsproperties.go new file mode 100644 index 00000000000..bdf39a78d98 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_rampuprule.go b/resource-manager/web/2023-12-01/webapps/model_rampuprule.go new file mode 100644 index 00000000000..a99e19c5085 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_rampuprule.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackUrl *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentity.go b/resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentity.go new file mode 100644 index 00000000000..a2bfbf4739e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentity.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelayServiceConnectionEntity struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RelayServiceConnectionEntityProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentityproperties.go b/resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentityproperties.go new file mode 100644 index 00000000000..608b034c0df --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_relayserviceconnectionentityproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelayServiceConnectionEntityProperties struct { + BiztalkUri *string `json:"biztalkUri,omitempty"` + EntityConnectionString *string `json:"entityConnectionString,omitempty"` + EntityName *string `json:"entityName,omitempty"` + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + ResourceConnectionString *string `json:"resourceConnectionString,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..2657ec83161 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..82a747ca53b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_requestsbasedtrigger.go b/resource-manager/web/2023-12-01/webapps/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..f8d9ec672d0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_resourceconfig.go b/resource-manager/web/2023-12-01/webapps/model_resourceconfig.go new file mode 100644 index 00000000000..14a70233fe9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_resourceconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_restorerequest.go b/resource-manager/web/2023-12-01/webapps/model_restorerequest.go new file mode 100644 index 00000000000..c56dde6c785 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_restorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_restorerequestproperties.go b/resource-manager/web/2023-12-01/webapps/model_restorerequestproperties.go new file mode 100644 index 00000000000..d352f67f61b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_restorerequestproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequestProperties struct { + AdjustConnectionStrings *bool `json:"adjustConnectionStrings,omitempty"` + AppServicePlan *string `json:"appServicePlan,omitempty"` + BlobName *string `json:"blobName,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + IgnoreConflictingHostNames *bool `json:"ignoreConflictingHostNames,omitempty"` + IgnoreDatabases *bool `json:"ignoreDatabases,omitempty"` + OperationType *BackupRestoreOperationType `json:"operationType,omitempty"` + Overwrite bool `json:"overwrite"` + SiteName *string `json:"siteName,omitempty"` + StorageAccountUrl string `json:"storageAccountUrl"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_site.go b/resource-manager/web/2023-12-01/webapps/model_site.go new file mode 100644 index 00000000000..48c36824946 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_site.go @@ -0,0 +1,20 @@ +package webapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteauthsettings.go b/resource-manager/web/2023-12-01/webapps/model_siteauthsettings.go new file mode 100644 index 00000000000..b1a8431fdcc --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteauthsettings.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteAuthSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsproperties.go b/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsproperties.go new file mode 100644 index 00000000000..46d05a77881 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsproperties.go @@ -0,0 +1,45 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsProperties struct { + AadClaimsAuthorization *string `json:"aadClaimsAuthorization,omitempty"` + AdditionalLoginParams *[]string `json:"additionalLoginParams,omitempty"` + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` + AllowedExternalRedirectUrls *[]string `json:"allowedExternalRedirectUrls,omitempty"` + AuthFilePath *string `json:"authFilePath,omitempty"` + ClientId *string `json:"clientId,omitempty"` + ClientSecret *string `json:"clientSecret,omitempty"` + ClientSecretCertificateThumbprint *string `json:"clientSecretCertificateThumbprint,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + ConfigVersion *string `json:"configVersion,omitempty"` + DefaultProvider *BuiltInAuthenticationProvider `json:"defaultProvider,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FacebookAppId *string `json:"facebookAppId,omitempty"` + FacebookAppSecret *string `json:"facebookAppSecret,omitempty"` + FacebookAppSecretSettingName *string `json:"facebookAppSecretSettingName,omitempty"` + FacebookOAuthScopes *[]string `json:"facebookOAuthScopes,omitempty"` + GitHubClientId *string `json:"gitHubClientId,omitempty"` + GitHubClientSecret *string `json:"gitHubClientSecret,omitempty"` + GitHubClientSecretSettingName *string `json:"gitHubClientSecretSettingName,omitempty"` + GitHubOAuthScopes *[]string `json:"gitHubOAuthScopes,omitempty"` + GoogleClientId *string `json:"googleClientId,omitempty"` + GoogleClientSecret *string `json:"googleClientSecret,omitempty"` + GoogleClientSecretSettingName *string `json:"googleClientSecretSettingName,omitempty"` + GoogleOAuthScopes *[]string `json:"googleOAuthScopes,omitempty"` + IsAuthFromFile *string `json:"isAuthFromFile,omitempty"` + Issuer *string `json:"issuer,omitempty"` + MicrosoftAccountClientId *string `json:"microsoftAccountClientId,omitempty"` + MicrosoftAccountClientSecret *string `json:"microsoftAccountClientSecret,omitempty"` + MicrosoftAccountClientSecretSettingName *string `json:"microsoftAccountClientSecretSettingName,omitempty"` + MicrosoftAccountOAuthScopes *[]string `json:"microsoftAccountOAuthScopes,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + TokenRefreshExtensionHours *float64 `json:"tokenRefreshExtensionHours,omitempty"` + TokenStoreEnabled *bool `json:"tokenStoreEnabled,omitempty"` + TwitterConsumerKey *string `json:"twitterConsumerKey,omitempty"` + TwitterConsumerSecret *string `json:"twitterConsumerSecret,omitempty"` + TwitterConsumerSecretSettingName *string `json:"twitterConsumerSecretSettingName,omitempty"` + UnauthenticatedClientAction *UnauthenticatedClientAction `json:"unauthenticatedClientAction,omitempty"` + ValidateIssuer *bool `json:"validateIssuer,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2.go b/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2.go new file mode 100644 index 00000000000..ee79ab12848 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsV2 struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteAuthSettingsV2Properties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2properties.go b/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2properties.go new file mode 100644 index 00000000000..9fe4cea0565 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteauthsettingsv2properties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsV2Properties struct { + GlobalValidation *GlobalValidation `json:"globalValidation,omitempty"` + HTTPSettings *HTTPSettings `json:"httpSettings,omitempty"` + IdentityProviders *IdentityProviders `json:"identityProviders,omitempty"` + Login *Login `json:"login,omitempty"` + Platform *AuthPlatform `json:"platform,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitecloneability.go b/resource-manager/web/2023-12-01/webapps/model_sitecloneability.go new file mode 100644 index 00000000000..ff7a0079247 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitecloneability.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteCloneability struct { + BlockingCharacteristics *[]SiteCloneabilityCriterion `json:"blockingCharacteristics,omitempty"` + BlockingFeatures *[]SiteCloneabilityCriterion `json:"blockingFeatures,omitempty"` + Result *CloneAbilityResult `json:"result,omitempty"` + UnsupportedFeatures *[]SiteCloneabilityCriterion `json:"unsupportedFeatures,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitecloneabilitycriterion.go b/resource-manager/web/2023-12-01/webapps/model_sitecloneabilitycriterion.go new file mode 100644 index 00000000000..89a4c57de83 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitecloneabilitycriterion.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteCloneabilityCriterion struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteconfig.go b/resource-manager/web/2023-12-01/webapps/model_siteconfig.go new file mode 100644 index 00000000000..faaa3834f5e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteconfig.go @@ -0,0 +1,97 @@ +package webapps + +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 SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteconfigresource.go b/resource-manager/web/2023-12-01/webapps/model_siteconfigresource.go new file mode 100644 index 00000000000..46d60ffe0b9 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteconfigresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteConfig `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfo.go b/resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfo.go new file mode 100644 index 00000000000..2fea88a6a47 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigurationSnapshotInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteConfigurationSnapshotInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfoproperties.go b/resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfoproperties.go new file mode 100644 index 00000000000..8907cc179db --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteconfigurationsnapshotinfoproperties.go @@ -0,0 +1,27 @@ +package webapps + +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 SiteConfigurationSnapshotInfoProperties struct { + SnapshotId *int64 `json:"snapshotId,omitempty"` + Time *string `json:"time,omitempty"` +} + +func (o *SiteConfigurationSnapshotInfoProperties) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfigurationSnapshotInfoProperties) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitecontainer.go b/resource-manager/web/2023-12-01/webapps/model_sitecontainer.go new file mode 100644 index 00000000000..ab2c105b488 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitecontainer.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteContainer struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteContainerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitecontainerproperties.go b/resource-manager/web/2023-12-01/webapps/model_sitecontainerproperties.go new file mode 100644 index 00000000000..ea67ce1a7e2 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitecontainerproperties.go @@ -0,0 +1,49 @@ +package webapps + +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 SiteContainerProperties struct { + AuthType *AuthType `json:"authType,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + EnvironmentVariables *[]EnvironmentVariable `json:"environmentVariables,omitempty"` + Image string `json:"image"` + IsMain bool `json:"isMain"` + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + PasswordSecret *string `json:"passwordSecret,omitempty"` + StartUpCommand *string `json:"startUpCommand,omitempty"` + TargetPort *string `json:"targetPort,omitempty"` + UserManagedIdentityClientId *string `json:"userManagedIdentityClientId,omitempty"` + UserName *string `json:"userName,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} + +func (o *SiteContainerProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteContainerProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *SiteContainerProperties) GetLastModifiedTimeAsTime() (*time.Time, error) { + if o.LastModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteContainerProperties) SetLastModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitednsconfig.go b/resource-manager/web/2023-12-01/webapps/model_sitednsconfig.go new file mode 100644 index 00000000000..e378e356c3f --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteextensioninfo.go b/resource-manager/web/2023-12-01/webapps/model_siteextensioninfo.go new file mode 100644 index 00000000000..918563b2f1d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteextensioninfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteExtensionInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteExtensionInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteextensioninfoproperties.go b/resource-manager/web/2023-12-01/webapps/model_siteextensioninfoproperties.go new file mode 100644 index 00000000000..4a10138d54c --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteextensioninfoproperties.go @@ -0,0 +1,57 @@ +package webapps + +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 SiteExtensionInfoProperties struct { + Authors *[]string `json:"authors,omitempty"` + Comment *string `json:"comment,omitempty"` + Description *string `json:"description,omitempty"` + DownloadCount *int64 `json:"download_count,omitempty"` + ExtensionId *string `json:"extension_id,omitempty"` + ExtensionType *SiteExtensionType `json:"extension_type,omitempty"` + ExtensionUrl *string `json:"extension_url,omitempty"` + FeedUrl *string `json:"feed_url,omitempty"` + IconUrl *string `json:"icon_url,omitempty"` + InstalledDateTime *string `json:"installed_date_time,omitempty"` + InstallerCommandLineParams *string `json:"installer_command_line_params,omitempty"` + LicenseUrl *string `json:"license_url,omitempty"` + LocalIsLatestVersion *bool `json:"local_is_latest_version,omitempty"` + LocalPath *string `json:"local_path,omitempty"` + ProjectUrl *string `json:"project_url,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublishedDateTime *string `json:"published_date_time,omitempty"` + Summary *string `json:"summary,omitempty"` + Title *string `json:"title,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *SiteExtensionInfoProperties) GetInstalledDateTimeAsTime() (*time.Time, error) { + if o.InstalledDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.InstalledDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteExtensionInfoProperties) SetInstalledDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.InstalledDateTime = &formatted +} + +func (o *SiteExtensionInfoProperties) GetPublishedDateTimeAsTime() (*time.Time, error) { + if o.PublishedDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PublishedDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteExtensionInfoProperties) SetPublishedDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PublishedDateTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitelimits.go b/resource-manager/web/2023-12-01/webapps/model_sitelimits.go new file mode 100644 index 00000000000..271933cbb7d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitelimits.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitelogsconfig.go b/resource-manager/web/2023-12-01/webapps/model_sitelogsconfig.go new file mode 100644 index 00000000000..91bb4451cde --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitelogsconfig.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLogsConfig struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteLogsConfigProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitelogsconfigproperties.go b/resource-manager/web/2023-12-01/webapps/model_sitelogsconfigproperties.go new file mode 100644 index 00000000000..1b853da7ad6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitelogsconfigproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLogsConfigProperties struct { + ApplicationLogs *ApplicationLogsConfig `json:"applicationLogs,omitempty"` + DetailedErrorMessages *EnabledConfig `json:"detailedErrorMessages,omitempty"` + FailedRequestsTracing *EnabledConfig `json:"failedRequestsTracing,omitempty"` + HTTPLogs *HTTPLogsConfig `json:"httpLogs,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitemachinekey.go b/resource-manager/web/2023-12-01/webapps/model_sitemachinekey.go new file mode 100644 index 00000000000..c6d65bc957d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitepatchresource.go b/resource-manager/web/2023-12-01/webapps/model_sitepatchresource.go new file mode 100644 index 00000000000..ca1829f5c66 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitepatchresource.go @@ -0,0 +1,17 @@ +package webapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePatchResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SitePatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitepatchresourceproperties.go b/resource-manager/web/2023-12-01/webapps/model_sitepatchresourceproperties.go new file mode 100644 index 00000000000..77ba3270f28 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitepatchresourceproperties.go @@ -0,0 +1,79 @@ +package webapps + +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 SitePatchResourceProperties struct { + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` +} + +func (o *SitePatchResourceProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SitePatchResourceProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SitePatchResourceProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SitePatchResourceProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflag.go b/resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflag.go new file mode 100644 index 00000000000..fd18d5d39f6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflag.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePhpErrorLogFlag struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SitePhpErrorLogFlagProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflagproperties.go b/resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflagproperties.go new file mode 100644 index 00000000000..4a9465a064b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitephperrorlogflagproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePhpErrorLogFlagProperties struct { + LocalLogErrors *string `json:"localLogErrors,omitempty"` + LocalLogErrorsMaxLength *string `json:"localLogErrorsMaxLength,omitempty"` + MasterLogErrors *string `json:"masterLogErrors,omitempty"` + MasterLogErrorsMaxLength *string `json:"masterLogErrorsMaxLength,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_siteproperties.go b/resource-manager/web/2023-12-01/webapps/model_siteproperties.go new file mode 100644 index 00000000000..dcb3e020b67 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_siteproperties.go @@ -0,0 +1,89 @@ +package webapps + +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 SiteProperties struct { + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + VnetBackupRestoreEnabled *bool `json:"vnetBackupRestoreEnabled,omitempty"` + VnetContentShareEnabled *bool `json:"vnetContentShareEnabled,omitempty"` + VnetImagePullEnabled *bool `json:"vnetImagePullEnabled,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitesourcecontrol.go b/resource-manager/web/2023-12-01/webapps/model_sitesourcecontrol.go new file mode 100644 index 00000000000..8b8a43b83b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitesourcecontrol.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSourceControl struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteSourceControlProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_sitesourcecontrolproperties.go b/resource-manager/web/2023-12-01/webapps/model_sitesourcecontrolproperties.go new file mode 100644 index 00000000000..f19c33a2a34 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_sitesourcecontrolproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSourceControlProperties struct { + Branch *string `json:"branch,omitempty"` + DeploymentRollbackEnabled *bool `json:"deploymentRollbackEnabled,omitempty"` + GitHubActionConfiguration *GitHubActionConfiguration `json:"gitHubActionConfiguration,omitempty"` + IsGitHubAction *bool `json:"isGitHubAction,omitempty"` + IsManualIntegration *bool `json:"isManualIntegration,omitempty"` + IsMercurial *bool `json:"isMercurial,omitempty"` + RepoUrl *string `json:"repoUrl,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_slotconfignames.go b/resource-manager/web/2023-12-01/webapps/model_slotconfignames.go new file mode 100644 index 00000000000..34cbe7ce354 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_slotconfignames.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotConfigNames struct { + AppSettingNames *[]string `json:"appSettingNames,omitempty"` + AzureStorageConfigNames *[]string `json:"azureStorageConfigNames,omitempty"` + ConnectionStringNames *[]string `json:"connectionStringNames,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_slotconfignamesresource.go b/resource-manager/web/2023-12-01/webapps/model_slotconfignamesresource.go new file mode 100644 index 00000000000..dea993a310d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_slotconfignamesresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotConfigNamesResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SlotConfigNames `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_slotdifference.go b/resource-manager/web/2023-12-01/webapps/model_slotdifference.go new file mode 100644 index 00000000000..433c86817c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_slotdifference.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotDifference struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SlotDifferenceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_slotdifferenceproperties.go b/resource-manager/web/2023-12-01/webapps/model_slotdifferenceproperties.go new file mode 100644 index 00000000000..79f90d274fa --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_slotdifferenceproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotDifferenceProperties struct { + Description *string `json:"description,omitempty"` + DiffRule *string `json:"diffRule,omitempty"` + Level *string `json:"level,omitempty"` + SettingName *string `json:"settingName,omitempty"` + SettingType *string `json:"settingType,omitempty"` + ValueInCurrentSlot *string `json:"valueInCurrentSlot,omitempty"` + ValueInTargetSlot *string `json:"valueInTargetSlot,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_slotswapstatus.go b/resource-manager/web/2023-12-01/webapps/model_slotswapstatus.go new file mode 100644 index 00000000000..c9eb5b7eeff --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package webapps + +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 SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_slowrequestsbasedtrigger.go b/resource-manager/web/2023-12-01/webapps/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..6d2bb3b5050 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_snapshot.go b/resource-manager/web/2023-12-01/webapps/model_snapshot.go new file mode 100644 index 00000000000..6a113202c94 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_snapshot.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snapshot struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_snapshotproperties.go b/resource-manager/web/2023-12-01/webapps/model_snapshotproperties.go new file mode 100644 index 00000000000..e6cf11407ff --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_snapshotproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotProperties struct { + Time *string `json:"time,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_snapshotrecoverysource.go b/resource-manager/web/2023-12-01/webapps/model_snapshotrecoverysource.go new file mode 100644 index 00000000000..5a9d31cacbb --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_snapshotrecoverysource.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRecoverySource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequest.go b/resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequest.go new file mode 100644 index 00000000000..f3b15067bd6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotRestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequestproperties.go b/resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequestproperties.go new file mode 100644 index 00000000000..43d7139eb35 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_snapshotrestorerequestproperties.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreRequestProperties struct { + IgnoreConflictingHostNames *bool `json:"ignoreConflictingHostNames,omitempty"` + Overwrite bool `json:"overwrite"` + RecoverConfiguration *bool `json:"recoverConfiguration,omitempty"` + RecoverySource *SnapshotRecoverySource `json:"recoverySource,omitempty"` + SnapshotTime *string `json:"snapshotTime,omitempty"` + UseDRSecondary *bool `json:"useDRSecondary,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_statuscodesbasedtrigger.go b/resource-manager/web/2023-12-01/webapps/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..38028980ea1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2023-12-01/webapps/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..399920aec5a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_storagemigrationoptions.go b/resource-manager/web/2023-12-01/webapps/model_storagemigrationoptions.go new file mode 100644 index 00000000000..45da1f0d070 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_storagemigrationoptions.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationOptions struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageMigrationOptionsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_storagemigrationoptionsproperties.go b/resource-manager/web/2023-12-01/webapps/model_storagemigrationoptionsproperties.go new file mode 100644 index 00000000000..102ddb713f6 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_storagemigrationoptionsproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationOptionsProperties struct { + AzurefilesConnectionString string `json:"azurefilesConnectionString"` + AzurefilesShare string `json:"azurefilesShare"` + BlockWriteAccessToSite *bool `json:"blockWriteAccessToSite,omitempty"` + SwitchSiteAfterMigration *bool `json:"switchSiteAfterMigration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_storagemigrationresponse.go b/resource-manager/web/2023-12-01/webapps/model_storagemigrationresponse.go new file mode 100644 index 00000000000..9422d63effd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_storagemigrationresponse.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageMigrationResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_storagemigrationresponseproperties.go b/resource-manager/web/2023-12-01/webapps/model_storagemigrationresponseproperties.go new file mode 100644 index 00000000000..780c084c664 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_storagemigrationresponseproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationResponseProperties struct { + OperationId *string `json:"operationId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_stringdictionary.go b/resource-manager/web/2023-12-01/webapps/model_stringdictionary.go new file mode 100644 index 00000000000..20fcaaa92b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_stringdictionary.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetwork.go b/resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetwork.go new file mode 100644 index 00000000000..db095809863 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetwork.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwiftVirtualNetwork struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SwiftVirtualNetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetworkproperties.go b/resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetworkproperties.go new file mode 100644 index 00000000000..8c1ca0faa38 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_swiftvirtualnetworkproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwiftVirtualNetworkProperties struct { + SubnetResourceId *string `json:"subnetResourceId,omitempty"` + SwiftSupported *bool `json:"swiftSupported,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_tokenstore.go b/resource-manager/web/2023-12-01/webapps/model_tokenstore.go new file mode 100644 index 00000000000..4668774ac25 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_tokenstore.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TokenStore struct { + AzureBlobStorage *BlobStorageTokenStore `json:"azureBlobStorage,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FileSystem *FileSystemTokenStore `json:"fileSystem,omitempty"` + TokenRefreshExtensionHours *float64 `json:"tokenRefreshExtensionHours,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_triggeredjobhistory.go b/resource-manager/web/2023-12-01/webapps/model_triggeredjobhistory.go new file mode 100644 index 00000000000..2eb9852d4b7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_triggeredjobhistory.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredJobHistory struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TriggeredJobHistoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_triggeredjobhistoryproperties.go b/resource-manager/web/2023-12-01/webapps/model_triggeredjobhistoryproperties.go new file mode 100644 index 00000000000..37c8ad7df32 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_triggeredjobhistoryproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredJobHistoryProperties struct { + Runs *[]TriggeredJobRun `json:"runs,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_triggeredjobrun.go b/resource-manager/web/2023-12-01/webapps/model_triggeredjobrun.go new file mode 100644 index 00000000000..695a8d5a98d --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_triggeredjobrun.go @@ -0,0 +1,48 @@ +package webapps + +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 TriggeredJobRun struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"end_time,omitempty"` + ErrorUrl *string `json:"error_url,omitempty"` + JobName *string `json:"job_name,omitempty"` + OutputUrl *string `json:"output_url,omitempty"` + StartTime *string `json:"start_time,omitempty"` + Status *TriggeredWebJobStatus `json:"status,omitempty"` + Trigger *string `json:"trigger,omitempty"` + Url *string `json:"url,omitempty"` + WebJobId *string `json:"web_job_id,omitempty"` + WebJobName *string `json:"web_job_name,omitempty"` +} + +func (o *TriggeredJobRun) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TriggeredJobRun) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *TriggeredJobRun) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TriggeredJobRun) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/webapps/model_triggeredwebjob.go b/resource-manager/web/2023-12-01/webapps/model_triggeredwebjob.go new file mode 100644 index 00000000000..aab21f2dfae --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_triggeredwebjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredWebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TriggeredWebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_triggeredwebjobproperties.go b/resource-manager/web/2023-12-01/webapps/model_triggeredwebjobproperties.go new file mode 100644 index 00000000000..0205e0bc246 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_triggeredwebjobproperties.go @@ -0,0 +1,19 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredWebJobProperties struct { + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + HistoryUrl *string `json:"history_url,omitempty"` + LatestRun *TriggeredJobRun `json:"latest_run,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + SchedulerLogsUrl *string `json:"scheduler_logs_url,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_twitter.go b/resource-manager/web/2023-12-01/webapps/model_twitter.go new file mode 100644 index 00000000000..16018b814ad --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_twitter.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Twitter struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *TwitterRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_twitterregistration.go b/resource-manager/web/2023-12-01/webapps/model_twitterregistration.go new file mode 100644 index 00000000000..15d70794ab7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_twitterregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TwitterRegistration struct { + ConsumerKey *string `json:"consumerKey,omitempty"` + ConsumerSecretSettingName *string `json:"consumerSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_user.go b/resource-manager/web/2023-12-01/webapps/model_user.go new file mode 100644 index 00000000000..0be0f9a3507 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_user.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type User struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UserProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_userproperties.go b/resource-manager/web/2023-12-01/webapps/model_userproperties.go new file mode 100644 index 00000000000..42d228f76de --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_userproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserProperties struct { + PublishingPassword *string `json:"publishingPassword,omitempty"` + PublishingPasswordHash *string `json:"publishingPasswordHash,omitempty"` + PublishingPasswordHashSalt *string `json:"publishingPasswordHashSalt,omitempty"` + PublishingUserName string `json:"publishingUserName"` + ScmUri *string `json:"scmUri,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_virtualapplication.go b/resource-manager/web/2023-12-01/webapps/model_virtualapplication.go new file mode 100644 index 00000000000..cd9a20e0a97 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_virtualapplication.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_virtualdirectory.go b/resource-manager/web/2023-12-01/webapps/model_virtualdirectory.go new file mode 100644 index 00000000000..e12dd8d0b49 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_vnetgateway.go b/resource-manager/web/2023-12-01/webapps/model_vnetgateway.go new file mode 100644 index 00000000000..59ce757342b --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_vnetgateway.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGateway struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetGatewayProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_vnetgatewayproperties.go b/resource-manager/web/2023-12-01/webapps/model_vnetgatewayproperties.go new file mode 100644 index 00000000000..e90b78642ee --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_vnetgatewayproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGatewayProperties struct { + VnetName *string `json:"vnetName,omitempty"` + VpnPackageUri string `json:"vpnPackageUri"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_vnetinfo.go b/resource-manager/web/2023-12-01/webapps/model_vnetinfo.go new file mode 100644 index 00000000000..9ef7b52d7de --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_vnetinfo.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfo struct { + CertBlob *string `json:"certBlob,omitempty"` + CertThumbprint *string `json:"certThumbprint,omitempty"` + DnsServers *string `json:"dnsServers,omitempty"` + IsSwift *bool `json:"isSwift,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + Routes *[]VnetRoute `json:"routes,omitempty"` + VnetResourceId *string `json:"vnetResourceId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_vnetinforesource.go b/resource-manager/web/2023-12-01/webapps/model_vnetinforesource.go new file mode 100644 index 00000000000..6b6193e0fee --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_vnetinforesource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfoResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_vnetroute.go b/resource-manager/web/2023-12-01/webapps/model_vnetroute.go new file mode 100644 index 00000000000..58365af2214 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_vnetroute.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetRouteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_vnetrouteproperties.go b/resource-manager/web/2023-12-01/webapps/model_vnetrouteproperties.go new file mode 100644 index 00000000000..00d288ce7d7 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_vnetrouteproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRouteProperties struct { + EndAddress *string `json:"endAddress,omitempty"` + RouteType *RouteType `json:"routeType,omitempty"` + StartAddress *string `json:"startAddress,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_volumemount.go b/resource-manager/web/2023-12-01/webapps/model_volumemount.go new file mode 100644 index 00000000000..fd0456dd18e --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_volumemount.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeMount struct { + ContainerMountPath string `json:"containerMountPath"` + Data *string `json:"data,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + VolumeSubPath string `json:"volumeSubPath"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_webjob.go b/resource-manager/web/2023-12-01/webapps/model_webjob.go new file mode 100644 index 00000000000..6dfbc3f0a58 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_webjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_webjobproperties.go b/resource-manager/web/2023-12-01/webapps/model_webjobproperties.go new file mode 100644 index 00000000000..b67f1af63a0 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_webjobproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebJobProperties struct { + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_websiteinstancestatus.go b/resource-manager/web/2023-12-01/webapps/model_websiteinstancestatus.go new file mode 100644 index 00000000000..7cf30ebf35a --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_websiteinstancestatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebSiteInstanceStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebSiteInstanceStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_websiteinstancestatusproperties.go b/resource-manager/web/2023-12-01/webapps/model_websiteinstancestatusproperties.go new file mode 100644 index 00000000000..fac5b723630 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_websiteinstancestatusproperties.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebSiteInstanceStatusProperties struct { + ConsoleUrl *string `json:"consoleUrl,omitempty"` + Containers *map[string]ContainerInfo `json:"containers,omitempty"` + DetectorUrl *string `json:"detectorUrl,omitempty"` + HealthCheckUrl *string `json:"healthCheckUrl,omitempty"` + State *SiteRuntimeState `json:"state,omitempty"` + StatusUrl *string `json:"statusUrl,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_workflowartifacts.go b/resource-manager/web/2023-12-01/webapps/model_workflowartifacts.go new file mode 100644 index 00000000000..52498481889 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_workflowartifacts.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowArtifacts struct { + AppSettings *interface{} `json:"appSettings,omitempty"` + Files *map[string]interface{} `json:"files,omitempty"` + FilesToDelete *[]string `json:"filesToDelete,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_workflowenvelope.go b/resource-manager/web/2023-12-01/webapps/model_workflowenvelope.go new file mode 100644 index 00000000000..6f4ea5ce596 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_workflowenvelope.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowEnvelope struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowEnvelopeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_workflowenvelopeproperties.go b/resource-manager/web/2023-12-01/webapps/model_workflowenvelopeproperties.go new file mode 100644 index 00000000000..a14bffda962 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_workflowenvelopeproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowEnvelopeProperties struct { + Files *map[string]interface{} `json:"files,omitempty"` + FlowState *WorkflowState `json:"flowState,omitempty"` + Health *WorkflowHealth `json:"health,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/webapps/model_workflowhealth.go b/resource-manager/web/2023-12-01/webapps/model_workflowhealth.go new file mode 100644 index 00000000000..f9ec376ba05 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/model_workflowhealth.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowHealth struct { + Error *ErrorEntity `json:"error,omitempty"` + State WorkflowHealthState `json:"state"` +} diff --git a/resource-manager/web/2023-12-01/webapps/predicates.go b/resource-manager/web/2023-12-01/webapps/predicates.go new file mode 100644 index 00000000000..3961c0e0cfd --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/predicates.go @@ -0,0 +1,788 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReferenceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ApiKVReferenceOperationPredicate) Matches(input ApiKVReference) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type BackupItemOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p BackupItemOperationPredicate) Matches(input BackupItem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ContinuousWebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ContinuousWebJobOperationPredicate) Matches(input ContinuousWebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmDeploymentStatusOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CsmDeploymentStatusOperationPredicate) Matches(input CsmDeploymentStatus) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmPublishingCredentialsPoliciesEntityOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CsmPublishingCredentialsPoliciesEntityOperationPredicate) Matches(input CsmPublishingCredentialsPoliciesEntity) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type DeploymentOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DeploymentOperationPredicate) Matches(input Deployment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type FunctionEnvelopeOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p FunctionEnvelopeOperationPredicate) Matches(input FunctionEnvelope) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type HostNameBindingOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p HostNameBindingOperationPredicate) Matches(input HostNameBinding) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type IdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p IdentifierOperationPredicate) Matches(input Identifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type PerfMonResponseOperationPredicate struct { + Code *string + Message *string +} + +func (p PerfMonResponseOperationPredicate) Matches(input PerfMonResponse) bool { + + if p.Code != nil && (input.Code == nil || *p.Code != *input.Code) { + return false + } + + if p.Message != nil && (input.Message == nil || *p.Message != *input.Message) { + return false + } + + return true +} + +type ProcessInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessInfoOperationPredicate) Matches(input ProcessInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ProcessModuleInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessModuleInfoOperationPredicate) Matches(input ProcessModuleInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type ProcessThreadInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessThreadInfoOperationPredicate) Matches(input ProcessThreadInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type PublicCertificateOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p PublicCertificateOperationPredicate) Matches(input PublicCertificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteConfigResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteConfigResourceOperationPredicate) Matches(input SiteConfigResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteConfigurationSnapshotInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteConfigurationSnapshotInfoOperationPredicate) Matches(input SiteConfigurationSnapshotInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteContainerOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteContainerOperationPredicate) Matches(input SiteContainer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SiteExtensionInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteExtensionInfoOperationPredicate) Matches(input SiteExtensionInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SlotDifferenceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SlotDifferenceOperationPredicate) Matches(input SlotDifference) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type SnapshotOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SnapshotOperationPredicate) Matches(input Snapshot) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type TriggeredJobHistoryOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TriggeredJobHistoryOperationPredicate) Matches(input TriggeredJobHistory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type TriggeredWebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TriggeredWebJobOperationPredicate) Matches(input TriggeredWebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WebJobOperationPredicate) Matches(input WebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WebSiteInstanceStatusOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WebSiteInstanceStatusOperationPredicate) Matches(input WebSiteInstanceStatus) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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 +} + +type WorkflowEnvelopeOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p WorkflowEnvelopeOperationPredicate) Matches(input WorkflowEnvelope) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + 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/web/2023-12-01/webapps/version.go b/resource-manager/web/2023-12-01/webapps/version.go new file mode 100644 index 00000000000..3cc70e92e92 --- /dev/null +++ b/resource-manager/web/2023-12-01/webapps/version.go @@ -0,0 +1,12 @@ +package webapps + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/webapps/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/README.md b/resource-manager/web/2023-12-01/workflowrunactions/README.md new file mode 100644 index 00000000000..1caebc94567 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/README.md @@ -0,0 +1,186 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowrunactions` Documentation + +The `workflowrunactions` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowrunactions" +``` + + +### Client Initialization + +```go +client := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowRunActionsClient.CopeRepetitionsGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "scopeRepetitionValue") + +read, err := client.CopeRepetitionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.CopeRepetitionsList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue") + +// alternatively `client.CopeRepetitionsList(ctx, id)` can be used to do batched pagination +items, err := client.CopeRepetitionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.Get` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue") + +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: `WorkflowRunActionsClient.List` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue") + +// alternatively `client.List(ctx, id, workflowrunactions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowrunactions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.ListExpressionTraces` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue") + +// alternatively `client.ListExpressionTraces(ctx, id)` can be used to do batched pagination +items, err := client.ListExpressionTracesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue") + +read, err := client.WorkflowRunActionRepetitionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue") + +// alternatively `client.WorkflowRunActionRepetitionsList(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsListExpressionTraces` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue") + +// alternatively `client.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsRequestHistoriesGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue", "requestHistoryValue") + +read, err := client.WorkflowRunActionRepetitionsRequestHistoriesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsRequestHistoriesList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue") + +// alternatively `client.WorkflowRunActionRepetitionsRequestHistoriesList(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/workflowrunactions/client.go b/resource-manager/web/2023-12-01/workflowrunactions/client.go new file mode 100644 index 00000000000..75492551c09 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/client.go @@ -0,0 +1,26 @@ +package workflowrunactions + +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 WorkflowRunActionsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowRunActionsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowRunActionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "workflowrunactions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunActionsClient: %+v", err) + } + + return &WorkflowRunActionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/constants.go b/resource-manager/web/2023-12-01/workflowrunactions/constants.go new file mode 100644 index 00000000000..98029f459ce --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/constants.go @@ -0,0 +1,84 @@ +package workflowrunactions + +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 WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/id_action.go b/resource-manager/web/2023-12-01/workflowrunactions/id_action.go new file mode 100644 index 00000000000..e8b0fe5a8c1 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_action.go @@ -0,0 +1,163 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ActionId{}) +} + +var _ resourceids.ResourceId = &ActionId{} + +// ActionId is a struct representing the Resource ID for a Action +type ActionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string +} + +// NewActionID returns a new ActionId struct +func NewActionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string) ActionId { + return ActionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + } +} + +// ParseActionID parses 'input' into a ActionId +func ParseActionID(input string) (*ActionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ActionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ActionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseActionIDInsensitively parses 'input' case-insensitively into a ActionId +// note: this method should only be used for API response data and not user input +func ParseActionIDInsensitively(input string) (*ActionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ActionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ActionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ActionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + return nil +} + +// ValidateActionID checks that 'input' can be parsed as a Action ID +func ValidateActionID(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 := ParseActionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Action ID +func (id ActionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Action ID +func (id ActionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runValue"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionValue"), + } +} + +// String returns a human-readable description of this Action ID +func (id ActionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + } + return fmt.Sprintf("Action (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/id_action_test.go b/resource-manager/web/2023-12-01/workflowrunactions/id_action_test.go new file mode 100644 index 00000000000..d6de0ac1369 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_action_test.go @@ -0,0 +1,507 @@ +package workflowrunactions + +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 = &ActionId{} + +func TestNewActionID(t *testing.T) { + id := NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.RunName != "runValue" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runValue") + } + + if id.ActionName != "actionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionValue") + } +} + +func TestFormatActionID(t *testing.T) { + actual := NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseActionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ActionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseActionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + } +} + +func TestParseActionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ActionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + RunName: "rUnVaLuE", + ActionName: "aCtIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseActionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + } +} + +func TestSegmentsForActionId(t *testing.T) { + segments := ActionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ActionId 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/web/2023-12-01/workflowrunactions/id_repetition.go b/resource-manager/web/2023-12-01/workflowrunactions/id_repetition.go new file mode 100644 index 00000000000..e546f29fa0c --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_repetition.go @@ -0,0 +1,172 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RepetitionId{}) +} + +var _ resourceids.ResourceId = &RepetitionId{} + +// RepetitionId is a struct representing the Resource ID for a Repetition +type RepetitionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + RepetitionName string +} + +// NewRepetitionID returns a new RepetitionId struct +func NewRepetitionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, repetitionName string) RepetitionId { + return RepetitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + RepetitionName: repetitionName, + } +} + +// ParseRepetitionID parses 'input' into a RepetitionId +func ParseRepetitionID(input string) (*RepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RepetitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RepetitionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRepetitionIDInsensitively parses 'input' case-insensitively into a RepetitionId +// note: this method should only be used for API response data and not user input +func ParseRepetitionIDInsensitively(input string) (*RepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RepetitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RepetitionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RepetitionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.RepetitionName, ok = input.Parsed["repetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "repetitionName", input) + } + + return nil +} + +// ValidateRepetitionID checks that 'input' can be parsed as a Repetition ID +func ValidateRepetitionID(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 := ParseRepetitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Repetition ID +func (id RepetitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/repetitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.RepetitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Repetition ID +func (id RepetitionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runValue"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionValue"), + resourceids.StaticSegment("staticRepetitions", "repetitions", "repetitions"), + resourceids.UserSpecifiedSegment("repetitionName", "repetitionValue"), + } +} + +// String returns a human-readable description of this Repetition ID +func (id RepetitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Repetition Name: %q", id.RepetitionName), + } + return fmt.Sprintf("Repetition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/id_repetition_test.go b/resource-manager/web/2023-12-01/workflowrunactions/id_repetition_test.go new file mode 100644 index 00000000000..e421aef5d1f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_repetition_test.go @@ -0,0 +1,552 @@ +package workflowrunactions + +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 = &RepetitionId{} + +func TestNewRepetitionID(t *testing.T) { + id := NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.RunName != "runValue" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runValue") + } + + if id.ActionName != "actionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionValue") + } + + if id.RepetitionName != "repetitionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RepetitionName'", id.RepetitionName, "repetitionValue") + } +} + +func TestFormatRepetitionID(t *testing.T) { + actual := NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRepetitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + RepetitionName: "repetitionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRepetitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + } +} + +func TestParseRepetitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + RepetitionName: "repetitionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs/rEpEtItIoNvAlUe", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + RunName: "rUnVaLuE", + ActionName: "aCtIoNvAlUe", + RepetitionName: "rEpEtItIoNvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs/rEpEtItIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRepetitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + } +} + +func TestSegmentsForRepetitionId(t *testing.T) { + segments := RepetitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RepetitionId 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/web/2023-12-01/workflowrunactions/id_requesthistory.go b/resource-manager/web/2023-12-01/workflowrunactions/id_requesthistory.go new file mode 100644 index 00000000000..2425ea99f3c --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_requesthistory.go @@ -0,0 +1,181 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RequestHistoryId{}) +} + +var _ resourceids.ResourceId = &RequestHistoryId{} + +// RequestHistoryId is a struct representing the Resource ID for a Request History +type RequestHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + RepetitionName string + RequestHistoryName string +} + +// NewRequestHistoryID returns a new RequestHistoryId struct +func NewRequestHistoryID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, repetitionName string, requestHistoryName string) RequestHistoryId { + return RequestHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + RepetitionName: repetitionName, + RequestHistoryName: requestHistoryName, + } +} + +// ParseRequestHistoryID parses 'input' into a RequestHistoryId +func ParseRequestHistoryID(input string) (*RequestHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RequestHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RequestHistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRequestHistoryIDInsensitively parses 'input' case-insensitively into a RequestHistoryId +// note: this method should only be used for API response data and not user input +func ParseRequestHistoryIDInsensitively(input string) (*RequestHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RequestHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RequestHistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RequestHistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.RepetitionName, ok = input.Parsed["repetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "repetitionName", input) + } + + if id.RequestHistoryName, ok = input.Parsed["requestHistoryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "requestHistoryName", input) + } + + return nil +} + +// ValidateRequestHistoryID checks that 'input' can be parsed as a Request History ID +func ValidateRequestHistoryID(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 := ParseRequestHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Request History ID +func (id RequestHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/repetitions/%s/requestHistories/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.RepetitionName, id.RequestHistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Request History ID +func (id RequestHistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runValue"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionValue"), + resourceids.StaticSegment("staticRepetitions", "repetitions", "repetitions"), + resourceids.UserSpecifiedSegment("repetitionName", "repetitionValue"), + resourceids.StaticSegment("staticRequestHistories", "requestHistories", "requestHistories"), + resourceids.UserSpecifiedSegment("requestHistoryName", "requestHistoryValue"), + } +} + +// String returns a human-readable description of this Request History ID +func (id RequestHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Repetition Name: %q", id.RepetitionName), + fmt.Sprintf("Request History Name: %q", id.RequestHistoryName), + } + return fmt.Sprintf("Request History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/id_requesthistory_test.go b/resource-manager/web/2023-12-01/workflowrunactions/id_requesthistory_test.go new file mode 100644 index 00000000000..8f338f0abb3 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_requesthistory_test.go @@ -0,0 +1,597 @@ +package workflowrunactions + +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 = &RequestHistoryId{} + +func TestNewRequestHistoryID(t *testing.T) { + id := NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue", "requestHistoryValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.RunName != "runValue" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runValue") + } + + if id.ActionName != "actionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionValue") + } + + if id.RepetitionName != "repetitionValue" { + t.Fatalf("Expected %q but got %q for Segment 'RepetitionName'", id.RepetitionName, "repetitionValue") + } + + if id.RequestHistoryName != "requestHistoryValue" { + t.Fatalf("Expected %q but got %q for Segment 'RequestHistoryName'", id.RequestHistoryName, "requestHistoryValue") + } +} + +func TestFormatRequestHistoryID(t *testing.T) { + actual := NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "repetitionValue", "requestHistoryValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/requestHistories/requestHistoryValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRequestHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RequestHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/requestHistories", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/requestHistories/requestHistoryValue", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + RepetitionName: "repetitionValue", + RequestHistoryName: "requestHistoryValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/requestHistories/requestHistoryValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRequestHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + if actual.RequestHistoryName != v.Expected.RequestHistoryName { + t.Fatalf("Expected %q but got %q for RequestHistoryName", v.Expected.RequestHistoryName, actual.RequestHistoryName) + } + + } +} + +func TestParseRequestHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RequestHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs/rEpEtItIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/requestHistories", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs/rEpEtItIoNvAlUe/rEqUeStHiStOrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/requestHistories/requestHistoryValue", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + RepetitionName: "repetitionValue", + RequestHistoryName: "requestHistoryValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/repetitions/repetitionValue/requestHistories/requestHistoryValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs/rEpEtItIoNvAlUe/rEqUeStHiStOrIeS/rEqUeStHiStOrYvAlUe", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + RunName: "rUnVaLuE", + ActionName: "aCtIoNvAlUe", + RepetitionName: "rEpEtItIoNvAlUe", + RequestHistoryName: "rEqUeStHiStOrYvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/rEpEtItIoNs/rEpEtItIoNvAlUe/rEqUeStHiStOrIeS/rEqUeStHiStOrYvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRequestHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + if actual.RequestHistoryName != v.Expected.RequestHistoryName { + t.Fatalf("Expected %q but got %q for RequestHistoryName", v.Expected.RequestHistoryName, actual.RequestHistoryName) + } + + } +} + +func TestSegmentsForRequestHistoryId(t *testing.T) { + segments := RequestHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RequestHistoryId 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/web/2023-12-01/workflowrunactions/id_run.go b/resource-manager/web/2023-12-01/workflowrunactions/id_run.go new file mode 100644 index 00000000000..3d1f8970278 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_run.go @@ -0,0 +1,154 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RunId{}) +} + +var _ resourceids.ResourceId = &RunId{} + +// RunId is a struct representing the Resource ID for a Run +type RunId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string +} + +// NewRunID returns a new RunId struct +func NewRunID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string) RunId { + return RunId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + } +} + +// ParseRunID parses 'input' into a RunId +func ParseRunID(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRunIDInsensitively parses 'input' case-insensitively into a RunId +// note: this method should only be used for API response data and not user input +func ParseRunIDInsensitively(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RunId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + return nil +} + +// ValidateRunID checks that 'input' can be parsed as a Run ID +func ValidateRunID(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 := ParseRunID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Run ID +func (id RunId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Run ID +func (id RunId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runValue"), + } +} + +// String returns a human-readable description of this Run ID +func (id RunId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + } + return fmt.Sprintf("Run (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/id_run_test.go b/resource-manager/web/2023-12-01/workflowrunactions/id_run_test.go new file mode 100644 index 00000000000..4530f543516 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_run_test.go @@ -0,0 +1,462 @@ +package workflowrunactions + +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 = &RunId{} + +func TestNewRunID(t *testing.T) { + id := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.RunName != "runValue" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runValue") + } +} + +func TestFormatRunID(t *testing.T) { + actual := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRunID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestParseRunIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + RunName: "rUnVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestSegmentsForRunId(t *testing.T) { + segments := RunId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RunId 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/web/2023-12-01/workflowrunactions/id_scoperepetition.go b/resource-manager/web/2023-12-01/workflowrunactions/id_scoperepetition.go new file mode 100644 index 00000000000..effb962622b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_scoperepetition.go @@ -0,0 +1,172 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScopeRepetitionId{}) +} + +var _ resourceids.ResourceId = &ScopeRepetitionId{} + +// ScopeRepetitionId is a struct representing the Resource ID for a Scope Repetition +type ScopeRepetitionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + ScopeRepetitionName string +} + +// NewScopeRepetitionID returns a new ScopeRepetitionId struct +func NewScopeRepetitionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, scopeRepetitionName string) ScopeRepetitionId { + return ScopeRepetitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + ScopeRepetitionName: scopeRepetitionName, + } +} + +// ParseScopeRepetitionID parses 'input' into a ScopeRepetitionId +func ParseScopeRepetitionID(input string) (*ScopeRepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeRepetitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeRepetitionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopeRepetitionIDInsensitively parses 'input' case-insensitively into a ScopeRepetitionId +// note: this method should only be used for API response data and not user input +func ParseScopeRepetitionIDInsensitively(input string) (*ScopeRepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeRepetitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeRepetitionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopeRepetitionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.ScopeRepetitionName, ok = input.Parsed["scopeRepetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scopeRepetitionName", input) + } + + return nil +} + +// ValidateScopeRepetitionID checks that 'input' can be parsed as a Scope Repetition ID +func ValidateScopeRepetitionID(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 := ParseScopeRepetitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scope Repetition ID +func (id ScopeRepetitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/scopeRepetitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.ScopeRepetitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scope Repetition ID +func (id ScopeRepetitionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runValue"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionValue"), + resourceids.StaticSegment("staticScopeRepetitions", "scopeRepetitions", "scopeRepetitions"), + resourceids.UserSpecifiedSegment("scopeRepetitionName", "scopeRepetitionValue"), + } +} + +// String returns a human-readable description of this Scope Repetition ID +func (id ScopeRepetitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Scope Repetition Name: %q", id.ScopeRepetitionName), + } + return fmt.Sprintf("Scope Repetition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/id_scoperepetition_test.go b/resource-manager/web/2023-12-01/workflowrunactions/id_scoperepetition_test.go new file mode 100644 index 00000000000..534ba5b8f33 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/id_scoperepetition_test.go @@ -0,0 +1,552 @@ +package workflowrunactions + +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 = &ScopeRepetitionId{} + +func TestNewScopeRepetitionID(t *testing.T) { + id := NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "scopeRepetitionValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.RunName != "runValue" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runValue") + } + + if id.ActionName != "actionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionValue") + } + + if id.ScopeRepetitionName != "scopeRepetitionValue" { + t.Fatalf("Expected %q but got %q for Segment 'ScopeRepetitionName'", id.ScopeRepetitionName, "scopeRepetitionValue") + } +} + +func TestFormatScopeRepetitionID(t *testing.T) { + actual := NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue", "actionValue", "scopeRepetitionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/scopeRepetitions/scopeRepetitionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopeRepetitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeRepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/scopeRepetitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/scopeRepetitions/scopeRepetitionValue", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + ScopeRepetitionName: "scopeRepetitionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/scopeRepetitions/scopeRepetitionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeRepetitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.ScopeRepetitionName != v.Expected.ScopeRepetitionName { + t.Fatalf("Expected %q but got %q for ScopeRepetitionName", v.Expected.ScopeRepetitionName, actual.ScopeRepetitionName) + } + + } +} + +func TestParseScopeRepetitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeRepetitionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/scopeRepetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/sCoPeRePeTiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/scopeRepetitions/scopeRepetitionValue", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + ActionName: "actionValue", + ScopeRepetitionName: "scopeRepetitionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/actions/actionValue/scopeRepetitions/scopeRepetitionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/sCoPeRePeTiTiOnS/sCoPeRePeTiTiOnVaLuE", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + RunName: "rUnVaLuE", + ActionName: "aCtIoNvAlUe", + ScopeRepetitionName: "sCoPeRePeTiTiOnVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/aCtIoNs/aCtIoNvAlUe/sCoPeRePeTiTiOnS/sCoPeRePeTiTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeRepetitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.ScopeRepetitionName != v.Expected.ScopeRepetitionName { + t.Fatalf("Expected %q but got %q for ScopeRepetitionName", v.Expected.ScopeRepetitionName, actual.ScopeRepetitionName) + } + + } +} + +func TestSegmentsForScopeRepetitionId(t *testing.T) { + segments := ScopeRepetitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopeRepetitionId 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/web/2023-12-01/workflowrunactions/method_coperepetitionsget.go b/resource-manager/web/2023-12-01/workflowrunactions/method_coperepetitionsget.go new file mode 100644 index 00000000000..f767e43bd99 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_coperepetitionsget.go @@ -0,0 +1,54 @@ +package workflowrunactions + +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 CopeRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// CopeRepetitionsGet ... +func (c WorkflowRunActionsClient) CopeRepetitionsGet(ctx context.Context, id ScopeRepetitionId) (result CopeRepetitionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRunActionRepetitionDefinition + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_coperepetitionslist.go b/resource-manager/web/2023-12-01/workflowrunactions/method_coperepetitionslist.go new file mode 100644 index 00000000000..6522f64a2f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_coperepetitionslist.go @@ -0,0 +1,91 @@ +package workflowrunactions + +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 CopeRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type CopeRepetitionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunActionRepetitionDefinition +} + +// CopeRepetitionsList ... +func (c WorkflowRunActionsClient) CopeRepetitionsList(ctx context.Context, id ActionId) (result CopeRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/scopeRepetitions", 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 *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CopeRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) CopeRepetitionsListComplete(ctx context.Context, id ActionId) (CopeRepetitionsListCompleteResult, error) { + return c.CopeRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// CopeRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) CopeRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result CopeRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.CopeRepetitionsList(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 = CopeRepetitionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_get.go b/resource-manager/web/2023-12-01/workflowrunactions/method_get.go new file mode 100644 index 00000000000..83af4ca8829 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_get.go @@ -0,0 +1,54 @@ +package workflowrunactions + +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 *WorkflowRunAction +} + +// Get ... +func (c WorkflowRunActionsClient) Get(ctx context.Context, id ActionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRunAction + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_list.go b/resource-manager/web/2023-12-01/workflowrunactions/method_list.go new file mode 100644 index 00000000000..1296d04b55d --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_list.go @@ -0,0 +1,123 @@ +package workflowrunactions + +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 *[]WorkflowRunAction +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunAction +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +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.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowRunActionsClient) List(ctx context.Context, id RunId, 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/actions", 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 *[]WorkflowRunAction `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 WorkflowRunActionsClient) ListComplete(ctx context.Context, id RunId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunActionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) ListCompleteMatchingPredicate(ctx context.Context, id RunId, options ListOperationOptions, predicate WorkflowRunActionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRunAction, 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/web/2023-12-01/workflowrunactions/method_listexpressiontraces.go b/resource-manager/web/2023-12-01/workflowrunactions/method_listexpressiontraces.go new file mode 100644 index 00000000000..34db9faf0de --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_listexpressiontraces.go @@ -0,0 +1,84 @@ +package workflowrunactions + +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 ListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type ListExpressionTracesCompleteResult struct { + LatestHttpResponse *http.Response + Items []interface{} +} + +// ListExpressionTraces ... +func (c WorkflowRunActionsClient) ListExpressionTraces(ctx context.Context, id ActionId) (result ListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listExpressionTraces", 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 *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) ListExpressionTracesComplete(ctx context.Context, id ActionId) (result ListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.ListExpressionTraces(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListExpressionTracesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsget.go b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsget.go new file mode 100644 index 00000000000..ecac4315b0f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsget.go @@ -0,0 +1,54 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// WorkflowRunActionRepetitionsGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsGet(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRunActionRepetitionDefinition + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslist.go b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslist.go new file mode 100644 index 00000000000..e36bbf7445a --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslist.go @@ -0,0 +1,91 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type WorkflowRunActionRepetitionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunActionRepetitionDefinition +} + +// WorkflowRunActionRepetitionsList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsList(ctx context.Context, id ActionId) (result WorkflowRunActionRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/repetitions", 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 *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListComplete(ctx context.Context, id ActionId) (WorkflowRunActionRepetitionsListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result WorkflowRunActionRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.WorkflowRunActionRepetitionsList(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 = WorkflowRunActionRepetitionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go new file mode 100644 index 00000000000..0e11efabe16 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go @@ -0,0 +1,84 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type WorkflowRunActionRepetitionsListExpressionTracesCompleteResult struct { + LatestHttpResponse *http.Response + Items []interface{} +} + +// WorkflowRunActionRepetitionsListExpressionTraces ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTraces(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listExpressionTraces", 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 *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = WorkflowRunActionRepetitionsListExpressionTracesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go new file mode 100644 index 00000000000..41bb4f82cb2 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go @@ -0,0 +1,54 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RequestHistory +} + +// WorkflowRunActionRepetitionsRequestHistoriesGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesGet(ctx context.Context, id RequestHistoryId) (result WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RequestHistory + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go new file mode 100644 index 00000000000..08b997c6301 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go @@ -0,0 +1,91 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RequestHistory +} + +type WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RequestHistory +} + +// WorkflowRunActionRepetitionsRequestHistoriesList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesList(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/requestHistories", 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 *[]RequestHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsRequestHistoriesListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx context.Context, id RepetitionId) (WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx, id, RequestHistoryOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx context.Context, id RepetitionId, predicate RequestHistoryOperationPredicate) (result WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, err error) { + items := make([]RequestHistory, 0) + + resp, err := c.WorkflowRunActionRepetitionsRequestHistoriesList(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 = WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_contenthash.go b/resource-manager/web/2023-12-01/workflowrunactions/model_contenthash.go new file mode 100644 index 00000000000..3c0011433bc --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_contentlink.go b/resource-manager/web/2023-12-01/workflowrunactions/model_contentlink.go new file mode 100644 index 00000000000..bd3dc0e8dbc --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_errorproperties.go b/resource-manager/web/2023-12-01/workflowrunactions/model_errorproperties.go new file mode 100644 index 00000000000..0c17755bd62 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_errorproperties.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorProperties struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_errorresponse.go b/resource-manager/web/2023-12-01/workflowrunactions/model_errorresponse.go new file mode 100644 index 00000000000..9856e5afdda --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_errorresponse.go @@ -0,0 +1,8 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorResponse struct { + Error *ErrorProperties `json:"error,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_repetitionindex.go b/resource-manager/web/2023-12-01/workflowrunactions/model_repetitionindex.go new file mode 100644 index 00000000000..ba809fd0741 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_repetitionindex.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RepetitionIndex struct { + ItemIndex int64 `json:"itemIndex"` + ScopeName *string `json:"scopeName,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_request.go b/resource-manager/web/2023-12-01/workflowrunactions/model_request.go new file mode 100644 index 00000000000..1ced5675ea2 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_request.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Request struct { + Headers *interface{} `json:"headers,omitempty"` + Method *string `json:"method,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_requesthistory.go b/resource-manager/web/2023-12-01/workflowrunactions/model_requesthistory.go new file mode 100644 index 00000000000..61e48b714f3 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_requesthistory.go @@ -0,0 +1,13 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestHistory struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RequestHistoryProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_requesthistoryproperties.go b/resource-manager/web/2023-12-01/workflowrunactions/model_requesthistoryproperties.go new file mode 100644 index 00000000000..86fd91ff9e0 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_requesthistoryproperties.go @@ -0,0 +1,41 @@ +package workflowrunactions + +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 RequestHistoryProperties struct { + EndTime *string `json:"endTime,omitempty"` + Request *Request `json:"request,omitempty"` + Response *Response `json:"response,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *RequestHistoryProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RequestHistoryProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RequestHistoryProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RequestHistoryProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_response.go b/resource-manager/web/2023-12-01/workflowrunactions/model_response.go new file mode 100644 index 00000000000..2697b1a5aab --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_response.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Response struct { + BodyLink *ContentLink `json:"bodyLink,omitempty"` + Headers *interface{} `json:"headers,omitempty"` + StatusCode *int64 `json:"statusCode,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_retryhistory.go b/resource-manager/web/2023-12-01/workflowrunactions/model_retryhistory.go new file mode 100644 index 00000000000..372ab23d01f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_retryhistory.go @@ -0,0 +1,43 @@ +package workflowrunactions + +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 RetryHistory struct { + ClientRequestId *string `json:"clientRequestId,omitempty"` + Code *string `json:"code,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *ErrorResponse `json:"error,omitempty"` + ServiceRequestId *string `json:"serviceRequestId,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *RetryHistory) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RetryHistory) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RetryHistory) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RetryHistory) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_runactioncorrelation.go b/resource-manager/web/2023-12-01/workflowrunactions/model_runactioncorrelation.go new file mode 100644 index 00000000000..dc7976ccc37 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_runactioncorrelation.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunActionCorrelation struct { + ActionTrackingId *string `json:"actionTrackingId,omitempty"` + ClientKeywords *[]string `json:"clientKeywords,omitempty"` + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunaction.go b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunaction.go new file mode 100644 index 00000000000..443cf266c76 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunaction.go @@ -0,0 +1,11 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunAction struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowRunActionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionproperties.go b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionproperties.go new file mode 100644 index 00000000000..515fd157766 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionproperties.go @@ -0,0 +1,48 @@ +package workflowrunactions + +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 WorkflowRunActionProperties struct { + Code *string `json:"code,omitempty"` + Correlation *RunActionCorrelation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + RetryHistory *[]RetryHistory `json:"retryHistory,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunActionProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunActionProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go new file mode 100644 index 00000000000..6705564dcf3 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go @@ -0,0 +1,13 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionDefinition struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkflowRunActionRepetitionProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go new file mode 100644 index 00000000000..759c33c6009 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go @@ -0,0 +1,52 @@ +package workflowrunactions + +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 WorkflowRunActionRepetitionProperties struct { + Code *string `json:"code,omitempty"` + Correlation *RunActionCorrelation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Inputs *interface{} `json:"inputs,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + IterationCount *int64 `json:"iterationCount,omitempty"` + Outputs *interface{} `json:"outputs,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + RepetitionIndexes *[]RepetitionIndex `json:"repetitionIndexes,omitempty"` + RetryHistory *[]RetryHistory `json:"retryHistory,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunActionRepetitionProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionRepetitionProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunActionRepetitionProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionRepetitionProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowrunactions/predicates.go b/resource-manager/web/2023-12-01/workflowrunactions/predicates.go new file mode 100644 index 00000000000..fa466cf2c8e --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/predicates.go @@ -0,0 +1,83 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestHistoryOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RequestHistoryOperationPredicate) Matches(input RequestHistory) 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 +} + +type WorkflowRunActionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowRunActionOperationPredicate) Matches(input WorkflowRunAction) 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 +} + +type WorkflowRunActionRepetitionDefinitionOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkflowRunActionRepetitionDefinitionOperationPredicate) Matches(input WorkflowRunActionRepetitionDefinition) 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/web/2023-12-01/workflowrunactions/version.go b/resource-manager/web/2023-12-01/workflowrunactions/version.go new file mode 100644 index 00000000000..1db8e4bcd98 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowrunactions/version.go @@ -0,0 +1,12 @@ +package workflowrunactions + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workflowrunactions/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/workflowruns/README.md b/resource-manager/web/2023-12-01/workflowruns/README.md new file mode 100644 index 00000000000..51e39d7d757 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowruns` Documentation + +The `workflowruns` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowruns" +``` + + +### Client Initialization + +```go +client := workflowruns.NewWorkflowRunsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowRunsClient.Cancel` + +```go +ctx := context.TODO() +id := workflowruns.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue") + +read, err := client.Cancel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunsClient.Get` + +```go +ctx := context.TODO() +id := workflowruns.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue") + +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: `WorkflowRunsClient.List` + +```go +ctx := context.TODO() +id := workflowruns.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + +// alternatively `client.List(ctx, id, workflowruns.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowruns.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/workflowruns/client.go b/resource-manager/web/2023-12-01/workflowruns/client.go new file mode 100644 index 00000000000..e41dae0872b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/client.go @@ -0,0 +1,26 @@ +package workflowruns + +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 WorkflowRunsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowRunsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowRunsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "workflowruns", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunsClient: %+v", err) + } + + return &WorkflowRunsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/workflowruns/constants.go b/resource-manager/web/2023-12-01/workflowruns/constants.go new file mode 100644 index 00000000000..35a87b003f0 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/constants.go @@ -0,0 +1,146 @@ +package workflowruns + +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 ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/workflowruns/id_managementworkflow.go b/resource-manager/web/2023-12-01/workflowruns/id_managementworkflow.go new file mode 100644 index 00000000000..7750de61f4e --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowruns/id_managementworkflow_test.go b/resource-manager/web/2023-12-01/workflowruns/id_managementworkflow_test.go new file mode 100644 index 00000000000..2677706f338 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowruns + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2023-12-01/workflowruns/id_run.go b/resource-manager/web/2023-12-01/workflowruns/id_run.go new file mode 100644 index 00000000000..9117bf15feb --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/id_run.go @@ -0,0 +1,154 @@ +package workflowruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RunId{}) +} + +var _ resourceids.ResourceId = &RunId{} + +// RunId is a struct representing the Resource ID for a Run +type RunId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string +} + +// NewRunID returns a new RunId struct +func NewRunID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string) RunId { + return RunId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + } +} + +// ParseRunID parses 'input' into a RunId +func ParseRunID(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRunIDInsensitively parses 'input' case-insensitively into a RunId +// note: this method should only be used for API response data and not user input +func ParseRunIDInsensitively(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RunId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + return nil +} + +// ValidateRunID checks that 'input' can be parsed as a Run ID +func ValidateRunID(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 := ParseRunID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Run ID +func (id RunId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Run ID +func (id RunId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runValue"), + } +} + +// String returns a human-readable description of this Run ID +func (id RunId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + } + return fmt.Sprintf("Run (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowruns/id_run_test.go b/resource-manager/web/2023-12-01/workflowruns/id_run_test.go new file mode 100644 index 00000000000..41dfd3e7429 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/id_run_test.go @@ -0,0 +1,462 @@ +package workflowruns + +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 = &RunId{} + +func TestNewRunID(t *testing.T) { + id := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.RunName != "runValue" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runValue") + } +} + +func TestFormatRunID(t *testing.T) { + actual := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "runValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRunID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestParseRunIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + RunName: "runValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/runs/runValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + RunName: "rUnVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/rUnS/rUnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestSegmentsForRunId(t *testing.T) { + segments := RunId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RunId 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/web/2023-12-01/workflowruns/method_cancel.go b/resource-manager/web/2023-12-01/workflowruns/method_cancel.go new file mode 100644 index 00000000000..bb4d8b5ae55 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/method_cancel.go @@ -0,0 +1,47 @@ +package workflowruns + +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 CancelOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Cancel ... +func (c WorkflowRunsClient) Cancel(ctx context.Context, id RunId) (result CancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowruns/method_get.go b/resource-manager/web/2023-12-01/workflowruns/method_get.go new file mode 100644 index 00000000000..6ee3078a7f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/method_get.go @@ -0,0 +1,54 @@ +package workflowruns + +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 *WorkflowRun +} + +// Get ... +func (c WorkflowRunsClient) Get(ctx context.Context, id RunId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRun + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowruns/method_list.go b/resource-manager/web/2023-12-01/workflowruns/method_list.go new file mode 100644 index 00000000000..c0dc04fd1ea --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/method_list.go @@ -0,0 +1,123 @@ +package workflowruns + +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 *[]WorkflowRun +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRun +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +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.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowRunsClient) List(ctx context.Context, id ManagementWorkflowId, 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/runs", 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 *[]WorkflowRun `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 WorkflowRunsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowRunOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRun, 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/web/2023-12-01/workflowruns/model_contenthash.go b/resource-manager/web/2023-12-01/workflowruns/model_contenthash.go new file mode 100644 index 00000000000..88622a95a71 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowruns/model_contentlink.go b/resource-manager/web/2023-12-01/workflowruns/model_contentlink.go new file mode 100644 index 00000000000..c373bce184c --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowruns/model_correlation.go b/resource-manager/web/2023-12-01/workflowruns/model_correlation.go new file mode 100644 index 00000000000..39ab7e52bc4 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_correlation.go @@ -0,0 +1,8 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Correlation struct { + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowruns/model_resourcereference.go b/resource-manager/web/2023-12-01/workflowruns/model_resourcereference.go new file mode 100644 index 00000000000..b3a7c0a9505 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowruns/model_workflowoutputparameter.go b/resource-manager/web/2023-12-01/workflowruns/model_workflowoutputparameter.go new file mode 100644 index 00000000000..eafad5d773e --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_workflowoutputparameter.go @@ -0,0 +1,12 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowOutputParameter struct { + Description *string `json:"description,omitempty"` + Error *interface{} `json:"error,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowruns/model_workflowrun.go b/resource-manager/web/2023-12-01/workflowruns/model_workflowrun.go new file mode 100644 index 00000000000..10487050a8b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_workflowrun.go @@ -0,0 +1,11 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRun struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowRunProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowruns/model_workflowrunproperties.go b/resource-manager/web/2023-12-01/workflowruns/model_workflowrunproperties.go new file mode 100644 index 00000000000..65670fb8d3a --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_workflowrunproperties.go @@ -0,0 +1,61 @@ +package workflowruns + +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 WorkflowRunProperties struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Outputs *map[string]WorkflowOutputParameter `json:"outputs,omitempty"` + Response *WorkflowRunTrigger `json:"response,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + Trigger *WorkflowRunTrigger `json:"trigger,omitempty"` + WaitEndTime *string `json:"waitEndTime,omitempty"` + Workflow *ResourceReference `json:"workflow,omitempty"` +} + +func (o *WorkflowRunProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +func (o *WorkflowRunProperties) GetWaitEndTimeAsTime() (*time.Time, error) { + if o.WaitEndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.WaitEndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetWaitEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.WaitEndTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowruns/model_workflowruntrigger.go b/resource-manager/web/2023-12-01/workflowruns/model_workflowruntrigger.go new file mode 100644 index 00000000000..64680149cd7 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/model_workflowruntrigger.go @@ -0,0 +1,63 @@ +package workflowruns + +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 WorkflowRunTrigger struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Inputs *interface{} `json:"inputs,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + Name *string `json:"name,omitempty"` + Outputs *interface{} `json:"outputs,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + ScheduledTime *string `json:"scheduledTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunTrigger) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunTrigger) GetScheduledTimeAsTime() (*time.Time, error) { + if o.ScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledTime = &formatted +} + +func (o *WorkflowRunTrigger) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowruns/predicates.go b/resource-manager/web/2023-12-01/workflowruns/predicates.go new file mode 100644 index 00000000000..ad76dae5873 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/predicates.go @@ -0,0 +1,27 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowRunOperationPredicate) Matches(input WorkflowRun) 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/web/2023-12-01/workflowruns/version.go b/resource-manager/web/2023-12-01/workflowruns/version.go new file mode 100644 index 00000000000..7c357eead3a --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowruns/version.go @@ -0,0 +1,12 @@ +package workflowruns + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workflowruns/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/workflows/README.md b/resource-manager/web/2023-12-01/workflows/README.md new file mode 100644 index 00000000000..19495f17f8b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/README.md @@ -0,0 +1,62 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflows` Documentation + +The `workflows` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflows" +``` + + +### Client Initialization + +```go +client := workflows.NewWorkflowsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowsClient.RegenerateAccessKey` + +```go +ctx := context.TODO() +id := workflows.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + +payload := workflows.RegenerateActionParameter{ + // ... +} + + +read, err := client.RegenerateAccessKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowsClient.Validate` + +```go +ctx := context.TODO() +id := workflows.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + +payload := workflows.Workflow{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2023-12-01/workflows/client.go b/resource-manager/web/2023-12-01/workflows/client.go new file mode 100644 index 00000000000..e036e0f1d48 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/client.go @@ -0,0 +1,26 @@ +package workflows + +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 WorkflowsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "workflows", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowsClient: %+v", err) + } + + return &WorkflowsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/workflows/constants.go b/resource-manager/web/2023-12-01/workflows/constants.go new file mode 100644 index 00000000000..856f9a16584 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/constants.go @@ -0,0 +1,402 @@ +package workflows + +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 KeyType string + +const ( + KeyTypeNotSpecified KeyType = "NotSpecified" + KeyTypePrimary KeyType = "Primary" + KeyTypeSecondary KeyType = "Secondary" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypeNotSpecified), + string(KeyTypePrimary), + string(KeyTypeSecondary), + } +} + +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "notspecified": KeyTypeNotSpecified, + "primary": KeyTypePrimary, + "secondary": KeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} + +type Kind string + +const ( + KindStateful Kind = "Stateful" + KindStateless Kind = "Stateless" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindStateful), + string(KindStateless), + } +} + +func (s *Kind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "stateful": KindStateful, + "stateless": KindStateless, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type OpenAuthenticationProviderType string + +const ( + OpenAuthenticationProviderTypeAAD OpenAuthenticationProviderType = "AAD" +) + +func PossibleValuesForOpenAuthenticationProviderType() []string { + return []string{ + string(OpenAuthenticationProviderTypeAAD), + } +} + +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { + vals := map[string]OpenAuthenticationProviderType{ + "aad": OpenAuthenticationProviderTypeAAD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OpenAuthenticationProviderType(input) + return &out, nil +} + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowProvisioningState string + +const ( + WorkflowProvisioningStateAccepted WorkflowProvisioningState = "Accepted" + WorkflowProvisioningStateCanceled WorkflowProvisioningState = "Canceled" + WorkflowProvisioningStateCompleted WorkflowProvisioningState = "Completed" + WorkflowProvisioningStateCreated WorkflowProvisioningState = "Created" + WorkflowProvisioningStateCreating WorkflowProvisioningState = "Creating" + WorkflowProvisioningStateDeleted WorkflowProvisioningState = "Deleted" + WorkflowProvisioningStateDeleting WorkflowProvisioningState = "Deleting" + WorkflowProvisioningStateFailed WorkflowProvisioningState = "Failed" + WorkflowProvisioningStateInProgress WorkflowProvisioningState = "InProgress" + WorkflowProvisioningStateMoving WorkflowProvisioningState = "Moving" + WorkflowProvisioningStateNotSpecified WorkflowProvisioningState = "NotSpecified" + WorkflowProvisioningStatePending WorkflowProvisioningState = "Pending" + WorkflowProvisioningStateReady WorkflowProvisioningState = "Ready" + WorkflowProvisioningStateRegistered WorkflowProvisioningState = "Registered" + WorkflowProvisioningStateRegistering WorkflowProvisioningState = "Registering" + WorkflowProvisioningStateRenewing WorkflowProvisioningState = "Renewing" + WorkflowProvisioningStateRunning WorkflowProvisioningState = "Running" + WorkflowProvisioningStateSucceeded WorkflowProvisioningState = "Succeeded" + WorkflowProvisioningStateUnregistered WorkflowProvisioningState = "Unregistered" + WorkflowProvisioningStateUnregistering WorkflowProvisioningState = "Unregistering" + WorkflowProvisioningStateUpdating WorkflowProvisioningState = "Updating" + WorkflowProvisioningStateWaiting WorkflowProvisioningState = "Waiting" +) + +func PossibleValuesForWorkflowProvisioningState() []string { + return []string{ + string(WorkflowProvisioningStateAccepted), + string(WorkflowProvisioningStateCanceled), + string(WorkflowProvisioningStateCompleted), + string(WorkflowProvisioningStateCreated), + string(WorkflowProvisioningStateCreating), + string(WorkflowProvisioningStateDeleted), + string(WorkflowProvisioningStateDeleting), + string(WorkflowProvisioningStateFailed), + string(WorkflowProvisioningStateInProgress), + string(WorkflowProvisioningStateMoving), + string(WorkflowProvisioningStateNotSpecified), + string(WorkflowProvisioningStatePending), + string(WorkflowProvisioningStateReady), + string(WorkflowProvisioningStateRegistered), + string(WorkflowProvisioningStateRegistering), + string(WorkflowProvisioningStateRenewing), + string(WorkflowProvisioningStateRunning), + string(WorkflowProvisioningStateSucceeded), + string(WorkflowProvisioningStateUnregistered), + string(WorkflowProvisioningStateUnregistering), + string(WorkflowProvisioningStateUpdating), + string(WorkflowProvisioningStateWaiting), + } +} + +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { + vals := map[string]WorkflowProvisioningState{ + "accepted": WorkflowProvisioningStateAccepted, + "canceled": WorkflowProvisioningStateCanceled, + "completed": WorkflowProvisioningStateCompleted, + "created": WorkflowProvisioningStateCreated, + "creating": WorkflowProvisioningStateCreating, + "deleted": WorkflowProvisioningStateDeleted, + "deleting": WorkflowProvisioningStateDeleting, + "failed": WorkflowProvisioningStateFailed, + "inprogress": WorkflowProvisioningStateInProgress, + "moving": WorkflowProvisioningStateMoving, + "notspecified": WorkflowProvisioningStateNotSpecified, + "pending": WorkflowProvisioningStatePending, + "ready": WorkflowProvisioningStateReady, + "registered": WorkflowProvisioningStateRegistered, + "registering": WorkflowProvisioningStateRegistering, + "renewing": WorkflowProvisioningStateRenewing, + "running": WorkflowProvisioningStateRunning, + "succeeded": WorkflowProvisioningStateSucceeded, + "unregistered": WorkflowProvisioningStateUnregistered, + "unregistering": WorkflowProvisioningStateUnregistering, + "updating": WorkflowProvisioningStateUpdating, + "waiting": WorkflowProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowProvisioningState(input) + return &out, nil +} + +type WorkflowSkuName string + +const ( + WorkflowSkuNameBasic WorkflowSkuName = "Basic" + WorkflowSkuNameFree WorkflowSkuName = "Free" + WorkflowSkuNameNotSpecified WorkflowSkuName = "NotSpecified" + WorkflowSkuNamePremium WorkflowSkuName = "Premium" + WorkflowSkuNameShared WorkflowSkuName = "Shared" + WorkflowSkuNameStandard WorkflowSkuName = "Standard" +) + +func PossibleValuesForWorkflowSkuName() []string { + return []string{ + string(WorkflowSkuNameBasic), + string(WorkflowSkuNameFree), + string(WorkflowSkuNameNotSpecified), + string(WorkflowSkuNamePremium), + string(WorkflowSkuNameShared), + string(WorkflowSkuNameStandard), + } +} + +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { + vals := map[string]WorkflowSkuName{ + "basic": WorkflowSkuNameBasic, + "free": WorkflowSkuNameFree, + "notspecified": WorkflowSkuNameNotSpecified, + "premium": WorkflowSkuNamePremium, + "shared": WorkflowSkuNameShared, + "standard": WorkflowSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowSkuName(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/workflows/id_managementworkflow.go b/resource-manager/web/2023-12-01/workflows/id_managementworkflow.go new file mode 100644 index 00000000000..bded96b67f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflows + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflows/id_managementworkflow_test.go b/resource-manager/web/2023-12-01/workflows/id_managementworkflow_test.go new file mode 100644 index 00000000000..f5cc807e354 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflows + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2023-12-01/workflows/method_regenerateaccesskey.go b/resource-manager/web/2023-12-01/workflows/method_regenerateaccesskey.go new file mode 100644 index 00000000000..6d15da4bbd2 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/method_regenerateaccesskey.go @@ -0,0 +1,51 @@ +package workflows + +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 RegenerateAccessKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateAccessKey ... +func (c WorkflowsClient) RegenerateAccessKey(ctx context.Context, id ManagementWorkflowId, input RegenerateActionParameter) (result RegenerateAccessKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateAccessKey", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflows/method_validate.go b/resource-manager/web/2023-12-01/workflows/method_validate.go new file mode 100644 index 00000000000..14ed7cd27b9 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/method_validate.go @@ -0,0 +1,51 @@ +package workflows + +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 ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Validate ... +func (c WorkflowsClient) Validate(ctx context.Context, id ManagementWorkflowId, input Workflow) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", 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 + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfiguration.go b/resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfiguration.go new file mode 100644 index 00000000000..e110c491fc2 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfiguration.go @@ -0,0 +1,11 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfiguration struct { + Actions *FlowAccessControlConfigurationPolicy `json:"actions,omitempty"` + Contents *FlowAccessControlConfigurationPolicy `json:"contents,omitempty"` + Triggers *FlowAccessControlConfigurationPolicy `json:"triggers,omitempty"` + WorkflowManagement *FlowAccessControlConfigurationPolicy `json:"workflowManagement,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfigurationpolicy.go b/resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfigurationpolicy.go new file mode 100644 index 00000000000..e14581b5ddc --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_flowaccesscontrolconfigurationpolicy.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfigurationPolicy struct { + AllowedCallerIPAddresses *[]IPAddressRange `json:"allowedCallerIpAddresses,omitempty"` + OpenAuthenticationPolicies *OpenAuthenticationAccessPolicies `json:"openAuthenticationPolicies,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_flowendpoints.go b/resource-manager/web/2023-12-01/workflows/model_flowendpoints.go new file mode 100644 index 00000000000..ab677222e7a --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_flowendpoints.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpoints struct { + AccessEndpointIPAddresses *[]IPAddress `json:"accessEndpointIpAddresses,omitempty"` + OutgoingIPAddresses *[]IPAddress `json:"outgoingIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_flowendpointsconfiguration.go b/resource-manager/web/2023-12-01/workflows/model_flowendpointsconfiguration.go new file mode 100644 index 00000000000..19393db48ab --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_flowendpointsconfiguration.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpointsConfiguration struct { + Connector *FlowEndpoints `json:"connector,omitempty"` + Workflow *FlowEndpoints `json:"workflow,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_ipaddress.go b/resource-manager/web/2023-12-01/workflows/model_ipaddress.go new file mode 100644 index 00000000000..0d10e34c4f8 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_ipaddress.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddress struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_ipaddressrange.go b/resource-manager/web/2023-12-01/workflows/model_ipaddressrange.go new file mode 100644 index 00000000000..347495131a8 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_ipaddressrange.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressRange struct { + AddressRange *string `json:"addressRange,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicies.go b/resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicies.go new file mode 100644 index 00000000000..a4b8fac5970 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicies.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicies struct { + Policies *map[string]OpenAuthenticationAccessPolicy `json:"policies,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicy.go b/resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicy.go new file mode 100644 index 00000000000..cf129596719 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_openauthenticationaccesspolicy.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicy struct { + Claims *[]OpenAuthenticationPolicyClaim `json:"claims,omitempty"` + Type *OpenAuthenticationProviderType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_openauthenticationpolicyclaim.go b/resource-manager/web/2023-12-01/workflows/model_openauthenticationpolicyclaim.go new file mode 100644 index 00000000000..3ab50a9ca9b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_openauthenticationpolicyclaim.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationPolicyClaim struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_regenerateactionparameter.go b/resource-manager/web/2023-12-01/workflows/model_regenerateactionparameter.go new file mode 100644 index 00000000000..a01c112c1c1 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_regenerateactionparameter.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateActionParameter struct { + KeyType *KeyType `json:"keyType,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_resourcereference.go b/resource-manager/web/2023-12-01/workflows/model_resourcereference.go new file mode 100644 index 00000000000..8541ecad863 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_workflow.go b/resource-manager/web/2023-12-01/workflows/model_workflow.go new file mode 100644 index 00000000000..7b9bb73f9b5 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_workflow.go @@ -0,0 +1,18 @@ +package workflows + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Workflow struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_workflowparameter.go b/resource-manager/web/2023-12-01/workflows/model_workflowparameter.go new file mode 100644 index 00000000000..c79cf198562 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_workflowparameter.go @@ -0,0 +1,11 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowParameter struct { + Description *string `json:"description,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/model_workflowproperties.go b/resource-manager/web/2023-12-01/workflows/model_workflowproperties.go new file mode 100644 index 00000000000..0dd6da80483 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_workflowproperties.go @@ -0,0 +1,51 @@ +package workflows + +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 WorkflowProperties struct { + AccessControl *FlowAccessControlConfiguration `json:"accessControl,omitempty"` + AccessEndpoint *string `json:"accessEndpoint,omitempty"` + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Definition *interface{} `json:"definition,omitempty"` + EndpointsConfiguration *FlowEndpointsConfiguration `json:"endpointsConfiguration,omitempty"` + IntegrationAccount *ResourceReference `json:"integrationAccount,omitempty"` + IntegrationServiceEnvironment *ResourceReference `json:"integrationServiceEnvironment,omitempty"` + Kind *Kind `json:"kind,omitempty"` + Parameters *map[string]WorkflowParameter `json:"parameters,omitempty"` + ProvisioningState *WorkflowProvisioningState `json:"provisioningState,omitempty"` + Sku *WorkflowSku `json:"sku,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *WorkflowProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflows/model_workflowsku.go b/resource-manager/web/2023-12-01/workflows/model_workflowsku.go new file mode 100644 index 00000000000..64591de779f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/model_workflowsku.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowSku struct { + Name WorkflowSkuName `json:"name"` + Plan *ResourceReference `json:"plan,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflows/version.go b/resource-manager/web/2023-12-01/workflows/version.go new file mode 100644 index 00000000000..1b7cfc80119 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflows/version.go @@ -0,0 +1,12 @@ +package workflows + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workflows/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/README.md b/resource-manager/web/2023-12-01/workflowtriggerhistories/README.md new file mode 100644 index 00000000000..5abec2718e9 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowtriggerhistories` Documentation + +The `workflowtriggerhistories` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowtriggerhistories" +``` + + +### Client Initialization + +```go +client := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowTriggerHistoriesClient.Get` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue", "historyValue") + +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: `WorkflowTriggerHistoriesClient.List` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue") + +// alternatively `client.List(ctx, id, workflowtriggerhistories.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowtriggerhistories.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowTriggerHistoriesClient.Resubmit` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue", "historyValue") + +if err := client.ResubmitThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/client.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/client.go new file mode 100644 index 00000000000..fc4b05de0ba --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/client.go @@ -0,0 +1,26 @@ +package workflowtriggerhistories + +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 WorkflowTriggerHistoriesClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowTriggerHistoriesClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowTriggerHistoriesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "workflowtriggerhistories", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggerHistoriesClient: %+v", err) + } + + return &WorkflowTriggerHistoriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/constants.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/constants.go new file mode 100644 index 00000000000..9ccf7819b12 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/constants.go @@ -0,0 +1,84 @@ +package workflowtriggerhistories + +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 WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger.go new file mode 100644 index 00000000000..66c61b8d260 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger.go @@ -0,0 +1,154 @@ +package workflowtriggerhistories + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggerId{}) +} + +var _ resourceids.ResourceId = &TriggerId{} + +// TriggerId is a struct representing the Resource ID for a Trigger +type TriggerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string +} + +// NewTriggerID returns a new TriggerId struct +func NewTriggerID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string) TriggerId { + return TriggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + } +} + +// ParseTriggerID parses 'input' into a TriggerId +func ParseTriggerID(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerIDInsensitively parses 'input' case-insensitively into a TriggerId +// note: this method should only be used for API response data and not user input +func ParseTriggerIDInsensitively(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + return nil +} + +// ValidateTriggerID checks that 'input' can be parsed as a Trigger ID +func ValidateTriggerID(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 := ParseTriggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger ID +func (id TriggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger ID +func (id TriggerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerValue"), + } +} + +// String returns a human-readable description of this Trigger ID +func (id TriggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + } + return fmt.Sprintf("Trigger (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger_test.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger_test.go new file mode 100644 index 00000000000..36f25c13729 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_trigger_test.go @@ -0,0 +1,462 @@ +package workflowtriggerhistories + +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 = &TriggerId{} + +func TestNewTriggerID(t *testing.T) { + id := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.TriggerName != "triggerValue" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerValue") + } +} + +func TestFormatTriggerID(t *testing.T) { + actual := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + TriggerName: "triggerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestParseTriggerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + TriggerName: "triggerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + TriggerName: "tRiGgErVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestSegmentsForTriggerId(t *testing.T) { + segments := TriggerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerId 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/web/2023-12-01/workflowtriggerhistories/id_triggerhistory.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_triggerhistory.go new file mode 100644 index 00000000000..f69ef638db4 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_triggerhistory.go @@ -0,0 +1,163 @@ +package workflowtriggerhistories + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggerHistoryId{}) +} + +var _ resourceids.ResourceId = &TriggerHistoryId{} + +// TriggerHistoryId is a struct representing the Resource ID for a Trigger History +type TriggerHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string + HistoryName string +} + +// NewTriggerHistoryID returns a new TriggerHistoryId struct +func NewTriggerHistoryID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string, historyName string) TriggerHistoryId { + return TriggerHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + HistoryName: historyName, + } +} + +// ParseTriggerHistoryID parses 'input' into a TriggerHistoryId +func ParseTriggerHistoryID(input string) (*TriggerHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerHistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerHistoryIDInsensitively parses 'input' case-insensitively into a TriggerHistoryId +// note: this method should only be used for API response data and not user input +func ParseTriggerHistoryIDInsensitively(input string) (*TriggerHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerHistoryId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerHistoryId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateTriggerHistoryID checks that 'input' can be parsed as a Trigger History ID +func ValidateTriggerHistoryID(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 := ParseTriggerHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger History ID +func (id TriggerHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s/histories/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger History ID +func (id TriggerHistoryId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerValue"), + resourceids.StaticSegment("staticHistories", "histories", "histories"), + resourceids.UserSpecifiedSegment("historyName", "historyValue"), + } +} + +// String returns a human-readable description of this Trigger History ID +func (id TriggerHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("Trigger History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/id_triggerhistory_test.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_triggerhistory_test.go new file mode 100644 index 00000000000..1eb76a2db2b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/id_triggerhistory_test.go @@ -0,0 +1,507 @@ +package workflowtriggerhistories + +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 = &TriggerHistoryId{} + +func TestNewTriggerHistoryID(t *testing.T) { + id := NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue", "historyValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.TriggerName != "triggerValue" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerValue") + } + + if id.HistoryName != "historyValue" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyValue") + } +} + +func TestFormatTriggerHistoryID(t *testing.T) { + actual := NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue", "historyValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/histories/historyValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/histories", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/histories/historyValue", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + TriggerName: "triggerValue", + HistoryName: "historyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/histories/historyValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseTriggerHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerHistoryId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/histories", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE/hIsToRiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/histories/historyValue", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + TriggerName: "triggerValue", + HistoryName: "historyValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/histories/historyValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE/hIsToRiEs/hIsToRyVaLuE", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + TriggerName: "tRiGgErVaLuE", + HistoryName: "hIsToRyVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE/hIsToRiEs/hIsToRyVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForTriggerHistoryId(t *testing.T) { + segments := TriggerHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerHistoryId 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/web/2023-12-01/workflowtriggerhistories/method_get.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/method_get.go new file mode 100644 index 00000000000..321b09eec4f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/method_get.go @@ -0,0 +1,54 @@ +package workflowtriggerhistories + +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 *WorkflowTriggerHistory +} + +// Get ... +func (c WorkflowTriggerHistoriesClient) Get(ctx context.Context, id TriggerHistoryId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowTriggerHistory + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/method_list.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/method_list.go new file mode 100644 index 00000000000..932a8ce7bfa --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/method_list.go @@ -0,0 +1,123 @@ +package workflowtriggerhistories + +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 *[]WorkflowTriggerHistory +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowTriggerHistory +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +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.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowTriggerHistoriesClient) List(ctx context.Context, id TriggerId, 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/histories", 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 *[]WorkflowTriggerHistory `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 WorkflowTriggerHistoriesClient) ListComplete(ctx context.Context, id TriggerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerHistoryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggerHistoriesClient) ListCompleteMatchingPredicate(ctx context.Context, id TriggerId, options ListOperationOptions, predicate WorkflowTriggerHistoryOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTriggerHistory, 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/web/2023-12-01/workflowtriggerhistories/method_resubmit.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/method_resubmit.go new file mode 100644 index 00000000000..3608c02e4dc --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/method_resubmit.go @@ -0,0 +1,69 @@ +package workflowtriggerhistories + +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 ResubmitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Resubmit ... +func (c WorkflowTriggerHistoriesClient) Resubmit(ctx context.Context, id TriggerHistoryId) (result ResubmitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resubmit", 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 +} + +// ResubmitThenPoll performs Resubmit then polls until it's completed +func (c WorkflowTriggerHistoriesClient) ResubmitThenPoll(ctx context.Context, id TriggerHistoryId) error { + result, err := c.Resubmit(ctx, id) + if err != nil { + return fmt.Errorf("performing Resubmit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resubmit: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/model_contenthash.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_contenthash.go new file mode 100644 index 00000000000..685fd29e9f7 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/model_contentlink.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_contentlink.go new file mode 100644 index 00000000000..73c25f49ab8 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/model_correlation.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_correlation.go new file mode 100644 index 00000000000..e052b2efb68 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_correlation.go @@ -0,0 +1,8 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Correlation struct { + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/model_resourcereference.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_resourcereference.go new file mode 100644 index 00000000000..ac6b3afa7c3 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistory.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistory.go new file mode 100644 index 00000000000..a1d64aebe3c --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistory.go @@ -0,0 +1,11 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistory struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowTriggerHistoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go new file mode 100644 index 00000000000..42821930e6a --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go @@ -0,0 +1,61 @@ +package workflowtriggerhistories + +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 WorkflowTriggerHistoryProperties struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Fired *bool `json:"fired,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + Run *ResourceReference `json:"run,omitempty"` + ScheduledTime *string `json:"scheduledTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowTriggerHistoryProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowTriggerHistoryProperties) GetScheduledTimeAsTime() (*time.Time, error) { + if o.ScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledTime = &formatted +} + +func (o *WorkflowTriggerHistoryProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowtriggerhistories/predicates.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/predicates.go new file mode 100644 index 00000000000..20fca9c869f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/predicates.go @@ -0,0 +1,27 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistoryOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowTriggerHistoryOperationPredicate) Matches(input WorkflowTriggerHistory) 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/web/2023-12-01/workflowtriggerhistories/version.go b/resource-manager/web/2023-12-01/workflowtriggerhistories/version.go new file mode 100644 index 00000000000..91bed02c969 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggerhistories/version.go @@ -0,0 +1,12 @@ +package workflowtriggerhistories + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workflowtriggerhistories/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/README.md b/resource-manager/web/2023-12-01/workflowtriggers/README.md new file mode 100644 index 00000000000..a91b58b3c36 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/README.md @@ -0,0 +1,97 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowtriggers` Documentation + +The `workflowtriggers` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowtriggers" +``` + + +### Client Initialization + +```go +client := workflowtriggers.NewWorkflowTriggersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowTriggersClient.Get` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue") + +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: `WorkflowTriggersClient.GetSchemaJson` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue") + +read, err := client.GetSchemaJson(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggersClient.List` + +```go +ctx := context.TODO() +id := workflowtriggers.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + +// alternatively `client.List(ctx, id, workflowtriggers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowtriggers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowTriggersClient.ListCallbackUrl` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue") + +read, err := client.ListCallbackUrl(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggersClient.Run` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue") + +if err := client.RunThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2023-12-01/workflowtriggers/client.go b/resource-manager/web/2023-12-01/workflowtriggers/client.go new file mode 100644 index 00000000000..4788e395649 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/client.go @@ -0,0 +1,26 @@ +package workflowtriggers + +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 WorkflowTriggersClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowTriggersClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowTriggersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "workflowtriggers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggersClient: %+v", err) + } + + return &WorkflowTriggersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/constants.go b/resource-manager/web/2023-12-01/workflowtriggers/constants.go new file mode 100644 index 00000000000..344f92609e4 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/constants.go @@ -0,0 +1,397 @@ +package workflowtriggers + +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 DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type DaysOfWeek string + +const ( + DaysOfWeekFriday DaysOfWeek = "Friday" + DaysOfWeekMonday DaysOfWeek = "Monday" + DaysOfWeekSaturday DaysOfWeek = "Saturday" + DaysOfWeekSunday DaysOfWeek = "Sunday" + DaysOfWeekThursday DaysOfWeek = "Thursday" + DaysOfWeekTuesday DaysOfWeek = "Tuesday" + DaysOfWeekWednesday DaysOfWeek = "Wednesday" +) + +func PossibleValuesForDaysOfWeek() []string { + return []string{ + string(DaysOfWeekFriday), + string(DaysOfWeekMonday), + string(DaysOfWeekSaturday), + string(DaysOfWeekSunday), + string(DaysOfWeekThursday), + string(DaysOfWeekTuesday), + string(DaysOfWeekWednesday), + } +} + +func (s *DaysOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaysOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaysOfWeek(input string) (*DaysOfWeek, error) { + vals := map[string]DaysOfWeek{ + "friday": DaysOfWeekFriday, + "monday": DaysOfWeekMonday, + "saturday": DaysOfWeekSaturday, + "sunday": DaysOfWeekSunday, + "thursday": DaysOfWeekThursday, + "tuesday": DaysOfWeekTuesday, + "wednesday": DaysOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaysOfWeek(input) + return &out, nil +} + +type RecurrenceFrequency string + +const ( + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + RecurrenceFrequencyNotSpecified RecurrenceFrequency = "NotSpecified" + RecurrenceFrequencySecond RecurrenceFrequency = "Second" + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" + RecurrenceFrequencyYear RecurrenceFrequency = "Year" +) + +func PossibleValuesForRecurrenceFrequency() []string { + return []string{ + string(RecurrenceFrequencyDay), + string(RecurrenceFrequencyHour), + string(RecurrenceFrequencyMinute), + string(RecurrenceFrequencyMonth), + string(RecurrenceFrequencyNotSpecified), + string(RecurrenceFrequencySecond), + string(RecurrenceFrequencyWeek), + string(RecurrenceFrequencyYear), + } +} + +func (s *RecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecurrenceFrequency(input string) (*RecurrenceFrequency, error) { + vals := map[string]RecurrenceFrequency{ + "day": RecurrenceFrequencyDay, + "hour": RecurrenceFrequencyHour, + "minute": RecurrenceFrequencyMinute, + "month": RecurrenceFrequencyMonth, + "notspecified": RecurrenceFrequencyNotSpecified, + "second": RecurrenceFrequencySecond, + "week": RecurrenceFrequencyWeek, + "year": RecurrenceFrequencyYear, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecurrenceFrequency(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} + +type WorkflowTriggerProvisioningState string + +const ( + WorkflowTriggerProvisioningStateAccepted WorkflowTriggerProvisioningState = "Accepted" + WorkflowTriggerProvisioningStateCanceled WorkflowTriggerProvisioningState = "Canceled" + WorkflowTriggerProvisioningStateCompleted WorkflowTriggerProvisioningState = "Completed" + WorkflowTriggerProvisioningStateCreated WorkflowTriggerProvisioningState = "Created" + WorkflowTriggerProvisioningStateCreating WorkflowTriggerProvisioningState = "Creating" + WorkflowTriggerProvisioningStateDeleted WorkflowTriggerProvisioningState = "Deleted" + WorkflowTriggerProvisioningStateDeleting WorkflowTriggerProvisioningState = "Deleting" + WorkflowTriggerProvisioningStateFailed WorkflowTriggerProvisioningState = "Failed" + WorkflowTriggerProvisioningStateMoving WorkflowTriggerProvisioningState = "Moving" + WorkflowTriggerProvisioningStateNotSpecified WorkflowTriggerProvisioningState = "NotSpecified" + WorkflowTriggerProvisioningStateReady WorkflowTriggerProvisioningState = "Ready" + WorkflowTriggerProvisioningStateRegistered WorkflowTriggerProvisioningState = "Registered" + WorkflowTriggerProvisioningStateRegistering WorkflowTriggerProvisioningState = "Registering" + WorkflowTriggerProvisioningStateRunning WorkflowTriggerProvisioningState = "Running" + WorkflowTriggerProvisioningStateSucceeded WorkflowTriggerProvisioningState = "Succeeded" + WorkflowTriggerProvisioningStateUnregistered WorkflowTriggerProvisioningState = "Unregistered" + WorkflowTriggerProvisioningStateUnregistering WorkflowTriggerProvisioningState = "Unregistering" + WorkflowTriggerProvisioningStateUpdating WorkflowTriggerProvisioningState = "Updating" +) + +func PossibleValuesForWorkflowTriggerProvisioningState() []string { + return []string{ + string(WorkflowTriggerProvisioningStateAccepted), + string(WorkflowTriggerProvisioningStateCanceled), + string(WorkflowTriggerProvisioningStateCompleted), + string(WorkflowTriggerProvisioningStateCreated), + string(WorkflowTriggerProvisioningStateCreating), + string(WorkflowTriggerProvisioningStateDeleted), + string(WorkflowTriggerProvisioningStateDeleting), + string(WorkflowTriggerProvisioningStateFailed), + string(WorkflowTriggerProvisioningStateMoving), + string(WorkflowTriggerProvisioningStateNotSpecified), + string(WorkflowTriggerProvisioningStateReady), + string(WorkflowTriggerProvisioningStateRegistered), + string(WorkflowTriggerProvisioningStateRegistering), + string(WorkflowTriggerProvisioningStateRunning), + string(WorkflowTriggerProvisioningStateSucceeded), + string(WorkflowTriggerProvisioningStateUnregistered), + string(WorkflowTriggerProvisioningStateUnregistering), + string(WorkflowTriggerProvisioningStateUpdating), + } +} + +func (s *WorkflowTriggerProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowTriggerProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowTriggerProvisioningState(input string) (*WorkflowTriggerProvisioningState, error) { + vals := map[string]WorkflowTriggerProvisioningState{ + "accepted": WorkflowTriggerProvisioningStateAccepted, + "canceled": WorkflowTriggerProvisioningStateCanceled, + "completed": WorkflowTriggerProvisioningStateCompleted, + "created": WorkflowTriggerProvisioningStateCreated, + "creating": WorkflowTriggerProvisioningStateCreating, + "deleted": WorkflowTriggerProvisioningStateDeleted, + "deleting": WorkflowTriggerProvisioningStateDeleting, + "failed": WorkflowTriggerProvisioningStateFailed, + "moving": WorkflowTriggerProvisioningStateMoving, + "notspecified": WorkflowTriggerProvisioningStateNotSpecified, + "ready": WorkflowTriggerProvisioningStateReady, + "registered": WorkflowTriggerProvisioningStateRegistered, + "registering": WorkflowTriggerProvisioningStateRegistering, + "running": WorkflowTriggerProvisioningStateRunning, + "succeeded": WorkflowTriggerProvisioningStateSucceeded, + "unregistered": WorkflowTriggerProvisioningStateUnregistered, + "unregistering": WorkflowTriggerProvisioningStateUnregistering, + "updating": WorkflowTriggerProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowTriggerProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow.go b/resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow.go new file mode 100644 index 00000000000..6c04d3a8fa8 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowtriggers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow_test.go b/resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow_test.go new file mode 100644 index 00000000000..f0663d91b58 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowtriggers + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2023-12-01/workflowtriggers/id_trigger.go b/resource-manager/web/2023-12-01/workflowtriggers/id_trigger.go new file mode 100644 index 00000000000..aacc113189c --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/id_trigger.go @@ -0,0 +1,154 @@ +package workflowtriggers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggerId{}) +} + +var _ resourceids.ResourceId = &TriggerId{} + +// TriggerId is a struct representing the Resource ID for a Trigger +type TriggerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string +} + +// NewTriggerID returns a new TriggerId struct +func NewTriggerID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string) TriggerId { + return TriggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + } +} + +// ParseTriggerID parses 'input' into a TriggerId +func ParseTriggerID(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerIDInsensitively parses 'input' case-insensitively into a TriggerId +// note: this method should only be used for API response data and not user input +func ParseTriggerIDInsensitively(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + return nil +} + +// ValidateTriggerID checks that 'input' can be parsed as a Trigger ID +func ValidateTriggerID(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 := ParseTriggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger ID +func (id TriggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger ID +func (id TriggerId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerValue"), + } +} + +// String returns a human-readable description of this Trigger ID +func (id TriggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + } + return fmt.Sprintf("Trigger (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/id_trigger_test.go b/resource-manager/web/2023-12-01/workflowtriggers/id_trigger_test.go new file mode 100644 index 00000000000..a523528ca33 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/id_trigger_test.go @@ -0,0 +1,462 @@ +package workflowtriggers + +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 = &TriggerId{} + +func TestNewTriggerID(t *testing.T) { + id := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.TriggerName != "triggerValue" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerValue") + } +} + +func TestFormatTriggerID(t *testing.T) { + actual := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "triggerValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + TriggerName: "triggerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestParseTriggerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + TriggerName: "triggerValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/triggers/triggerValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + TriggerName: "tRiGgErVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/tRiGgErS/tRiGgErVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestSegmentsForTriggerId(t *testing.T) { + segments := TriggerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerId 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/web/2023-12-01/workflowtriggers/method_get.go b/resource-manager/web/2023-12-01/workflowtriggers/method_get.go new file mode 100644 index 00000000000..6ff7e339030 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/method_get.go @@ -0,0 +1,54 @@ +package workflowtriggers + +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 *WorkflowTrigger +} + +// Get ... +func (c WorkflowTriggersClient) Get(ctx context.Context, id TriggerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowTrigger + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/method_getschemajson.go b/resource-manager/web/2023-12-01/workflowtriggers/method_getschemajson.go new file mode 100644 index 00000000000..286934bd0ea --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/method_getschemajson.go @@ -0,0 +1,55 @@ +package workflowtriggers + +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 GetSchemaJsonOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JsonSchema +} + +// GetSchemaJson ... +func (c WorkflowTriggersClient) GetSchemaJson(ctx context.Context, id TriggerId) (result GetSchemaJsonOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas/json", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model JsonSchema + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/method_list.go b/resource-manager/web/2023-12-01/workflowtriggers/method_list.go new file mode 100644 index 00000000000..d5bdab00f48 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/method_list.go @@ -0,0 +1,123 @@ +package workflowtriggers + +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 *[]WorkflowTrigger +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowTrigger +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +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.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowTriggersClient) List(ctx context.Context, id ManagementWorkflowId, 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/triggers", 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 *[]WorkflowTrigger `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 WorkflowTriggersClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggersClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowTriggerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTrigger, 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/web/2023-12-01/workflowtriggers/method_listcallbackurl.go b/resource-manager/web/2023-12-01/workflowtriggers/method_listcallbackurl.go new file mode 100644 index 00000000000..5f6d581c207 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/method_listcallbackurl.go @@ -0,0 +1,55 @@ +package workflowtriggers + +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 ListCallbackUrlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTriggerCallbackUrl +} + +// ListCallbackUrl ... +func (c WorkflowTriggersClient) ListCallbackUrl(ctx context.Context, id TriggerId) (result ListCallbackUrlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listCallbackUrl", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowTriggerCallbackUrl + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/method_run.go b/resource-manager/web/2023-12-01/workflowtriggers/method_run.go new file mode 100644 index 00000000000..2fa34636832 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/method_run.go @@ -0,0 +1,70 @@ +package workflowtriggers + +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 RunOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Run ... +func (c WorkflowTriggersClient) Run(ctx context.Context, id TriggerId) (result RunOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", 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 +} + +// RunThenPoll performs Run then polls until it's completed +func (c WorkflowTriggersClient) RunThenPoll(ctx context.Context, id TriggerId) error { + result, err := c.Run(ctx, id) + if err != nil { + return fmt.Errorf("performing Run: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Run: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_jsonschema.go b/resource-manager/web/2023-12-01/workflowtriggers/model_jsonschema.go new file mode 100644 index 00000000000..9dbec86f757 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_jsonschema.go @@ -0,0 +1,9 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JsonSchema struct { + Content *string `json:"content,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_recurrenceschedule.go b/resource-manager/web/2023-12-01/workflowtriggers/model_recurrenceschedule.go new file mode 100644 index 00000000000..7ea8413d4cd --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_recurrenceschedule.go @@ -0,0 +1,12 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceSchedule struct { + Hours *[]int64 `json:"hours,omitempty"` + Minutes *[]int64 `json:"minutes,omitempty"` + MonthDays *[]int64 `json:"monthDays,omitempty"` + MonthlyOccurrences *[]RecurrenceScheduleOccurrence `json:"monthlyOccurrences,omitempty"` + WeekDays *[]DaysOfWeek `json:"weekDays,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_recurrencescheduleoccurrence.go b/resource-manager/web/2023-12-01/workflowtriggers/model_recurrencescheduleoccurrence.go new file mode 100644 index 00000000000..39f417c38d7 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_recurrencescheduleoccurrence.go @@ -0,0 +1,9 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceScheduleOccurrence struct { + Day *DayOfWeek `json:"day,omitempty"` + Occurrence *int64 `json:"occurrence,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_resourcereference.go b/resource-manager/web/2023-12-01/workflowtriggers/model_resourcereference.go new file mode 100644 index 00000000000..f96ba2e28a0 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtrigger.go b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtrigger.go new file mode 100644 index 00000000000..b2502e9f9c4 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtrigger.go @@ -0,0 +1,11 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTrigger struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowTriggerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggercallbackurl.go b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggercallbackurl.go new file mode 100644 index 00000000000..fd5a9082bd7 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggercallbackurl.go @@ -0,0 +1,13 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerCallbackUrl struct { + BasePath *string `json:"basePath,omitempty"` + Method *string `json:"method,omitempty"` + Queries *WorkflowTriggerListCallbackUrlQueries `json:"queries,omitempty"` + RelativePath *string `json:"relativePath,omitempty"` + RelativePathParameters *[]string `json:"relativePathParameters,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go new file mode 100644 index 00000000000..cc3b231968b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go @@ -0,0 +1,12 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerListCallbackUrlQueries struct { + ApiVersion *string `json:"api-version,omitempty"` + Se *string `json:"se,omitempty"` + Sig *string `json:"sig,omitempty"` + Sp *string `json:"sp,omitempty"` + Sv *string `json:"sv,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerproperties.go b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerproperties.go new file mode 100644 index 00000000000..b860a57a39c --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerproperties.go @@ -0,0 +1,70 @@ +package workflowtriggers + +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 WorkflowTriggerProperties struct { + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + LastExecutionTime *string `json:"lastExecutionTime,omitempty"` + NextExecutionTime *string `json:"nextExecutionTime,omitempty"` + ProvisioningState *WorkflowTriggerProvisioningState `json:"provisioningState,omitempty"` + Recurrence *WorkflowTriggerRecurrence `json:"recurrence,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + Workflow *ResourceReference `json:"workflow,omitempty"` +} + +func (o *WorkflowTriggerProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetLastExecutionTimeAsTime() (*time.Time, error) { + if o.LastExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetLastExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastExecutionTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetNextExecutionTimeAsTime() (*time.Time, error) { + if o.NextExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetNextExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextExecutionTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerrecurrence.go b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerrecurrence.go new file mode 100644 index 00000000000..ec9873b4518 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/model_workflowtriggerrecurrence.go @@ -0,0 +1,13 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerRecurrence struct { + EndTime *string `json:"endTime,omitempty"` + Frequency *RecurrenceFrequency `json:"frequency,omitempty"` + Interval *int64 `json:"interval,omitempty"` + Schedule *RecurrenceSchedule `json:"schedule,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowtriggers/predicates.go b/resource-manager/web/2023-12-01/workflowtriggers/predicates.go new file mode 100644 index 00000000000..724f6388737 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/predicates.go @@ -0,0 +1,27 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowTriggerOperationPredicate) Matches(input WorkflowTrigger) 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/web/2023-12-01/workflowtriggers/version.go b/resource-manager/web/2023-12-01/workflowtriggers/version.go new file mode 100644 index 00000000000..0789cc30fdb --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowtriggers/version.go @@ -0,0 +1,12 @@ +package workflowtriggers + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workflowtriggers/%s", defaultApiVersion) +} diff --git a/resource-manager/web/2023-12-01/workflowversions/README.md b/resource-manager/web/2023-12-01/workflowversions/README.md new file mode 100644 index 00000000000..7a0d0c71022 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowversions` Documentation + +The `workflowversions` SDK allows for interaction with the Azure Resource Manager Service `web` (API Version `2023-12-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-12-01/workflowversions" +``` + + +### Client Initialization + +```go +client := workflowversions.NewWorkflowVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowVersionsClient.Get` + +```go +ctx := context.TODO() +id := workflowversions.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "versionIdValue") + +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: `WorkflowVersionsClient.List` + +```go +ctx := context.TODO() +id := workflowversions.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + +// alternatively `client.List(ctx, id, workflowversions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowversions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2023-12-01/workflowversions/client.go b/resource-manager/web/2023-12-01/workflowversions/client.go new file mode 100644 index 00000000000..8a0b4fbb7be --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/client.go @@ -0,0 +1,26 @@ +package workflowversions + +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 WorkflowVersionsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowVersionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "workflowversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowVersionsClient: %+v", err) + } + + return &WorkflowVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2023-12-01/workflowversions/constants.go b/resource-manager/web/2023-12-01/workflowversions/constants.go new file mode 100644 index 00000000000..fe1be75f3e9 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/constants.go @@ -0,0 +1,317 @@ +package workflowversions + +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 OpenAuthenticationProviderType string + +const ( + OpenAuthenticationProviderTypeAAD OpenAuthenticationProviderType = "AAD" +) + +func PossibleValuesForOpenAuthenticationProviderType() []string { + return []string{ + string(OpenAuthenticationProviderTypeAAD), + } +} + +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { + vals := map[string]OpenAuthenticationProviderType{ + "aad": OpenAuthenticationProviderTypeAAD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OpenAuthenticationProviderType(input) + return &out, nil +} + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowProvisioningState string + +const ( + WorkflowProvisioningStateAccepted WorkflowProvisioningState = "Accepted" + WorkflowProvisioningStateCanceled WorkflowProvisioningState = "Canceled" + WorkflowProvisioningStateCompleted WorkflowProvisioningState = "Completed" + WorkflowProvisioningStateCreated WorkflowProvisioningState = "Created" + WorkflowProvisioningStateCreating WorkflowProvisioningState = "Creating" + WorkflowProvisioningStateDeleted WorkflowProvisioningState = "Deleted" + WorkflowProvisioningStateDeleting WorkflowProvisioningState = "Deleting" + WorkflowProvisioningStateFailed WorkflowProvisioningState = "Failed" + WorkflowProvisioningStateInProgress WorkflowProvisioningState = "InProgress" + WorkflowProvisioningStateMoving WorkflowProvisioningState = "Moving" + WorkflowProvisioningStateNotSpecified WorkflowProvisioningState = "NotSpecified" + WorkflowProvisioningStatePending WorkflowProvisioningState = "Pending" + WorkflowProvisioningStateReady WorkflowProvisioningState = "Ready" + WorkflowProvisioningStateRegistered WorkflowProvisioningState = "Registered" + WorkflowProvisioningStateRegistering WorkflowProvisioningState = "Registering" + WorkflowProvisioningStateRenewing WorkflowProvisioningState = "Renewing" + WorkflowProvisioningStateRunning WorkflowProvisioningState = "Running" + WorkflowProvisioningStateSucceeded WorkflowProvisioningState = "Succeeded" + WorkflowProvisioningStateUnregistered WorkflowProvisioningState = "Unregistered" + WorkflowProvisioningStateUnregistering WorkflowProvisioningState = "Unregistering" + WorkflowProvisioningStateUpdating WorkflowProvisioningState = "Updating" + WorkflowProvisioningStateWaiting WorkflowProvisioningState = "Waiting" +) + +func PossibleValuesForWorkflowProvisioningState() []string { + return []string{ + string(WorkflowProvisioningStateAccepted), + string(WorkflowProvisioningStateCanceled), + string(WorkflowProvisioningStateCompleted), + string(WorkflowProvisioningStateCreated), + string(WorkflowProvisioningStateCreating), + string(WorkflowProvisioningStateDeleted), + string(WorkflowProvisioningStateDeleting), + string(WorkflowProvisioningStateFailed), + string(WorkflowProvisioningStateInProgress), + string(WorkflowProvisioningStateMoving), + string(WorkflowProvisioningStateNotSpecified), + string(WorkflowProvisioningStatePending), + string(WorkflowProvisioningStateReady), + string(WorkflowProvisioningStateRegistered), + string(WorkflowProvisioningStateRegistering), + string(WorkflowProvisioningStateRenewing), + string(WorkflowProvisioningStateRunning), + string(WorkflowProvisioningStateSucceeded), + string(WorkflowProvisioningStateUnregistered), + string(WorkflowProvisioningStateUnregistering), + string(WorkflowProvisioningStateUpdating), + string(WorkflowProvisioningStateWaiting), + } +} + +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { + vals := map[string]WorkflowProvisioningState{ + "accepted": WorkflowProvisioningStateAccepted, + "canceled": WorkflowProvisioningStateCanceled, + "completed": WorkflowProvisioningStateCompleted, + "created": WorkflowProvisioningStateCreated, + "creating": WorkflowProvisioningStateCreating, + "deleted": WorkflowProvisioningStateDeleted, + "deleting": WorkflowProvisioningStateDeleting, + "failed": WorkflowProvisioningStateFailed, + "inprogress": WorkflowProvisioningStateInProgress, + "moving": WorkflowProvisioningStateMoving, + "notspecified": WorkflowProvisioningStateNotSpecified, + "pending": WorkflowProvisioningStatePending, + "ready": WorkflowProvisioningStateReady, + "registered": WorkflowProvisioningStateRegistered, + "registering": WorkflowProvisioningStateRegistering, + "renewing": WorkflowProvisioningStateRenewing, + "running": WorkflowProvisioningStateRunning, + "succeeded": WorkflowProvisioningStateSucceeded, + "unregistered": WorkflowProvisioningStateUnregistered, + "unregistering": WorkflowProvisioningStateUnregistering, + "updating": WorkflowProvisioningStateUpdating, + "waiting": WorkflowProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowProvisioningState(input) + return &out, nil +} + +type WorkflowSkuName string + +const ( + WorkflowSkuNameBasic WorkflowSkuName = "Basic" + WorkflowSkuNameFree WorkflowSkuName = "Free" + WorkflowSkuNameNotSpecified WorkflowSkuName = "NotSpecified" + WorkflowSkuNamePremium WorkflowSkuName = "Premium" + WorkflowSkuNameShared WorkflowSkuName = "Shared" + WorkflowSkuNameStandard WorkflowSkuName = "Standard" +) + +func PossibleValuesForWorkflowSkuName() []string { + return []string{ + string(WorkflowSkuNameBasic), + string(WorkflowSkuNameFree), + string(WorkflowSkuNameNotSpecified), + string(WorkflowSkuNamePremium), + string(WorkflowSkuNameShared), + string(WorkflowSkuNameStandard), + } +} + +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { + vals := map[string]WorkflowSkuName{ + "basic": WorkflowSkuNameBasic, + "free": WorkflowSkuNameFree, + "notspecified": WorkflowSkuNameNotSpecified, + "premium": WorkflowSkuNamePremium, + "shared": WorkflowSkuNameShared, + "standard": WorkflowSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowSkuName(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2023-12-01/workflowversions/id_managementworkflow.go b/resource-manager/web/2023-12-01/workflowversions/id_managementworkflow.go new file mode 100644 index 00000000000..2c77e05839a --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(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 := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowversions/id_managementworkflow_test.go b/resource-manager/web/2023-12-01/workflowversions/id_managementworkflow_test.go new file mode 100644 index 00000000000..657a4c5180f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowversions + +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 = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId 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/web/2023-12-01/workflowversions/id_version.go b/resource-manager/web/2023-12-01/workflowversions/id_version.go new file mode 100644 index 00000000000..c08f6c0a48d --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/id_version.go @@ -0,0 +1,154 @@ +package workflowversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VersionId{}) +} + +var _ resourceids.ResourceId = &VersionId{} + +// VersionId is a struct representing the Resource ID for a Version +type VersionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + VersionId string +} + +// NewVersionID returns a new VersionId struct +func NewVersionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, versionId string) VersionId { + return VersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + VersionId: versionId, + } +} + +// ParseVersionID parses 'input' into a VersionId +func ParseVersionID(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVersionIDInsensitively parses 'input' case-insensitively into a VersionId +// note: this method should only be used for API response data and not user input +func ParseVersionIDInsensitively(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VersionId) 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.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.VersionId, ok = input.Parsed["versionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionId", input) + } + + return nil +} + +// ValidateVersionID checks that 'input' can be parsed as a Version ID +func ValidateVersionID(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 := ParseVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Version ID +func (id VersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.VersionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Version ID +func (id VersionId) 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("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteValue"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowValue"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionId", "versionIdValue"), + } +} + +// String returns a human-readable description of this Version ID +func (id VersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Version: %q", id.VersionId), + } + return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2023-12-01/workflowversions/id_version_test.go b/resource-manager/web/2023-12-01/workflowversions/id_version_test.go new file mode 100644 index 00000000000..4c2e4ac2f4f --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/id_version_test.go @@ -0,0 +1,462 @@ +package workflowversions + +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 = &VersionId{} + +func TestNewVersionID(t *testing.T) { + id := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "versionIdValue") + + 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.SiteName != "siteValue" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteValue") + } + + if id.WorkflowName != "workflowValue" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowValue") + } + + if id.VersionId != "versionIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'VersionId'", id.VersionId, "versionIdValue") + } +} + +func TestFormatVersionID(t *testing.T) { + actual := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteValue", "workflowValue", "versionIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/versions/versionIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/versions/versionIdValue", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + VersionId: "versionIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/versions/versionIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.VersionId != v.Expected.VersionId { + t.Fatalf("Expected %q but got %q for VersionId", v.Expected.VersionId, actual.VersionId) + } + + } +} + +func TestParseVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // 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.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/versions/versionIdValue", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteValue", + WorkflowName: "workflowValue", + VersionId: "versionIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteValue/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowValue/versions/versionIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/vErSiOnS/vErSiOnIdVaLuE", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEvAlUe", + WorkflowName: "wOrKfLoWvAlUe", + VersionId: "vErSiOnIdVaLuE", + }, + }, + { + // 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.wEb/sItEs/sItEvAlUe/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWvAlUe/vErSiOnS/vErSiOnIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.VersionId != v.Expected.VersionId { + t.Fatalf("Expected %q but got %q for VersionId", v.Expected.VersionId, actual.VersionId) + } + + } +} + +func TestSegmentsForVersionId(t *testing.T) { + segments := VersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VersionId 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/web/2023-12-01/workflowversions/method_get.go b/resource-manager/web/2023-12-01/workflowversions/method_get.go new file mode 100644 index 00000000000..f0742aafdc1 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/method_get.go @@ -0,0 +1,54 @@ +package workflowversions + +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 *WorkflowVersion +} + +// Get ... +func (c WorkflowVersionsClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowVersion + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2023-12-01/workflowversions/method_list.go b/resource-manager/web/2023-12-01/workflowversions/method_list.go new file mode 100644 index 00000000000..700905b7d99 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/method_list.go @@ -0,0 +1,119 @@ +package workflowversions + +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 *[]WorkflowVersion +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowVersion +} + +type ListOperationOptions struct { + Top *int64 +} + +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.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c WorkflowVersionsClient) List(ctx context.Context, id ManagementWorkflowId, 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/versions", 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 *[]WorkflowVersion `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 WorkflowVersionsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowVersionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowVersionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowVersionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowVersion, 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/web/2023-12-01/workflowversions/model_flowaccesscontrolconfiguration.go b/resource-manager/web/2023-12-01/workflowversions/model_flowaccesscontrolconfiguration.go new file mode 100644 index 00000000000..4d1b24e5c47 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_flowaccesscontrolconfiguration.go @@ -0,0 +1,11 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfiguration struct { + Actions *FlowAccessControlConfigurationPolicy `json:"actions,omitempty"` + Contents *FlowAccessControlConfigurationPolicy `json:"contents,omitempty"` + Triggers *FlowAccessControlConfigurationPolicy `json:"triggers,omitempty"` + WorkflowManagement *FlowAccessControlConfigurationPolicy `json:"workflowManagement,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go b/resource-manager/web/2023-12-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go new file mode 100644 index 00000000000..623db6898d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfigurationPolicy struct { + AllowedCallerIPAddresses *[]IPAddressRange `json:"allowedCallerIpAddresses,omitempty"` + OpenAuthenticationPolicies *OpenAuthenticationAccessPolicies `json:"openAuthenticationPolicies,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_flowendpoints.go b/resource-manager/web/2023-12-01/workflowversions/model_flowendpoints.go new file mode 100644 index 00000000000..78fd2c63224 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_flowendpoints.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpoints struct { + AccessEndpointIPAddresses *[]IPAddress `json:"accessEndpointIpAddresses,omitempty"` + OutgoingIPAddresses *[]IPAddress `json:"outgoingIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_flowendpointsconfiguration.go b/resource-manager/web/2023-12-01/workflowversions/model_flowendpointsconfiguration.go new file mode 100644 index 00000000000..dd3a411d472 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_flowendpointsconfiguration.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpointsConfiguration struct { + Connector *FlowEndpoints `json:"connector,omitempty"` + Workflow *FlowEndpoints `json:"workflow,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_ipaddress.go b/resource-manager/web/2023-12-01/workflowversions/model_ipaddress.go new file mode 100644 index 00000000000..2594d6696b1 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_ipaddress.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddress struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_ipaddressrange.go b/resource-manager/web/2023-12-01/workflowversions/model_ipaddressrange.go new file mode 100644 index 00000000000..c663c9f3a9e --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_ipaddressrange.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressRange struct { + AddressRange *string `json:"addressRange,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicies.go b/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicies.go new file mode 100644 index 00000000000..5b41cfe9f74 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicies.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicies struct { + Policies *map[string]OpenAuthenticationAccessPolicy `json:"policies,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicy.go b/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicy.go new file mode 100644 index 00000000000..2a53bfad87e --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationaccesspolicy.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicy struct { + Claims *[]OpenAuthenticationPolicyClaim `json:"claims,omitempty"` + Type *OpenAuthenticationProviderType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationpolicyclaim.go b/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationpolicyclaim.go new file mode 100644 index 00000000000..2df917da9bc --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_openauthenticationpolicyclaim.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationPolicyClaim struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_resourcereference.go b/resource-manager/web/2023-12-01/workflowversions/model_resourcereference.go new file mode 100644 index 00000000000..095116732d9 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_workflowparameter.go b/resource-manager/web/2023-12-01/workflowversions/model_workflowparameter.go new file mode 100644 index 00000000000..4adc5e9fef6 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_workflowparameter.go @@ -0,0 +1,11 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowParameter struct { + Description *string `json:"description,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_workflowsku.go b/resource-manager/web/2023-12-01/workflowversions/model_workflowsku.go new file mode 100644 index 00000000000..d5bcab2e40e --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_workflowsku.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowSku struct { + Name WorkflowSkuName `json:"name"` + Plan *ResourceReference `json:"plan,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_workflowversion.go b/resource-manager/web/2023-12-01/workflowversions/model_workflowversion.go new file mode 100644 index 00000000000..ae7647f4412 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_workflowversion.go @@ -0,0 +1,13 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersion struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowVersionProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2023-12-01/workflowversions/model_workflowversionproperties.go b/resource-manager/web/2023-12-01/workflowversions/model_workflowversionproperties.go new file mode 100644 index 00000000000..0d9459677c9 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/model_workflowversionproperties.go @@ -0,0 +1,49 @@ +package workflowversions + +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 WorkflowVersionProperties struct { + AccessControl *FlowAccessControlConfiguration `json:"accessControl,omitempty"` + AccessEndpoint *string `json:"accessEndpoint,omitempty"` + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Definition *interface{} `json:"definition,omitempty"` + EndpointsConfiguration *FlowEndpointsConfiguration `json:"endpointsConfiguration,omitempty"` + IntegrationAccount *ResourceReference `json:"integrationAccount,omitempty"` + Parameters *map[string]WorkflowParameter `json:"parameters,omitempty"` + ProvisioningState *WorkflowProvisioningState `json:"provisioningState,omitempty"` + Sku *WorkflowSku `json:"sku,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *WorkflowVersionProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowVersionProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowVersionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowVersionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2023-12-01/workflowversions/predicates.go b/resource-manager/web/2023-12-01/workflowversions/predicates.go new file mode 100644 index 00000000000..1458230244b --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/predicates.go @@ -0,0 +1,32 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersionOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkflowVersionOperationPredicate) Matches(input WorkflowVersion) 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/web/2023-12-01/workflowversions/version.go b/resource-manager/web/2023-12-01/workflowversions/version.go new file mode 100644 index 00000000000..415e8c62326 --- /dev/null +++ b/resource-manager/web/2023-12-01/workflowversions/version.go @@ -0,0 +1,12 @@ +package workflowversions + +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-12-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/workflowversions/%s", defaultApiVersion) +}